Skip to content

Commit fbd1c95

Browse files
authored
Update failed test tracking to support Mocha 6+ (#39211)
* Update failed test tracking to support Mocha 6+ * grep should not be an array
1 parent 964e474 commit fbd1c95

File tree

2 files changed

+16
-98
lines changed

2 files changed

+16
-98
lines changed

scripts/build/tests.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,23 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
7777
// timeout normally isn"t necessary but Travis-CI has been timing out on compiler baselines occasionally
7878
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
7979
if (!runInParallel) {
80-
args.push(failed ? "scripts/run-failed-tests.js" : mochaJs);
80+
args.push(mochaJs);
8181
args.push("-R", "scripts/failed-tests");
8282
args.push("-O", '"reporter=' + reporter + (keepFailed ? ",keepFailed=true" : "") + '"');
8383
if (tests) {
8484
args.push("-g", `"${tests}"`);
8585
}
86+
if (failed) {
87+
const grep = fs.readFileSync(".failed-tests", "utf8")
88+
.split(/\r?\n/g)
89+
.map(test => test.trim())
90+
.filter(test => test.length > 0)
91+
.map(regExpEscape)
92+
.join("|");
93+
const file = path.join(os.tmpdir(), ".failed-tests.json");
94+
fs.writeFileSync(file, JSON.stringify({ grep }), "utf8");
95+
args.push("--config", file);
96+
}
8697
if (colors) {
8798
args.push("--colors");
8899
}
@@ -203,3 +214,7 @@ function restoreSavedNodeEnv() {
203214
function deleteTemporaryProjectOutput() {
204215
return del(path.join(exports.localBaseline, "projectOutput/"));
205216
}
217+
218+
function regExpEscape(text) {
219+
return text.replace(/[.*+?^${}()|\[\]\\]/g, '\\$&');
220+
}

scripts/run-failed-tests.js

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)