Skip to content

Commit d8b9ff7

Browse files
QoL improvements to our testing framework (#1816)
1 parent 0621322 commit d8b9ff7

File tree

224 files changed

+1618
-1162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+1618
-1162
lines changed

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
2+
"plugins": ["@trivago/prettier-plugin-sort-imports"],
3+
"endOfLine": "auto",
24
"trailingComma": "es5",
35
"printWidth": 100,
46
"tabWidth": 4,
57
"arrowParens": "avoid",
8+
"importOrder": ["^@src/(.*)$", "^\\.(\\.)?/(.*)$"],
9+
"importOrderSeparation": true,
10+
"importOrderSortSpecifiers": true,
11+
"importOrderSideEffects": false,
612
"overrides": [
713
{
814
"files": "*.json",

.vscode-test.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,29 @@
1111
// SPDX-License-Identifier: Apache-2.0
1212
//
1313
//===----------------------------------------------------------------------===//
14+
// @ts-check
1415

1516
const { defineConfig } = require("@vscode/test-cli");
1617
const path = require("path");
1718
const { version, publisher, name } = require("./package.json");
1819

1920
const isCIBuild = process.env["CI"] === "1";
20-
const isFastTestRun = process.env["FAST_TEST_RUN"] === "1";
2121

2222
const dataDir = process.env["VSCODE_DATA_DIR"];
2323

24-
// "env" in launch.json doesn't seem to work with vscode-test
24+
// Check if we're debugging by looking at the process executable. Unfortunately, the VS Code debugger
25+
// doesn't seem to allow setting environment variables on a launched extension host.
2526
const isDebugRun = !(process.env["_"] ?? "").endsWith("node_modules/.bin/vscode-test");
2627

27-
function log(...args) {
28+
function log(/** @type {string} */ message) {
2829
if (!isDebugRun) {
29-
console.log(...args);
30+
console.log(message);
3031
}
3132
}
3233

33-
// so tests don't timeout when a breakpoint is hit
34-
const timeout = isDebugRun ? Number.MAX_SAFE_INTEGER : 3000;
34+
// Remove the default timeout when debugging to avoid test failures when a breakpoint is hit.
35+
// Keep this up to date with the timeout of a 'small' test in 'test/tags.ts'.
36+
const timeout = isDebugRun ? 0 : 2000;
3537

3638
const launchArgs = [
3739
"--disable-updates",
@@ -96,6 +98,7 @@ for (const ext of installExtensions) {
9698
const env = {
9799
...process.env,
98100
RUNNING_UNDER_VSCODE_TEST_CLI: "1",
101+
VSCODE_DEBUG: isDebugRun ? "1" : "0",
99102
};
100103
log("Running tests against environment:\n" + JSON.stringify(env, undefined, 2));
101104

@@ -115,8 +118,6 @@ module.exports = defineConfig({
115118
color: true,
116119
timeout,
117120
forbidOnly: isCIBuild,
118-
grep: isFastTestRun ? "@slow" : undefined,
119-
invert: isFastTestRun,
120121
slow: 10000,
121122
retries: 1,
122123
reporter: path.join(__dirname, ".mocha-reporter.js"),
@@ -128,7 +129,6 @@ module.exports = defineConfig({
128129
},
129130
installExtensions: extensionDependencies,
130131
skipExtensionDependencies: installConfigs.length > 0,
131-
reuseMachineInstall: !isCIBuild,
132132
},
133133
{
134134
label: "codeWorkspaceTests",
@@ -151,8 +151,6 @@ module.exports = defineConfig({
151151
color: true,
152152
timeout,
153153
forbidOnly: isCIBuild,
154-
grep: isFastTestRun ? "@slow" : undefined,
155-
invert: isFastTestRun,
156154
slow: 10000,
157155
retries: 1,
158156
reporter: path.join(__dirname, ".mocha-reporter.js"),
@@ -164,7 +162,6 @@ module.exports = defineConfig({
164162
},
165163
installExtensions: extensionDependencies,
166164
skipExtensionDependencies: installConfigs.length > 0,
167-
reuseMachineInstall: !isCIBuild,
168165
},
169166
{
170167
label: "unitTests",
@@ -186,7 +183,6 @@ module.exports = defineConfig({
186183
},
187184
},
188185
skipExtensionDependencies: true,
189-
reuseMachineInstall: !isCIBuild,
190186
},
191187
// you can specify additional test configurations, too
192188
],

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"preLaunchTask": "Build Extension"
1818
},
1919
{
20-
"name": "Extension Tests",
20+
"name": "Integration Tests",
2121
"type": "extensionHost",
2222
"request": "launch",
2323
"testConfiguration": "${workspaceFolder}/.vscode-test.js",

0 commit comments

Comments
 (0)