-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtestExtension.js
More file actions
60 lines (48 loc) · 1.46 KB
/
testExtension.js
File metadata and controls
60 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const path = require("path");
const cp = require("child_process");
const fs = require("fs");
const ROOT = __dirname;
const downloadAndUnzipVSCode = require("@vscode/test-electron").downloadAndUnzipVSCode;
const testsWorkspace = path.resolve(ROOT, "testdata");
const testsFolder = path.resolve(ROOT, "out", "test", "extension");
const extensionsFolder = ROOT;
function runTests(executablePath) {
const args = [
testsWorkspace,
"--no-sandbox",
"--extensionDevelopmentPath=" + extensionsFolder,
"--extensionTestsPath=" + testsFolder,
"--locale=en",
"--disable-extensions"
];
console.log(
"Running extension tests: " + [executablePath, args.join(" ")].join(" ")
);
const cmd = cp.spawn(executablePath, args);
cmd.stdout.on("data", function(data) {
console.log(data.toString());
});
cmd.stderr.on("data", function(data) {
console.error(data.toString());
});
cmd.on("error", function(data) {
console.log("Failed to execute tests: " + data.toString());
});
cmd.on("close", function(code) {
console.log("Tests exited with code: " + code);
if (code !== 0) {
process.exit(code); // propagate exit code to outer runner
}
});
}
async function downloadExecutableAndRunTests() {
try {
const exePath = await downloadAndUnzipVSCode();
runTests(exePath);
} catch (err) {
console.error("Failed to run test with error:");
console.log(err);
process.exit(1);
}
}
downloadExecutableAndRunTests();