Skip to content

Commit

Permalink
Bug 1535484 - Use mozlog for node debugger linting test. r=jdescottes
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D28491

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Jason Laster committed Apr 23, 2019
1 parent a547906 commit 1d349df
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 4 deletions.
129 changes: 129 additions & 0 deletions devtools/client/debugger/bin/try-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */

/*
* A small test runner/reporter for node-based tests,
* which are run via taskcluster node(debugger).
*/

const { execFileSync } = require("child_process");
const { chdir } = require("process");
const path = require("path");
const flow = require("flow-bin");

const dbgPath = path.join(__dirname, "..");

function execOut(...args) {
let out;
let err;
try {
out = execFileSync(...args);
} catch (e) {
out = e.stdout;
err = e.stderr;
}
return { out: out.toString(), err: err && err.toString() };
}

function logErrors(text, regexp) {
const errors = text.match(regexp) || [];
for (const error of errors) {
console.log(`TEST-UNEXPECTED-FAIL | ${error}`);
}
return errors;
}

function logStart(name) {
console.log(`TEST START | ${name}`);
}

function runFlowJson() {
const { out } = execOut(flow, ["check", "--json"]);
const results = JSON.parse(out);

if (!results.passed) {
for (const error of results.errors) {
for (const message of error.message) {
console.log(`TEST-UNEXPECTED-FAIL | ${message.descr}`);
}
}
}

return results.passed;
}

function runFlow() {
logStart("Flow");
const { out } = execOut(flow, ["check"]);
console.log(out);
return runFlowJson();
}

function eslint() {
logStart("Eslint");
const { out } = execOut("yarn", ["lint:js"]);
console.log(out);
const errors = logErrors(out, / {2}error {2}(.*)/g);
return errors.length == 0;
}

function jest() {
logStart("Jest");
const { out, err } = execOut("yarn", ["test"]);
console.log(err);
const errors = logErrors(err || "", / {4}✕(.*)/g);
return errors.length == 0;
}

function stylelint() {
logStart("Stylelint");
const { out } = execOut("yarn", ["lint:css"]);
console.log(out);
const errors = logErrors(out, / {2}✖(.*)/g);
return errors.length == 0;
}

function jsxAccessibility() {
logStart("Eslint (JSX Accessibility)");

const { out } = execOut("yarn", ["lint:jsx-a11y"]);
console.log(out);
const errors = logErrors(out, / {2}error {2}(.*)/g);
return errors.length == 0;
}

function lintMd() {
logStart("Remark");

const { out, err } = execOut("yarn", ["lint:md"]);
const errors = logErrors(err || "", /warning(.+)/g);
return errors.length == 0;
}

chdir(dbgPath);
const flowPassed = runFlow();
const eslintPassed = eslint();
const jestPassed = jest();
const styleLintPassed = stylelint();
const jsxAccessibilityPassed = jsxAccessibility();
const remarkPassed = lintMd();

const success =
flowPassed &&
eslintPassed &&
jestPassed &&
styleLintPassed &&
jsxAccessibilityPassed &&
remarkPassed;

console.log({
flowPassed,
eslintPassed,
jestPassed,
styleLintPassed,
jsxAccessibilityPassed,
remarkPassed
});

process.exitCode = success ? 0 : 1;
6 changes: 2 additions & 4 deletions taskcluster/ci/source-test/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ debugger-tests:
treeherder:
symbol: node(debugger)
kind: test
tier: 3
tier: 1
worker-type: aws-provisioner-v1/gecko-t-linux-xlarge
worker:
docker-image: {in-tree: "lint"}
Expand All @@ -17,9 +17,7 @@ debugger-tests:
npm install &&
cd /builds/worker/checkouts/gecko/devtools/client/debugger/ &&
yarn &&
yarn flow &&
yarn test &&
yarn lint
node bin/try-runner.js
when:
files-changed:
- 'devtools/client/debugger/**'
Expand Down

0 comments on commit 1d349df

Please sign in to comment.