This commit is contained in:
Pine Wu 2019-12-11 11:04:53 -08:00
Родитель 62ac48f2bb
Коммит c5904348e1
6 изменённых файлов: 34 добавлений и 39 удалений

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

@ -2,7 +2,7 @@ import * as rimraf from 'rimraf';
export function rmdir(dir: string) {
return new Promise((c, e) => {
rimraf(dir, (err) => {
rimraf(dir, err => {
if (err) {
return e(err);
}
@ -10,4 +10,4 @@ export function rmdir(dir: string) {
c();
});
});
}
}

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

@ -113,19 +113,19 @@ async function innerRunTests(
const fullEnv = Object.assign({}, process.env, testRunnerEnv);
const cmd = cp.spawn(executable, args, { env: fullEnv });
cmd.stdout.on('data', function (data) {
cmd.stdout.on('data', function(data) {
console.log(data.toString());
});
cmd.stderr.on('data', function (data) {
cmd.stderr.on('data', function(data) {
console.error(data.toString());
});
cmd.on('error', function (data) {
cmd.on('error', function(data) {
console.log('Test error: ' + data.toString());
});
cmd.on('close', function (code) {
cmd.on('close', function(code) {
console.log(`Exit code: ${code}`);
if (code !== 0) {

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

@ -5,7 +5,6 @@ import * as vscode from 'vscode';
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "vscode-test-ext" is now active!');

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

@ -1,12 +1,12 @@
import * as path from 'path'
import * as cp from 'child_process'
import * as path from 'path';
import * as cp from 'child_process';
import { runTests, downloadAndUnzipVSCode, resolveCliPathFromVSCodeExecutablePath } from '../../lib/index'
import { runTests, downloadAndUnzipVSCode, resolveCliPathFromVSCodeExecutablePath } from '../../lib/index';
async function go() {
try {
const extensionDevelopmentPath = path.resolve(__dirname, '../../../')
const extensionTestsPath = path.resolve(__dirname, './suite')
const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
const extensionTestsPath = path.resolve(__dirname, './suite');
/**
* Basic usage
@ -14,10 +14,10 @@ async function go() {
await runTests({
extensionDevelopmentPath,
extensionTestsPath
})
});
const extensionTestsPath2 = path.resolve(__dirname, './suite2')
const testWorkspace = path.resolve(__dirname, '../../../test-fixtures/fixture1')
const extensionTestsPath2 = path.resolve(__dirname, './suite2');
const testWorkspace = path.resolve(__dirname, '../../../test-fixtures/fixture1');
/**
* Running another test suite on a specific workspace
@ -26,7 +26,7 @@ async function go() {
extensionDevelopmentPath,
extensionTestsPath: extensionTestsPath2,
launchArgs: [testWorkspace]
})
});
/**
* Use 1.36.1 release for testing
@ -36,7 +36,7 @@ async function go() {
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [testWorkspace]
})
});
/**
* Use Insiders release for testing
@ -46,32 +46,32 @@ async function go() {
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [testWorkspace]
})
});
/**
* Noop, since 1.36.1 already downloaded to .vscode-test/vscode-1.36.1
*/
await downloadAndUnzipVSCode('1.36.1')
await downloadAndUnzipVSCode('1.36.1');
/**
* Manually download VS Code 1.35.0 release for testing.
*/
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.35.0')
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.35.0');
await runTests({
vscodeExecutablePath,
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [testWorkspace]
})
});
/**
* Install Python extension
*/
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath)
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath);
cp.spawnSync(cliPath, ['--install-extension', 'ms-python.python'], {
encoding: 'utf-8',
stdio: 'inherit'
})
});
/**
* - Add additional launch flags for VS Code
@ -88,11 +88,11 @@ async function go() {
],
// Custom environment variables for extension test script
extensionTestsEnv: { foo: 'bar' }
})
});
} catch (err) {
console.error('Failed to run tests')
process.exit(1)
console.error('Failed to run tests');
process.exit(1);
}
}
go()
go();

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

@ -5,7 +5,7 @@ import * as glob from 'glob';
export function run(testsRoot: string, cb: (error: any, failures?: number) => void): void {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
ui: 'tdd'
});
mocha.useColors(true);
@ -19,11 +19,9 @@ export function run(testsRoot: string, cb: (error: any, failures?: number) => vo
try {
// Run the mocha test
mocha
.run(failures => {
cb(null, failures);
});
mocha.run(failures => {
cb(null, failures);
});
} catch (err) {
cb(err);
}

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

@ -5,7 +5,7 @@ import * as glob from 'glob';
export function run(testsRoot: string, cb: (error: any, failures?: number) => void): void {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
ui: 'tdd'
});
mocha.useColors(true);
@ -19,11 +19,9 @@ export function run(testsRoot: string, cb: (error: any, failures?: number) => vo
try {
// Run the mocha test
mocha
.run(failures => {
cb(null, failures);
});
mocha.run(failures => {
cb(null, failures);
});
} catch (err) {
cb(err);
}