Skip to content

Commit 8d051fd

Browse files
authored
Run linting during CI (and other small cleanups) (#477)
* Run linting during CI Otherwise it tends to break over time. * Fix lint errors about "Forbidden non-null assertion" regPC cannot be undefined at this point because we assert as much above, so the non-null assertions are not needed. However the TypeScript compiler does not know that and would error out because it does not understand `expect(regPC).to.exist`. It does understand `assert(regPC !== undefined)`, so replace it with that. (Not an exact replacement because `exist` also checks for null, but that cannot occur here.) * Fix typo in ignoring compiled test programs * Run mocha with --forbid-only in CI To catch accidentally committed `.only(` on tests. Signed-off-by: Christian Walther <[email protected]>
1 parent 9676116 commit 8d051fd

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

.github/workflows/build-pr.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ jobs:
2828
- name: Build
2929
run: yarn
3030
- name: Verify code formatting is valid
31-
run: yarn format-check
31+
run: |
32+
yarn format-check
33+
yarn lint
3234
- name: Build Test Programs
3335
run: make -C src/integration-tests/test-programs
3436
- name: Test

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@
3636
"test:integration-hw-breakpoint-on-remote-target": "cross-env JUNIT_REPORT_PATH=test-reports/integration-hw-breakpoint-on-remote-target.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-hw-breakpoint-on --test-remote",
3737
"test:pty": "cross-env JUNIT_REPORT_PATH=test-reports/native.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 mocha --exit --reporter mocha-jenkins-reporter dist/native/*.spec.js",
3838
"test-ci": "run-s --continue-on-error test-ci:integration test-ci:integration-remote-target test-ci:integration-gdb-async-off test-ci:integration-gdb-async-off-remote-target test-ci:integration-gdb-non-stop test-ci:integration-gdb-non-stop-remote-target test-ci:integration-hw-breakpoint-on-remote-target",
39-
"test-ci:integration": "cross-env JUNIT_REPORT_PATH=test-reports/integration.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts",
40-
"test-ci:integration-run-in-terminal": "cross-env JUNIT_REPORT_PATH=test-reports/integration-run-in-terminal.xml JUNIT_REPORT_STACK=1 ENV_TEST_VAR=VALUE1 JUNIT_REPORT_PACKAGES=1 mocha --exit --skip-make --run-in-terminal --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts",
41-
"test-ci:integration-remote-target": "cross-env JUNIT_REPORT_PATH=test-reports/integration-remote-target.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --skip-make --test-remote --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts",
42-
"test-ci:integration-remote-target-run-in-terminal": "cross-env JUNIT_REPORT_PATH=test-reports/integration-remote-target-run-in-terminal.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --skip-make --test-remote --run-in-terminal --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts",
43-
"test-ci:integration-gdb-async-off": "cross-env JUNIT_REPORT_PATH=test-reports/integration-gdb-async-off.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-gdb-async-off",
44-
"test-ci:integration-gdb-async-off-remote-target": "cross-env JUNIT_REPORT_PATH=test-reports/integration-gdb-async-off-remote-target.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-gdb-async-off --test-remote",
45-
"test-ci:integration-gdb-non-stop": "cross-env JUNIT_REPORT_PATH=test-reports/integration-gdb-non-stop.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-gdb-non-stop",
46-
"test-ci:integration-gdb-non-stop-remote-target": "cross-env JUNIT_REPORT_PATH=test-reports/integration-gdb-non-stop-remote-target.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-gdb-non-stop --test-remote",
47-
"test-ci:integration-hw-breakpoint-on-remote-target": "cross-env JUNIT_REPORT_PATH=test-reports/integration-hw-breakpoint-on-remote-target.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-hw-breakpoint-on --test-remote",
48-
"test-ci:pty": "cross-env JUNIT_REPORT_PATH=test-reports/native.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 mocha --exit --skip-make --reporter mocha-jenkins-reporter dist/native/*.spec.js"
39+
"test-ci:integration": "cross-env JUNIT_REPORT_PATH=test-reports/integration.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --forbid-only --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts",
40+
"test-ci:integration-run-in-terminal": "cross-env JUNIT_REPORT_PATH=test-reports/integration-run-in-terminal.xml JUNIT_REPORT_STACK=1 ENV_TEST_VAR=VALUE1 JUNIT_REPORT_PACKAGES=1 mocha --exit --forbid-only --skip-make --run-in-terminal --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts",
41+
"test-ci:integration-remote-target": "cross-env JUNIT_REPORT_PATH=test-reports/integration-remote-target.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --forbid-only --skip-make --test-remote --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts",
42+
"test-ci:integration-remote-target-run-in-terminal": "cross-env JUNIT_REPORT_PATH=test-reports/integration-remote-target-run-in-terminal.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --forbid-only --skip-make --test-remote --run-in-terminal --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts",
43+
"test-ci:integration-gdb-async-off": "cross-env JUNIT_REPORT_PATH=test-reports/integration-gdb-async-off.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --forbid-only --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-gdb-async-off",
44+
"test-ci:integration-gdb-async-off-remote-target": "cross-env JUNIT_REPORT_PATH=test-reports/integration-gdb-async-off-remote-target.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --forbid-only --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-gdb-async-off --test-remote",
45+
"test-ci:integration-gdb-non-stop": "cross-env JUNIT_REPORT_PATH=test-reports/integration-gdb-non-stop.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --forbid-only --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-gdb-non-stop",
46+
"test-ci:integration-gdb-non-stop-remote-target": "cross-env JUNIT_REPORT_PATH=test-reports/integration-gdb-non-stop-remote-target.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --forbid-only --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-gdb-non-stop --test-remote",
47+
"test-ci:integration-hw-breakpoint-on-remote-target": "cross-env JUNIT_REPORT_PATH=test-reports/integration-hw-breakpoint-on-remote-target.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 ENV_TEST_VAR=VALUE1 mocha --exit --forbid-only --skip-make --reporter mocha-jenkins-reporter -r ts-node/register src/integration-tests/*.spec.ts --test-hw-breakpoint-on --test-remote",
48+
"test-ci:pty": "cross-env JUNIT_REPORT_PATH=test-reports/native.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 mocha --exit --forbid-only --skip-make --reporter mocha-jenkins-reporter dist/native/*.spec.js"
4949
},
5050
"repository": {
5151
"type": "git",

src/integration-tests/multithread.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,12 @@ describe('multithread', async function () {
473473
const regPC = vars.body.variables.find(
474474
(v) => v.name === 'pc' || v.name === 'rip'
475475
);
476-
expect(regPC).to.exist;
476+
// assert instead of expect to make tsc happy so we don't need forbidden non-null assertions below
477+
assert(regPC !== undefined, 'expected regPC to exist');
477478
const reg0 = vars.body.variables[0];
478479

479480
const setRegPC = await dc.setVariableRequest({
480-
name: regPC!.name,
481+
name: regPC.name,
481482
value: '0x200',
482483
variablesReference: vr,
483484
});
@@ -503,12 +504,12 @@ describe('multithread', async function () {
503504
variable.value,
504505
])
505506
);
506-
expect(varnameToValue1.get(regPC!.name)).to.equal('0x200');
507+
expect(varnameToValue1.get(regPC.name)).to.equal('0x200');
507508
expect(varnameToValue1.get(reg0.name)).to.equal('0x55555');
508509

509510
await dc.setVariableRequest({
510-
name: regPC!.name,
511-
value: regPC!.value,
511+
name: regPC.name,
512+
value: regPC.value,
512513
variablesReference: vr,
513514
});
514515
await dc.setVariableRequest({

src/integration-tests/test-programs/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ evaluate
77
mem
88
vars
99
vars_env
10-
var_globals
10+
vars_globals
1111
segv
1212
loopforever
1313
MultiThread

0 commit comments

Comments
 (0)