Skip to content

Commit 831cf10

Browse files
authored
Fix running Extension Tests from VS Code (#1773)
The `Extension Tests` launch config stopped working because the vscode-test.js prints console output, which VS Code now wants to interpret as JSON configuration. Only log when we're building in CI.
1 parent d4561f3 commit 831cf10

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.vscode-test.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ const dataDir = process.env["VSCODE_DATA_DIR"];
2424
// "env" in launch.json doesn't seem to work with vscode-test
2525
const isDebugRun = !(process.env["_"] ?? "").endsWith("node_modules/.bin/vscode-test");
2626

27+
function log(...args) {
28+
if (!isDebugRun) {
29+
console.log(...args);
30+
}
31+
}
32+
2733
// so tests don't timeout when a breakpoint is hit
2834
const timeout = isDebugRun ? Number.MAX_SAFE_INTEGER : 3000;
2935

@@ -55,24 +61,24 @@ if (vsixPath) {
5561
if (!path.isAbsolute(vsixPath)) {
5662
vsixPath = path.join(__dirname, vsixPath);
5763
}
58-
console.log("Installing VSIX " + vsixPath);
64+
log("Installing VSIX " + vsixPath);
5965
installExtensions.push(vsixPath);
6066

6167
// Determine version to use
6268
const match = /swift-vscode-(\d+.\d+.\d+(-dev)?)(-\d+)?.vsix/g.exec(path.basename(vsixPath));
6369
if (match) {
6470
versionStr = match[1];
6571
}
66-
console.log("Running tests against extension version " + versionStr);
72+
log("Running tests against extension version " + versionStr);
6773

6874
extensionDevelopmentPath = `${__dirname}/.vscode-test/extensions/${publisher}.${name}-${versionStr}`;
69-
console.log("Running tests against extension development path " + extensionDevelopmentPath);
75+
log("Running tests against extension development path " + extensionDevelopmentPath);
7076
} else {
7177
extensionDependencies.push("vadimcn.vscode-lldb", "llvm-vs-code-extensions.lldb-dap");
7278
}
7379

7480
const vscodeVersion = process.env["VSCODE_VERSION"] ?? "stable";
75-
console.log("Running tests against VS Code version " + vscodeVersion);
81+
log("Running tests against VS Code version " + vscodeVersion);
7682

7783
const installConfigs = [];
7884
for (const ext of installExtensions) {
@@ -91,7 +97,7 @@ const env = {
9197
...process.env,
9298
RUNNING_UNDER_VSCODE_TEST_CLI: "1",
9399
};
94-
console.log("Running tests against environment:\n" + JSON.stringify(env, undefined, 2));
100+
log("Running tests against environment:\n" + JSON.stringify(env, undefined, 2));
95101

96102
module.exports = defineConfig({
97103
tests: [

0 commit comments

Comments
 (0)