Skip to content

Commit c016f5b

Browse files
authored
Split runner selection from test selection (microsoft#19729)
* Split runner selection from test selection * Continue to support old behavior
1 parent c4bf21b commit c016f5b

3 files changed

Lines changed: 22 additions & 13 deletions

File tree

Gulpfile.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
5050
d: "debug", "debug-brk": "debug",
5151
i: "inspect", "inspect-brk": "inspect",
5252
t: "tests", test: "tests",
53+
ru: "runners", runner: "runners",
5354
r: "reporter",
5455
c: "colors", color: "colors",
5556
f: "files", file: "files",
@@ -64,6 +65,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
6465
browser: process.env.browser || process.env.b || "IE",
6566
timeout: process.env.timeout || 40000,
6667
tests: process.env.test || process.env.tests || process.env.t,
68+
runners: process.env.runners || process.env.runner || process.env.ru,
6769
light: process.env.light === undefined || process.env.light !== "false",
6870
reporter: process.env.reporter || process.env.r,
6971
lint: process.env.lint || true,
@@ -648,6 +650,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
648650
const debug = cmdLineOptions.debug;
649651
const inspect = cmdLineOptions.inspect;
650652
const tests = cmdLineOptions.tests;
653+
const runners = cmdLineOptions.runners;
651654
const light = cmdLineOptions.light;
652655
const stackTraceLimit = cmdLineOptions.stackTraceLimit;
653656
const testConfigFile = "test.config";
@@ -668,8 +671,8 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
668671
workerCount = cmdLineOptions.workers;
669672
}
670673

671-
if (tests || light || taskConfigsFolder) {
672-
writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit);
674+
if (tests || runners || light || taskConfigsFolder) {
675+
writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit);
673676
}
674677

675678
if (tests && tests.toLocaleLowerCase() === "rwc") {
@@ -860,8 +863,8 @@ function cleanTestDirs(done: (e?: any) => void) {
860863
}
861864

862865
// used to pass data from jake command line directly to run.js
863-
function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?: string, workerCount?: number, stackTraceLimit?: string) {
864-
const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder, noColor: !cmdLineOptions.colors });
866+
function writeTestConfigFile(tests: string, runners: string, light: boolean, taskConfigsFolder?: string, workerCount?: number, stackTraceLimit?: string) {
867+
const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, runner: runners ? runners.split(",") : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder, noColor: !cmdLineOptions.colors });
865868
console.log("Running tests with config: " + testConfigContents);
866869
fs.writeFileSync("test.config", testConfigContents);
867870
}
@@ -872,13 +875,14 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
872875
if (err) { console.error(err); done(err); process.exit(1); }
873876
host = "node";
874877
const tests = cmdLineOptions.tests;
878+
const runners = cmdLineOptions.runners;
875879
const light = cmdLineOptions.light;
876880
const testConfigFile = "test.config";
877881
if (fs.existsSync(testConfigFile)) {
878882
fs.unlinkSync(testConfigFile);
879883
}
880-
if (tests || light) {
881-
writeTestConfigFile(tests, light);
884+
if (tests || runners || light) {
885+
writeTestConfigFile(tests, runners, light);
882886
}
883887

884888
const args = [nodeServerOutFile];

Jakefile.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,9 @@ function cleanTestDirs() {
844844
}
845845

846846
// used to pass data from jake command line directly to run.js
847-
function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit, colors) {
847+
function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, colors) {
848848
var testConfigContents = JSON.stringify({
849+
runners: runners ? runners.split(",") : undefined,
849850
test: tests ? [tests] : undefined,
850851
light: light,
851852
workerCount: workerCount,
@@ -871,6 +872,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
871872
var debug = process.env.debug || process.env["debug-brk"] || process.env.d;
872873
var inspect = process.env.inspect || process.env["inspect-brk"] || process.env.i;
873874
var testTimeout = process.env.timeout || defaultTestTimeout;
875+
var runners = process.env.runners || process.env.runner || process.env.ru;
874876
var tests = process.env.test || process.env.tests || process.env.t;
875877
var light = process.env.light === undefined || process.env.light !== "false";
876878
var stackTraceLimit = process.env.stackTraceLimit;
@@ -892,8 +894,8 @@ function runConsoleTests(defaultReporter, runInParallel) {
892894
workerCount = process.env.workerCount || process.env.p || os.cpus().length;
893895
}
894896

895-
if (tests || light || taskConfigsFolder) {
896-
writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit, colors);
897+
if (tests || runners || light || taskConfigsFolder) {
898+
writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, colors);
897899
}
898900

899901
if (tests && tests.toLocaleLowerCase() === "rwc") {
@@ -1028,14 +1030,15 @@ task("runtests-browser", ["browserify", nodeServerOutFile], function () {
10281030
cleanTestDirs();
10291031
host = "node";
10301032
var browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE");
1033+
var runners = process.env.runners || process.env.runner || process.env.ru;
10311034
var tests = process.env.test || process.env.tests || process.env.t;
10321035
var light = process.env.light || false;
10331036
var testConfigFile = 'test.config';
10341037
if (fs.existsSync(testConfigFile)) {
10351038
fs.unlinkSync(testConfigFile);
10361039
}
1037-
if (tests || light) {
1038-
writeTestConfigFile(tests, light);
1040+
if (tests || runners || light) {
1041+
writeTestConfigFile(tests, runners, light);
10391042
}
10401043

10411044
tests = tests ? tests : '';

src/harness/runner.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ interface TestConfig {
9595
workerCount?: number;
9696
stackTraceLimit?: number | "full";
9797
test?: string[];
98+
runners?: string[];
9899
runUnitTests?: boolean;
99100
noColors?: boolean;
100101
}
@@ -132,8 +133,9 @@ function handleTestConfig() {
132133
return true;
133134
}
134135

135-
if (testConfig.test && testConfig.test.length > 0) {
136-
for (const option of testConfig.test) {
136+
const runnerConfig = testConfig.runners || testConfig.test;
137+
if (runnerConfig && runnerConfig.length > 0) {
138+
for (const option of runnerConfig) {
137139
if (!option) {
138140
continue;
139141
}

0 commit comments

Comments
 (0)