This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
/
test
106 lines (84 loc) · 3.47 KB
/
test
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env node
const path = require('path');
const cp = require('child_process');
const fs = require('fs');
const downloadAndUnzipVSCode = require('vscode-test').downloadAndUnzipVSCode;
const version = process.env.CODE_VERSION || '*';
const isInsiders = version === 'insiders';
const testRunFolder = path.join('.vscode-test', isInsiders ? 'insiders' : 'stable');
const testRunFolderAbsolute = path.join(process.cwd(), testRunFolder);
let windowsExecutable;
let darwinExecutable;
let linuxExecutable;
if (isInsiders) {
windowsExecutable = path.join(testRunFolderAbsolute, 'Code - Insiders.exe');
darwinExecutable = path.join(testRunFolderAbsolute, 'Visual Studio Code - Insiders.app', 'Contents', 'MacOS', 'Electron');
linuxExecutable = path.join(testRunFolderAbsolute, 'VSCode-linux-x64', 'code-insiders');
} else {
windowsExecutable = path.join(testRunFolderAbsolute, 'Code.exe');
darwinExecutable = path.join(testRunFolderAbsolute, 'Visual Studio Code.app', 'Contents', 'MacOS', 'Electron');
linuxExecutable = path.join(testRunFolderAbsolute, 'VSCode-linux-x64', 'code');
if (['0.10.1', '0.10.2', '0.10.3', '0.10.4', '0.10.5', '0.10.6', '0.10.7', '0.10.8', '0.10.9'].indexOf(version) >= 0) {
linuxExecutable = path.join(testRunFolderAbsolute, 'VSCode-linux-x64', 'Code');
}
}
var testsFolder;
if (process.env.CODE_TESTS_PATH) {
testsFolder = process.env.CODE_TESTS_PATH;
} else if (fs.existsSync(path.join(process.cwd(), 'out', 'test'))) {
testsFolder = path.join(process.cwd(), 'out', 'test'); // TS extension
} else {
testsFolder = path.join(process.cwd(), 'test'); // JS extension
}
var testsWorkspace = process.env.CODE_TESTS_WORKSPACE || testsFolder;
var extensionsFolder = process.env.CODE_EXTENSIONS_PATH || process.cwd();
var locale = process.env.CODE_LOCALE || 'en';
var userDataDir = process.env.CODE_TESTS_DATA_DIR;
var executable = (process.platform === 'darwin') ? darwinExecutable : process.platform === 'win32' ? windowsExecutable : linuxExecutable;
console.log('### VS Code Extension Test Run ###');
console.log('Current working directory: ' + process.cwd());
function runTests() {
var args = [
testsWorkspace,
'--extensionDevelopmentPath=' + extensionsFolder,
'--extensionTestsPath=' + testsFolder,
'--locale=' + locale,
];
if (userDataDir) {
args.push('--user-data-dir=' + userDataDir);
}
if (process.env.CODE_DISABLE_EXTENSIONS) {
args.push('--disable-extensions');
}
console.log('Running extension tests: ' + [executable, args.join(' ')].join(' '));
var cmd = cp.spawn(executable, 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
}
});
}
function downloadExecutableAndRunTests() {
console.log('Downloading VS Code into "' + testRunFolderAbsolute);
downloadAndUnzipVSCode().then(executablePath => {
executable = executablePath
runTests()
})
}
fs.exists(executable, function (exists) {
if (exists) {
runTests();
} else {
downloadExecutableAndRunTests();
}
});