This commit is contained in:
Pine Wu
2020-03-05 11:34:58 -08:00
parent 403f8669d8
commit 67e6aef0c8
23 changed files with 481 additions and 10625 deletions

View File

@@ -3,28 +3,68 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
const testRunner = require('vscode/lib/testrunner');
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
const suite = 'Integration Single Folder Tests';
const options: any = {
ui: 'tdd',
useColors: (!process.env.BUILD_ARTIFACTSTAGINGDIRECTORY && process.platform !== 'win32'),
timeout: 60000
};
if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) {
options.reporter = 'mocha-multi-reporters';
options.reporterOptions = {
reporterEnabled: 'spec, mocha-junit-reporter',
mochaJunitReporterReporterOptions: {
testsuitesTitle: `${suite} ${process.platform}`,
mochaFile: path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${suite.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`)
}
export function run(): Promise<void> {
// Create the mocha test
const options: {
ui?: string;
timeout?: number;
reporter?: string;
reporterOptions?: any;
} = {
ui: 'tdd',
timeout: 60000,
reporter: undefined,
reporterOptions: undefined
};
if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) {
options.reporter = 'mocha-multi-reporters';
options.reporterOptions = {
reporterEnabled: 'spec, mocha-junit-reporter',
mochaJunitReporterReporterOptions: {
testsuitesTitle: `${suite} ${process.platform}`,
mochaFile: path.join(
process.env.BUILD_ARTIFACTSTAGINGDIRECTORY,
`test-results/${process.platform}-${suite.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`
)
}
};
}
const mocha = new Mocha(options);
if (!process.env.BUILD_ARTIFACTSTAGINGDIRECTORY && process.platform !== 'win32') {
mocha.useColors(true);
}
const testsRoot = path.resolve(__dirname, '..');
return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}
// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
try {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
e(err);
}
});
});
}
testRunner.configure(options);
export = testRunner;

View File

@@ -3,28 +3,68 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
const testRunner = require('vscode/lib/testrunner');
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
const suite = 'Integration Workspace Tests';
const options: any = {
ui: 'tdd',
useColors: (!process.env.BUILD_ARTIFACTSTAGINGDIRECTORY && process.platform !== 'win32'),
timeout: 60000
};
if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) {
options.reporter = 'mocha-multi-reporters';
options.reporterOptions = {
reporterEnabled: 'spec, mocha-junit-reporter',
mochaJunitReporterReporterOptions: {
testsuitesTitle: `${suite} ${process.platform}`,
mochaFile: path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${suite.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`)
}
export function run(): Promise<void> {
// Create the mocha test
const options: {
ui?: string;
timeout?: number;
reporter?: string;
reporterOptions?: any;
} = {
ui: 'tdd',
timeout: 60000,
reporter: undefined,
reporterOptions: undefined
};
if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) {
options.reporter = 'mocha-multi-reporters';
options.reporterOptions = {
reporterEnabled: 'spec, mocha-junit-reporter',
mochaJunitReporterReporterOptions: {
testsuitesTitle: `${suite} ${process.platform}`,
mochaFile: path.join(
process.env.BUILD_ARTIFACTSTAGINGDIRECTORY,
`test-results/${process.platform}-${suite.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`
)
}
};
}
const mocha = new Mocha(options);
if (!process.env.BUILD_ARTIFACTSTAGINGDIRECTORY && process.platform !== 'win32') {
mocha.useColors(true);
}
const testsRoot = path.resolve(__dirname, '..');
return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}
// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
try {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
e(err);
}
});
});
}
testRunner.configure(options);
export = testRunner;