Skip to content

Commit

Permalink
Bug 1820103 - [devtools] Make it possible for devtools-node-test-runn…
Browse files Browse the repository at this point in the history
…er.js to run all suites. r=jdescottes.

Differential Revision: https://phabricator.services.mozilla.com/D171533
  • Loading branch information
nchevobbe committed Mar 6, 2023
1 parent 2ea5182 commit 1ed3828
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 42 deletions.
81 changes: 49 additions & 32 deletions devtools/client/bin/devtools-node-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,12 @@ function runTests() {
console.log("[devtools-node-test-runner] Extract suite argument");
const suiteArg = process.argv.find(arg => arg.includes("suite="));
const suite = suiteArg.split("=")[1];
if (!SUITES[suite]) {
if (suite !== "all" && !SUITES[suite]) {
throw new Error(
"Invalid suite argument to devtools-node-test-runner: " + suite
);
}

console.log("[devtools-node-test-runner] Found test suite: " + suite);

console.log("[devtools-node-test-runner] Check `yarn` is available");
try {
// This will throw if yarn is unavailable
Expand All @@ -147,46 +145,65 @@ function runTests() {
return false;
}

if (SUITES[suite].dependencies) {
console.log("[devtools-node-test-runner] Running `yarn` for dependencies");
for (const dep of SUITES[suite].dependencies) {
const depPath = path.join(__dirname, dep);
chdir(depPath);

console.log("[devtools-node-test-runner] Run `yarn` in " + depPath);
execOut(YARN_PROCESS);
const failedSuites = [];
const suites = suite == "all" ? SUITES : { [suite]: SUITES[suite] };
for (const [suiteName, suiteData] of Object.entries(suites)) {
console.log("[devtools-node-test-runner] Running suite: " + suiteName);

if (suiteData.dependencies) {
console.log(
"[devtools-node-test-runner] Running `yarn` for dependencies"
);
for (const dep of suiteData.dependencies) {
const depPath = path.join(__dirname, dep);
chdir(depPath);

console.log("[devtools-node-test-runner] Run `yarn` in " + depPath);
execOut(YARN_PROCESS);
}
}
}

const testPath = path.join(__dirname, SUITES[suite].path);
chdir(testPath);
const testPath = path.join(__dirname, suiteData.path);
chdir(testPath);

console.log("[devtools-node-test-runner] Run `yarn` in test folder");
execOut(YARN_PROCESS);
console.log("[devtools-node-test-runner] Run `yarn` in test folder");
execOut(YARN_PROCESS);

console.log(`TEST START | ${SUITES[suite].type} | ${suite}`);
console.log(`TEST START | ${suiteData.type} | ${suiteName}`);

console.log("[devtools-node-test-runner] Run `yarn test` in test folder");
const { out, err } = execOut(YARN_PROCESS, ["test-ci"]);
console.log("[devtools-node-test-runner] Run `yarn test` in test folder");
const { out, err } = execOut(YARN_PROCESS, ["test-ci"]);

if (err) {
console.log("[devtools-node-test-runner] Error log");
console.log(err);
}
if (err) {
console.log("[devtools-node-test-runner] Error log");
console.log(err);
}

console.log("[devtools-node-test-runner] Parse errors from the test logs");
const errors = getErrors(suite, out, err) || [];
for (const error of errors) {
console.log(
`TEST-UNEXPECTED-FAIL | ${SUITES[suite].type} | ${suite} | ${error}`
);
console.log("[devtools-node-test-runner] Parse errors from the test logs");
const errors = getErrors(suiteName, out, err) || [];
if (errors.length) {
failedSuites.push(suiteName);
}
for (const error of errors) {
console.log(
`TEST-UNEXPECTED-FAIL | ${suiteData.type} | ${suiteName} | ${error}`
);
}
}

const success = errors.length === 0;
const success = failedSuites.length === 0;
if (success) {
console.log(`[devtools-node-test-runner] Test suite [${suite}] succeeded`);
console.log(
`[devtools-node-test-runner] Test suites [${Object.keys(suites).join(
", "
)}] succeeded`
);
} else {
console.log(`[devtools-node-test-runner] Test suite [${suite}] failed`);
console.log(
`[devtools-node-test-runner] Test suites [${failedSuites.join(
", "
)}] failed`
);
console.log(
"[devtools-node-test-runner] You can find documentation about the " +
"devtools node tests at https://firefox-source-docs.mozilla.org/devtools/tests/node-tests.html"
Expand Down
11 changes: 1 addition & 10 deletions taskcluster/ci/source-test/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,7 @@ devtools-tests:
ln -s ../tools/lint/eslint/eslint-plugin-mozilla node_modules &&
ln -s ../tools/lint/eslint/eslint-plugin-spidermonkey-js node_modules &&
cd devtools/client/bin/ &&
node devtools-node-test-runner.js --suite=aboutdebugging &&
node devtools-node-test-runner.js --suite=accessibility &&
node devtools-node-test-runner.js --suite=application &&
node devtools-node-test-runner.js --suite=debugger &&
node devtools-node-test-runner.js --suite=compatibility &&
node devtools-node-test-runner.js --suite=framework &&
node devtools-node-test-runner.js --suite=netmonitor &&
node devtools-node-test-runner.js --suite=performance &&
node devtools-node-test-runner.js --suite=shared_components &&
node devtools-node-test-runner.js --suite=webconsole
node devtools-node-test-runner.js --suite=all
when:
files-changed:
- 'devtools/client/**'
Expand Down

0 comments on commit 1ed3828

Please sign in to comment.