Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/sanity/src/index.ts
5240 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import fs from 'fs';
7
import minimist from 'minimist';
8
import Mocha, { MochaOptions } from 'mocha';
9
import path from 'path';
10
import { fileURLToPath } from 'url';
11
12
const options = minimist(process.argv.slice(2), {
13
string: ['fgrep', 'grep', 'test-results', 'timeout'],
14
boolean: ['help'],
15
alias: { fgrep: 'f', grep: 'g', help: 'h', 'test-results': 't' },
16
});
17
18
if (options.help) {
19
console.info(`Usage: node ${path.basename(process.argv[1])} [options]`);
20
console.info('Options:');
21
console.info(' --commit, -c <commit> The commit to test (required)');
22
console.info(` --quality, -q <quality> The quality to test (required, "stable", "insider" or "exploration")`);
23
console.info(' --no-cleanup Do not cleanup downloaded files after each test');
24
console.info(' --no-signing-check Skip Authenticode and codesign signature checks');
25
console.info(' --no-headless Run tests with a visible UI (desktop tests only)');
26
console.info(' --no-detection Enable all tests regardless of platform and skip executable runs');
27
console.info(' --grep, -g <pattern> Only run tests matching the given <pattern>');
28
console.info(' --fgrep, -f <string> Only run tests containing the given <string>');
29
console.info(' --test-results, -t <path> Output test results in JUnit format to the specified path');
30
console.info(' --timeout <sec> Set the test-case timeout in seconds (default: 600 seconds)');
31
console.info(' --verbose, -v Enable verbose logging');
32
console.info(' --help, -h Show this help message');
33
process.exit(0);
34
}
35
36
const testResults = options['test-results'];
37
const mochaOptions: MochaOptions = {
38
color: true,
39
timeout: (options.timeout ?? 10 * 60) * 1000,
40
slow: 3 * 60 * 1000,
41
grep: options.grep,
42
fgrep: options.fgrep,
43
reporter: testResults ? 'mocha-junit-reporter' : undefined,
44
reporterOptions: testResults ? { mochaFile: testResults, outputs: true } : undefined,
45
};
46
47
if (testResults) {
48
fs.mkdirSync(path.dirname(testResults), { recursive: true });
49
}
50
51
const mocha = new Mocha(mochaOptions);
52
mocha.addFile(fileURLToPath(new URL('./main.js', import.meta.url)));
53
await mocha.loadFilesAsync();
54
mocha.run(failures => {
55
process.exitCode = failures > 0 ? 1 : 0;
56
// Force exit to prevent hanging on open handles (background processes, timers, etc.)
57
setTimeout(() => process.exit(process.exitCode), 1000);
58
});
59
60