Skip to content

Commit 90f180d

Browse files
committed
Revert "refactor: add SKIP_SUBMODULE_DEPS to postinstall"
This reverts commit 9d3ad87.
1 parent bcadec1 commit 90f180d

File tree

4 files changed

+88
-7
lines changed

4 files changed

+88
-7
lines changed

ci/dev/postinstall.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ main() {
2929

3030
install-deps test
3131
install-deps test/e2e/extensions/test-extension
32-
# We don't need these when running the integration tests
33-
# so you can pass SKIP_SUBMODULE_DEPS
34-
if [[ ! ${SKIP_SUBMODULE_DEPS-} ]]; then
35-
install-deps lib/vscode
36-
fi
32+
install-deps lib/vscode
3733
}
3834

3935
main "$@"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"release:prep": "./ci/build/release-prep.sh",
2020
"test:e2e": "VSCODE_IPC_HOOK_CLI= ./ci/dev/test-e2e.sh",
2121
"test:unit": "./ci/dev/test-unit.sh --forceExit --detectOpenHandles",
22-
"test:integration": "SKIP_SUBMODULE_DEPS=1 ./ci/dev/test-integration.sh",
22+
"test:integration": "./ci/dev/test-integration.sh",
2323
"test:scripts": "./ci/dev/test-scripts.sh",
2424
"package": "./ci/build/build-packages.sh",
2525
"postinstall": "./ci/dev/postinstall.sh",

test/integration/installExtension.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { clean, tmpdir } from "../utils/helpers"
2-
import { runCodeServerCommand } from "../utils/runCodeServerCommand"
2+
import { runCodeServerCommand } from "../utils/integration"
33

44
describe("--install-extension", () => {
55
const testName = "installExtension"

test/utils/integration.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { spawn } from "child_process"
12
import { promises as fs } from "fs"
23
import * as path from "path"
34
import { parse, parseConfigFile, setDefaults } from "../../src/node/cli"
@@ -29,3 +30,87 @@ export async function setup(argv: string[], configFile?: string): Promise<httpse
2930

3031
return new httpserver.HttpServer(server)
3132
}
33+
34+
type RunCodeServerCommandOptions = {
35+
stderr?: "log"
36+
stdout?: "log"
37+
ignoreFail?: boolean
38+
}
39+
interface ErrorWithMoreInfo extends Error {
40+
stderr: string
41+
stdout: string
42+
}
43+
44+
type CSCmd =
45+
| {
46+
code: number | null
47+
signal: NodeJS.Signals | null
48+
stdout: string
49+
stderr: string
50+
}
51+
| ErrorWithMoreInfo
52+
53+
/**
54+
*
55+
* A helper function for integration tests to run code-server commands.
56+
*/
57+
export async function runCodeServerCommand(argv: string[], options: RunCodeServerCommandOptions = {}): Promise<CSCmd> {
58+
const CODE_SERVER_COMMAND = process.env.CODE_SERVER_PATH || "/var/tmp/coder/code-server/bin/code-server"
59+
// Credit: https://github.com/vercel/next.js/blob/canary/test/lib/next-test-utils.js#L139
60+
return new Promise((resolve, reject) => {
61+
console.log(`Running command "${CODE_SERVER_COMMAND} ${argv.join(" ")}"`)
62+
const instance = spawn(CODE_SERVER_COMMAND, [...argv])
63+
let mergedStdio = ""
64+
65+
let stderrOutput = ""
66+
if (options.stderr) {
67+
instance.stderr.on("data", function (chunk) {
68+
mergedStdio += chunk
69+
stderrOutput += chunk
70+
71+
if (options.stderr === "log") {
72+
console.log(chunk.toString())
73+
}
74+
})
75+
} else {
76+
instance.stderr.on("data", function (chunk) {
77+
mergedStdio += chunk
78+
})
79+
}
80+
81+
let stdoutOutput = ""
82+
if (options.stdout) {
83+
instance.stdout.on("data", function (chunk) {
84+
mergedStdio += chunk
85+
stdoutOutput += chunk
86+
87+
if (options.stdout === "log") {
88+
console.log(chunk.toString())
89+
}
90+
})
91+
} else {
92+
instance.stdout.on("data", function (chunk) {
93+
mergedStdio += chunk
94+
})
95+
}
96+
97+
instance.on("close", (code, signal) => {
98+
if (!options.stderr && !options.stdout && !options.ignoreFail && code !== 0) {
99+
return reject(new Error(`command failed with code ${code}\n${mergedStdio}`))
100+
}
101+
102+
resolve({
103+
code,
104+
signal,
105+
stdout: stdoutOutput,
106+
stderr: stderrOutput,
107+
})
108+
})
109+
110+
instance.on("error", (err: ErrorWithMoreInfo) => {
111+
err.stdout = stdoutOutput
112+
err.stderr = stderrOutput
113+
reject(err)
114+
})
115+
})
116+
}

0 commit comments

Comments
 (0)