Skip to content

Commit 6afd1c5

Browse files
committed
web/test: shell suites fail when a test waits for something that never happens (exit guard)
1 parent b2343b9 commit 6afd1c5

14 files changed

Lines changed: 44 additions & 0 deletions

‎web/test/unit/shell-engine-build.test.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
// @ts-check
1010
'use strict';
1111

12+
// A test that waits for something that never happens must fail the suite, not end it silently with status 0.
13+
require('../helpers/shell-exit-guard.js');
14+
1215
const assert = require('assert');
1316
const fs = require('fs');
1417
const os = require('os');
@@ -100,6 +103,8 @@ async function main() {
100103
fs.mkdirSync(path.join(root, 'web', 'test', 'unit'), { recursive: true });
101104
fs.cpSync(ENGINE, path.join(root, 'web', 'shell', 'engine'), { recursive: true });
102105
fs.copyFileSync(__filename, path.join(root, 'web', 'test', 'unit', 'shell-engine-build.test.js'));
106+
fs.mkdirSync(path.join(root, 'web', 'test', 'helpers'), { recursive: true });
107+
fs.copyFileSync(path.join(__dirname, '..', 'helpers', 'shell-exit-guard.js'), path.join(root, 'web', 'test', 'helpers', 'shell-exit-guard.js'));
103108
const run = (env) => spawnSync(process.execPath, [path.join(root, 'web', 'test', 'unit', 'shell-engine-build.test.js')], { encoding: 'utf8', env: Object.assign({}, process.env, { LEVELCODE_VSCODE: '', LEVELCODE_REQUIRE_BUILD: '', LC_BUILD_TEST_COPY: '1' }, env) });
104109
const quiet = run({});
105110
assert.strictEqual(quiet.status, 0, quiet.stdout + quiet.stderr);

‎web/test/unit/shell-engine-compat.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
// @ts-check
1010
'use strict';
1111

12+
// A test that waits for something that never happens must fail the suite, not end it silently with status 0.
13+
require('../helpers/shell-exit-guard.js');
14+
1215
// `touch -t`, `date` and `stat` read local time as GNU does, and the shell's is UTC (or the command's TZ): the process's
1316
// zone, the visitor's in a browser, is never asked. The whole suite is run under three of them.
1417
const ZONES = ['UTC', 'America/New_York', 'Asia/Tokyo'];

‎web/test/unit/shell-engine-consistency.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
// @ts-check
1515
'use strict';
1616

17+
// A test that waits for something that never happens must fail the suite, not end it silently with status 0.
18+
require('../helpers/shell-exit-guard.js');
19+
1720
const assert = require('assert');
1821
const fs = require('fs');
1922
const path = require('path');

‎web/test/unit/shell-engine-core.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// @ts-check
1414
'use strict';
1515

16+
// A test that waits for something that never happens must fail the suite, not end it silently with status 0.
17+
require('../helpers/shell-exit-guard.js');
18+
1619
const assert = require('assert');
1720
const path = require('path');
1821

‎web/test/unit/shell-engine-cpmv.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
// @ts-check
1717
'use strict';
1818

19+
// A test that waits for something that never happens must fail the suite, not end it silently with status 0.
20+
require('../helpers/shell-exit-guard.js');
21+
1922
const assert = require('assert');
2023
const fs = require('fs');
2124
const path = require('path');

‎web/test/unit/shell-engine-fuzz.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
// @ts-check
1111
'use strict';
1212

13+
// A test that waits for something that never happens must fail the suite, not end it silently with status 0.
14+
require('../helpers/shell-exit-guard.js');
15+
1316
// the zone of the process is the visitor's, and the shell does not ask it: the first run is in UTC, the others in two
1417
// that are not (a smaller count each, from other seeds)
1518
const ZONES = [['UTC', 3000, 20261011], ['America/New_York', 800, 20261012], ['Asia/Tokyo', 800, 20261013]];

‎web/test/unit/shell-engine-golden.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
// @ts-check
1717
'use strict';
1818

19+
// A test that waits for something that never happens must fail the suite, not end it silently with status 0.
20+
require('../helpers/shell-exit-guard.js');
21+
1922
// The reference ran with TZ unset, which is UTC, and so does the shell: whatever zone the process (the visitor's
2023
// browser) is in is never asked. Every case is run under three of them and must give the same answer.
2124
const ZONES = ['UTC', 'America/New_York', 'Asia/Tokyo'];

‎web/test/unit/shell-engine-overlay.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// @ts-check
1313
'use strict';
1414

15+
// A test that waits for something that never happens must fail the suite, not end it silently with status 0.
16+
require('../helpers/shell-exit-guard.js');
17+
1518
const assert = require('assert');
1619
const path = require('path');
1720

‎web/test/unit/shell-engine-patches.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// @ts-check
1313
'use strict';
1414

15+
// A test that waits for something that never happens must fail the suite, not end it silently with status 0.
16+
require('../helpers/shell-exit-guard.js');
17+
1518
const assert = require('assert');
1619
const crypto = require('crypto');
1720
const fs = require('fs');

‎web/test/unit/shell-engine-text.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// @ts-check
99
'use strict';
1010

11+
// A test that waits for something that never happens must fail the suite, not end it silently with status 0.
12+
require('../helpers/shell-exit-guard.js');
13+
1114
const assert = require('assert');
1215
const path = require('path');
1316

0 commit comments

Comments
 (0)