Bug 1673419 - [devtools] Support performance-new typescript checks in devtools node try runner r=gregtatum,nchevobbe

This allows to run the performance-new typescript checks via
"node devtools/client/bin/devtools-node-test-runner.js --suite=performance"

Differential Revision: https://phabricator.services.mozilla.com/D95232
This commit is contained in:
Julian Descottes 2020-10-30 17:15:55 +00:00
parent 8042432b13
commit 900514e20e
3 changed files with 32 additions and 2 deletions

View File

@ -22,6 +22,7 @@ const path = require("path");
const TEST_TYPES = {
JEST: "jest",
MOCHA: "mocha",
TYPESCRIPT: "typescript",
};
const SUITES = {
@ -49,6 +50,10 @@ const SUITES = {
path: "../netmonitor/test/node",
type: TEST_TYPES.JEST,
},
performance: {
path: "../performance-new",
type: TEST_TYPES.TYPESCRIPT,
},
shared_components: {
path: "../shared/components/test/node",
type: TEST_TYPES.JEST,
@ -77,6 +82,8 @@ function getErrors(suite, out, err) {
return getJestErrors(out, err);
case TEST_TYPES.MOCHA:
return getMochaErrors(out, err);
case TEST_TYPES.TYPESCRIPT:
return getTypescriptErrors(out, err);
default:
throw new Error("Unsupported suite type: " + SUITES[suite].type);
}
@ -114,6 +121,15 @@ function getMochaErrors(out, err) {
);
}
function getTypescriptErrors(out, err) {
// Typescript error lines look like:
// popup/panel.jsm.js(103,7): error TS2531: Object is possibly 'null'.
// Which means:
// {file_path}({line},{col}): error TS{error_code}: {message}
const tsErrorRegex = /error TS\d+\:/;
return out.split("\n").filter(l => tsErrorRegex.test(l));
}
function runTests() {
console.log("[devtools-node-test-runner] Extract suite argument");
const suiteArg = process.argv.find(arg => arg.includes("suite="));

View File

@ -1,6 +1,6 @@
# TypeScript Experiment
This folder contains an experiment to add TypeScript to Gecko. The type checking is not integrated into continuous integration as of yet, and can be run manually via:
This folder contains an experiment to add TypeScript to Gecko. The type checking can be run manually via:
```
cd devtools/client/performance-new
@ -10,6 +10,15 @@ yarn test
Also, the types should work with editor integration. VS Code works with TypeScript by default, and should pick up the types here.
The type checking is also included in the DevTools node tests, which can be run manually via:
```
node devtools/client/bin/devtools-node-test-runner.js --suite=performance
```
More importantly the DevTools node tests run on Continuous Integration. They are included in the DevTools presets `devtools` and `devtools-linux`. They can also be found via `mach try fuzzy`, under the name "source-test-node-devtools-tests". To recap, the following try pushes will run the DevTools node tests:
DevTools node tests are also automatically run for any Phabricator diff which impacts DevTools. If the job fails, a bot will add a comment on the corresponding Phabricator diff.
## Do not overload require
Anytime that our code creates the `require` function through a BrowserLoader, it can conflict with the TypeScript type system. For example:

View File

@ -46,13 +46,14 @@ To run the other (non-debugger) DevTools tests, the easiest is to rely on the sa
> node devtools/client/bin/devtools-node-test-runner.js --suite={suitename}
```
At the moment of writing, the supported suites for this script are:
At the moment of writing, the supported suites for this script are:
- `aboutdebugging`
- `accessibility`
- `application`
- `compatibility`
- `framework`
- `netmonitor`
- `performance`
- `shared_components`
- `webconsole`
@ -75,3 +76,7 @@ Inspect your code changes or run `yarn run test-ci -u` to update them.
```
For example, if you need to update snapshots in a specific panel, first locate the package.json corresponding to the node test folder of the panel. In theory it should be under `devtools/client/{panelname}/test/node/` but it might be slightly different depending on each panel. Then run `yarn run test-ci -u` in this folder and add the snapshot changes to your commit.
## TypeScript
The "performance" suite performs TypeScript checks. The TypeScript usage in the performance panel is documented at [devtools/client/performance-new/typescript.md](https://searchfox.org/mozilla-central/source/devtools/client/performance-new/typescript.md) ([see rendered version on GitHub](https://github.com/mozilla/gecko-dev/blob/master/devtools/client/performance-new/typescript.md)).