Split runner selection from test selection (#19729)

* Split runner selection from test selection

* Continue to support old behavior
This commit is contained in:
Wesley Wigham 2017-11-06 11:24:17 -08:00 committed by GitHub
parent c4bf21b9cb
commit c016f5b9b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 13 deletions

View File

@ -50,6 +50,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
d: "debug", "debug-brk": "debug",
i: "inspect", "inspect-brk": "inspect",
t: "tests", test: "tests",
ru: "runners", runner: "runners",
r: "reporter",
c: "colors", color: "colors",
f: "files", file: "files",
@ -64,6 +65,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
browser: process.env.browser || process.env.b || "IE",
timeout: process.env.timeout || 40000,
tests: process.env.test || process.env.tests || process.env.t,
runners: process.env.runners || process.env.runner || process.env.ru,
light: process.env.light === undefined || process.env.light !== "false",
reporter: process.env.reporter || process.env.r,
lint: process.env.lint || true,
@ -648,6 +650,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
const debug = cmdLineOptions.debug;
const inspect = cmdLineOptions.inspect;
const tests = cmdLineOptions.tests;
const runners = cmdLineOptions.runners;
const light = cmdLineOptions.light;
const stackTraceLimit = cmdLineOptions.stackTraceLimit;
const testConfigFile = "test.config";
@ -668,8 +671,8 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
workerCount = cmdLineOptions.workers;
}
if (tests || light || taskConfigsFolder) {
writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit);
if (tests || runners || light || taskConfigsFolder) {
writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit);
}
if (tests && tests.toLocaleLowerCase() === "rwc") {
@ -860,8 +863,8 @@ function cleanTestDirs(done: (e?: any) => void) {
}
// used to pass data from jake command line directly to run.js
function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?: string, workerCount?: number, stackTraceLimit?: string) {
const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder, noColor: !cmdLineOptions.colors });
function writeTestConfigFile(tests: string, runners: string, light: boolean, taskConfigsFolder?: string, workerCount?: number, stackTraceLimit?: string) {
const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, runner: runners ? runners.split(",") : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder, noColor: !cmdLineOptions.colors });
console.log("Running tests with config: " + testConfigContents);
fs.writeFileSync("test.config", testConfigContents);
}
@ -872,13 +875,14 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
if (err) { console.error(err); done(err); process.exit(1); }
host = "node";
const tests = cmdLineOptions.tests;
const runners = cmdLineOptions.runners;
const light = cmdLineOptions.light;
const testConfigFile = "test.config";
if (fs.existsSync(testConfigFile)) {
fs.unlinkSync(testConfigFile);
}
if (tests || light) {
writeTestConfigFile(tests, light);
if (tests || runners || light) {
writeTestConfigFile(tests, runners, light);
}
const args = [nodeServerOutFile];

View File

@ -844,8 +844,9 @@ function cleanTestDirs() {
}
// used to pass data from jake command line directly to run.js
function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit, colors) {
function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, colors) {
var testConfigContents = JSON.stringify({
runners: runners ? runners.split(",") : undefined,
test: tests ? [tests] : undefined,
light: light,
workerCount: workerCount,
@ -871,6 +872,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
var debug = process.env.debug || process.env["debug-brk"] || process.env.d;
var inspect = process.env.inspect || process.env["inspect-brk"] || process.env.i;
var testTimeout = process.env.timeout || defaultTestTimeout;
var runners = process.env.runners || process.env.runner || process.env.ru;
var tests = process.env.test || process.env.tests || process.env.t;
var light = process.env.light === undefined || process.env.light !== "false";
var stackTraceLimit = process.env.stackTraceLimit;
@ -892,8 +894,8 @@ function runConsoleTests(defaultReporter, runInParallel) {
workerCount = process.env.workerCount || process.env.p || os.cpus().length;
}
if (tests || light || taskConfigsFolder) {
writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit, colors);
if (tests || runners || light || taskConfigsFolder) {
writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, colors);
}
if (tests && tests.toLocaleLowerCase() === "rwc") {
@ -1028,14 +1030,15 @@ task("runtests-browser", ["browserify", nodeServerOutFile], function () {
cleanTestDirs();
host = "node";
var browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE");
var runners = process.env.runners || process.env.runner || process.env.ru;
var tests = process.env.test || process.env.tests || process.env.t;
var light = process.env.light || false;
var testConfigFile = 'test.config';
if (fs.existsSync(testConfigFile)) {
fs.unlinkSync(testConfigFile);
}
if (tests || light) {
writeTestConfigFile(tests, light);
if (tests || runners || light) {
writeTestConfigFile(tests, runners, light);
}
tests = tests ? tests : '';

View File

@ -95,6 +95,7 @@ interface TestConfig {
workerCount?: number;
stackTraceLimit?: number | "full";
test?: string[];
runners?: string[];
runUnitTests?: boolean;
noColors?: boolean;
}
@ -132,8 +133,9 @@ function handleTestConfig() {
return true;
}
if (testConfig.test && testConfig.test.length > 0) {
for (const option of testConfig.test) {
const runnerConfig = testConfig.runners || testConfig.test;
if (runnerConfig && runnerConfig.length > 0) {
for (const option of runnerConfig) {
if (!option) {
continue;
}