Skip to content

Commit

Permalink
Add an option to gulp makeref/browsertest to only run tests with spec…
Browse files Browse the repository at this point in the history
…ific ids

It can be used like this: `gulp makeref -t tracemonkey-eq` or `gulp browsertest --testfilter tracemonkey-text`.
  • Loading branch information
calixteman committed Oct 2, 2024
1 parent 0308b80 commit 45af322
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,13 @@ function runTests(testsName, { bot = false, xfaOnly = false } = {}) {
args.push("--xfaOnly");
}
args.push("--manifestFile=" + PDF_TEST);
collectArgs(
{
names: ["-t", "--testfilter"],
hasValue: true,
},
args
);
break;
case "unit":
args.push("--unitTest");
Expand Down Expand Up @@ -724,6 +731,30 @@ function runTests(testsName, { bot = false, xfaOnly = false } = {}) {
});
}

function collectArgs(options, args) {
if (!Array.isArray(options)) {
options = [options];
}
for (let i = 0, ii = process.argv.length; i < ii; i++) {
const arg = process.argv[i];
const option = options.find(
opt => opt.name === arg || opt.names.includes(arg)
);
if (!option) {
continue;
}
if (!option.hasValue) {
args.push(arg);
continue;
}
const next = process.argv[i + 1];
if (next && !next.startsWith("-")) {
args.push(arg, next);
i += 1;
}
}
}

function makeRef(done, bot) {
console.log();
console.log("### Creating reference images");
Expand All @@ -748,6 +779,13 @@ function makeRef(done, bot) {
if (process.argv.includes("--headless")) {
args.push("--headless");
}
collectArgs(
{
names: ["-t", "--testfilter"],
hasValue: true,
},
args
);

const testProcess = startNode(args, { cwd: TEST_DIR, stdio: "inherit" });
testProcess.on("close", function (code) {
Expand Down

0 comments on commit 45af322

Please sign in to comment.