diff --git a/Gulpfile.ts b/Gulpfile.ts index 4d6dfdf2862..fd353083433 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -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]; diff --git a/Jakefile.js b/Jakefile.js index 13607f7b40f..7f0915ad7e9 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -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 : ''; diff --git a/src/harness/runner.ts b/src/harness/runner.ts index b538f90bc39..70954e9e853 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -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; }