Skip to content

Commit a9aa6bc

Browse files
authored
Use @vscode/test-cli to run tests (#949)
Migrates to the new @vscode/test-cli package to download the appropriate VS Code and run the tests. This streamlines the test setup code, and should be a more reliable way to run the tests as VS Code evolves. Hopefully this also helps with the occasional SIGSEGV errors that happen in CI on startup.
1 parent 7745a19 commit a9aa6bc

File tree

7 files changed

+503
-197
lines changed

7 files changed

+503
-197
lines changed

.c8rc

Lines changed: 0 additions & 14 deletions
This file was deleted.

.vscode-test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the VS Code Swift open source project
4+
//
5+
// Copyright (c) 2024 the VS Code Swift project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
const { defineConfig } = require("@vscode/test-cli");
16+
17+
const isCIBuild = process.env["CI"] === "1";
18+
const isFastTestRun = process.env["FAST_TEST_RUN"] === "1";
19+
20+
// "env" in launch.json doesn't seem to work with vscode-test
21+
const isDebugRun = !(process.env["_"] ?? "").endsWith("node_modules/.bin/vscode-test");
22+
23+
// so tests don't timeout when a breakpoint is hit
24+
const timeout = isDebugRun ? Number.MAX_SAFE_INTEGER : 3000
25+
26+
module.exports = defineConfig({
27+
tests: [
28+
{
29+
label: "integrationTests",
30+
files: ["out/test/suite/**/*.test.js"],
31+
version: "stable",
32+
workspaceFolder: "./assets/test",
33+
mocha: {
34+
ui: "tdd",
35+
color: true,
36+
timeout,
37+
forbidOnly: isCIBuild,
38+
grep: isFastTestRun ? "@slow" : undefined,
39+
invert: isFastTestRun,
40+
},
41+
installExtensions: ["vadimcn.vscode-lldb"],
42+
reuseMachineInstall: !isCIBuild,
43+
},
44+
// you can specify additional test configurations, too
45+
],
46+
coverage: {
47+
include: ["**/src/**"],
48+
reporter: ["text", "html"],
49+
},
50+
});

.vscode/launch.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@
2424
"name": "Extension Tests",
2525
"type": "extensionHost",
2626
"request": "launch",
27+
"testConfiguration": "${workspaceFolder}/.vscode-test.js",
28+
"testConfigurationLabel": "integrationTests",
2729
"args": [
2830
"--profile=testing-debug",
29-
"--extensionDevelopmentPath=${workspaceFolder}",
30-
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index",
3131
"${workspaceFolder}/assets/test"
3232
],
3333
"outFiles": [
3434
"${workspaceFolder}/out/**/*.js"
3535
],
36+
"env": {
37+
"VSCODE_DEBUG": "1"
38+
},
3639
"preLaunchTask": "compile-tests"
3740
}
3841
]

0 commit comments

Comments
 (0)