This commit is contained in:
Pine Wu 2019-03-21 13:39:50 -07:00
Родитель 26a677505d
Коммит df9c929da3
1 изменённых файлов: 11 добавлений и 41 удалений

Просмотреть файл

@ -6,29 +6,6 @@ const fs = require('fs');
const downloadAndUnzipVSCode = require('vscode-test').downloadAndUnzipVSCode;
const version = process.env.CODE_VERSION || '<latest>';
const isInsiders = version === 'insiders';
const testRunFolder = path.join('.vscode-test', isInsiders ? 'vscode-insiders' : `vscode-${version}`);
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;
@ -42,12 +19,12 @@ 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('');
console.log('Current working directory: ' + process.cwd());
function runTests() {
function runTests(executablePath) {
var args = [
testsWorkspace,
'--extensionDevelopmentPath=' + extensionsFolder,
@ -63,9 +40,9 @@ function runTests() {
args.push('--disable-extensions');
}
console.log('Running extension tests: ' + [executable, args.join(' ')].join(' '));
console.log('Running extension tests: ' + [executablePath, args.join(' ')].join(' '));
var cmd = cp.spawn(executable, args);
var cmd = cp.spawn(executablePath, args);
cmd.stdout.on('data', function (data) {
console.log(data.toString());
@ -89,20 +66,13 @@ function runTests() {
}
function downloadExecutableAndRunTests() {
console.log('Downloading VS Code into "' + testRunFolderAbsolute);
var targetVersion = (version === '<latest>') ? undefined : version;
downloadAndUnzipVSCode(targetVersion).then(executablePath => {
executable = executablePath
runTests()
downloadAndUnzipVSCode(process.env.CODE_VERSION).then(executablePath => {
runTests(executablePath)
}).catch(err => {
console.error('Failed to run test with error:')
console.log(err);
process.exit(1);
})
}
fs.exists(executable, function (exists) {
if (exists) {
runTests();
} else {
downloadExecutableAndRunTests();
}
});
downloadExecutableAndRunTests()