Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 781a266

Browse filesBrowse files
committed
test: ensure assertions are reachable in more folders
PR-URL: #60411 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent d09ba98 commit 781a266
Copy full SHA for 781a266
Expand file treeCollapse file tree

18 files changed

+147
-77
lines changed
Open diff view settings
Collapse file

‎test/doctool/test-apilinks.mjs‎

Copy file name to clipboardExpand all lines: test/doctool/test-apilinks.mjs
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '../common/index.mjs';
1+
import { mustCallAtLeast } from '../common/index.mjs';
22
import * as fixtures from '../common/fixtures.mjs';
33
import tmpdir from '../common/tmpdir.js';
44

@@ -14,7 +14,7 @@ const apilinks = fixtures.path('apilinks');
1414

1515
tmpdir.refresh();
1616

17-
fs.readdirSync(apilinks).forEach((fixture) => {
17+
fs.readdirSync(apilinks).forEach(mustCallAtLeast((fixture) => {
1818
if (!fixture.endsWith('.js')) return;
1919
const input = path.join(apilinks, fixture);
2020

@@ -40,4 +40,4 @@ fs.readdirSync(apilinks).forEach((fixture) => {
4040
Object.keys(actualLinks).length, 0,
4141
`unexpected links returned ${JSON.stringify(actualLinks)}`,
4242
);
43-
});
43+
}));
Collapse file

‎test/eslint.config_partial.mjs‎

Copy file name to clipboardExpand all lines: test/eslint.config_partial.mjs
+19-1Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,31 @@ export default [
163163
'benchmark',
164164
'cctest',
165165
'client-proxy',
166+
'doctool',
167+
'embedding',
168+
'fixtures',
169+
'fuzzers',
170+
'js-native-api',
171+
'known_issues',
166172
'message',
167173
'module-hooks',
168174
'node-api',
169-
'pummel',
175+
'nop',
176+
'overlapped-checker',
170177
'pseudo-tty',
178+
'pummel',
179+
'report',
180+
'sea',
181+
'sqlite',
182+
'system-ca',
183+
'test426',
184+
'testpy',
185+
'tick-processor',
186+
'tools',
171187
'v8-updates',
172188
'wasi',
189+
'wasm-allocation',
190+
'wpt',
173191
].join(',')}}/**/*.{js,mjs,cjs}`,
174192
],
175193
rules: {
Collapse file

‎test/fixtures/test-runner/output/filtered-suite-delayed-build.js‎

Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/filtered-suite-delayed-build.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
const common = require('../../../common');
44
const { suite, test } = require('node:test');
55

6-
suite('async suite', async () => {
6+
suite('async suite', common.mustCall(async () => {
77
await 1;
88
test('enabled 1', common.mustCall());
99
await 1;
1010
test('not run', common.mustNotCall());
1111
await 1;
12-
});
12+
}));
1313

14-
suite('sync suite', () => {
14+
suite('sync suite', common.mustCall(() => {
1515
test('enabled 2', common.mustCall());
16-
});
16+
}));
Collapse file

‎test/fixtures/test-runner/output/hooks-with-no-global-test.js‎

Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/hooks-with-no-global-test.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ before(() => testArr.push('global before'));
99
after(() => {
1010
testArr.push('global after');
1111

12+
// eslint-disable-next-line node-core/must-call-assert
1213
assert.deepStrictEqual(testArr, [
1314
'global before',
1415
'describe before',
Collapse file

‎test/fixtures/test-runner/output/hooks.js‎

Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/hooks.js
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { setTimeout } = require('node:timers/promises');
77
before((t) => t.diagnostic('before 1 called'));
88
after((t) => t.diagnostic('after 1 called'));
99

10-
describe('describe hooks', () => {
10+
describe('describe hooks', common.mustCall(() => {
1111
const testArr = [];
1212
before(function() {
1313
testArr.push('before ' + this.name);
@@ -51,9 +51,9 @@ describe('describe hooks', () => {
5151
it('nested 1', () => testArr.push('nested 1'));
5252
test('nested 2', () => testArr.push('nested 2'));
5353
});
54-
});
54+
}));
5555

56-
describe('describe hooks - no subtests', () => {
56+
describe('describe hooks - no subtests', common.mustCall(() => {
5757
const testArr = [];
5858
before(function() {
5959
testArr.push('before ' + this.name);
@@ -67,18 +67,18 @@ describe('describe hooks - no subtests', () => {
6767
}));
6868
beforeEach(common.mustNotCall());
6969
afterEach(common.mustNotCall());
70-
});
70+
}));
7171

7272
describe('before throws', () => {
7373
before(() => { throw new Error('before'); });
7474
it('1', () => {});
7575
test('2', () => {});
7676
});
7777

78-
describe('before throws - no subtests', () => {
78+
describe('before throws - no subtests', common.mustCall(() => {
7979
before(() => { throw new Error('before'); });
8080
after(common.mustCall());
81-
});
81+
}));
8282

8383
describe('after throws', () => {
8484
after(() => { throw new Error('after'); });
@@ -102,11 +102,11 @@ describe('afterEach throws', () => {
102102
test('2', () => {});
103103
});
104104

105-
describe('afterEach when test fails', () => {
105+
describe('afterEach when test fails', common.mustCall(() => {
106106
afterEach(common.mustCall(2));
107107
it('1', () => { throw new Error('test'); });
108108
test('2', () => {});
109-
});
109+
}));
110110

111111
describe('afterEach throws and test fails', () => {
112112
afterEach(() => { throw new Error('afterEach'); });
@@ -246,13 +246,13 @@ test('t.after() is called if test body throws', (t) => {
246246
throw new Error('bye');
247247
});
248248

249-
describe('run after when before throws', () => {
249+
describe('run after when before throws', common.mustCall(() => {
250250
after(common.mustCall(() => {
251251
console.log('- after() called');
252252
}));
253253
before(() => { throw new Error('before'); });
254254
it('1', () => {});
255-
});
255+
}));
256256

257257

258258
test('test hooks - async', async (t) => {
Collapse file

‎test/fixtures/test-runner/output/name_pattern.js‎

Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/name_pattern.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test('top level test enabled', common.mustCall(async (t) => {
3232
);
3333
}));
3434

35-
describe('top level describe enabled', () => {
35+
describe('top level describe enabled', common.mustCall(() => {
3636
before(common.mustCall());
3737
beforeEach(common.mustCall(3));
3838
afterEach(common.mustCall(3));
@@ -44,7 +44,7 @@ describe('top level describe enabled', () => {
4444
describe('nested describe enabled', common.mustCall(() => {
4545
it('is enabled', common.mustCall());
4646
}));
47-
});
47+
}));
4848

4949
describe('yes', function() {
5050
it('no', () => {});
@@ -76,13 +76,13 @@ describe('no with todo', { todo: true }, () => {
7676
});
7777
});
7878

79-
describe('DescribeForMatchWithAncestors', () => {
79+
describe('DescribeForMatchWithAncestors', common.mustCall(() => {
8080
it('NestedTest', () => common.mustNotCall());
8181

82-
describe('NestedDescribeForMatchWithAncestors', () => {
82+
describe('NestedDescribeForMatchWithAncestors', common.mustCall(() => {
8383
it('NestedTest', common.mustCall());
84-
});
85-
});
84+
}));
85+
}));
8686

8787
describe('DescribeForMatchWithAncestors', () => {
8888
it('NestedTest', () => common.mustNotCall());
Collapse file

‎test/js-native-api/3_callbacks/test.js‎

Copy file name to clipboardExpand all lines: test/js-native-api/3_callbacks/test.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ const common = require('../../common');
33
const assert = require('assert');
44
const addon = require(`./build/${common.buildType}/3_callbacks`);
55

6-
addon.RunCallback(function(msg) {
6+
addon.RunCallback(common.mustCall((msg) => {
77
assert.strictEqual(msg, 'hello world');
8-
});
8+
}));
99

1010
function testRecv(desiredRecv) {
11-
addon.RunCallbackWithRecv(function() {
11+
addon.RunCallbackWithRecv(common.mustCall(function() {
1212
assert.strictEqual(this, desiredRecv);
13-
}, desiredRecv);
13+
}), desiredRecv);
1414
}
1515

1616
testRecv(undefined);
Collapse file

‎test/js-native-api/test_promise/test.js‎

Copy file name to clipboardExpand all lines: test/js-native-api/test_promise/test.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ test_promise.concludeCurrentPromise(undefined, true);
5050
const rejectPromise = Promise.reject(-1);
5151
const expected_reason = -1;
5252
assert.strictEqual(test_promise.isPromise(rejectPromise), true);
53-
rejectPromise.catch((reason) => {
53+
rejectPromise.catch(common.mustCall((reason) => {
5454
assert.strictEqual(reason, expected_reason);
55-
});
55+
}));
5656

5757
assert.strictEqual(test_promise.isPromise(2.4), false);
5858
assert.strictEqual(test_promise.isPromise('I promise!'), false);
Collapse file

‎test/known_issues/test-dgram-bind-shared-ports-after-port-0.js‎

Copy file name to clipboardExpand all lines: test/known_issues/test-dgram-bind-shared-ports-after-port-0.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ if (cluster.isPrimary) {
2121
if (err.code === 'ENOTSUP') throw err;
2222
});
2323

24-
worker1.on('message', (msg) => {
24+
worker1.on('message', common.mustCall((msg) => {
2525
if (typeof msg !== 'object') process.exit(0);
2626
if (msg.message !== 'success') process.exit(0);
2727
if (typeof msg.port1 !== 'number') process.exit(0);
2828

2929
const worker2 = cluster.fork({ PRT1: msg.port1 });
3030
worker2.on('message', () => process.exit(0));
31-
worker2.on('exit', (code, signal) => {
31+
worker2.on('exit', common.mustCall((code, signal) => {
3232
// This is the droid we are looking for
3333
assert.strictEqual(code, 0);
3434
assert.strictEqual(signal, null);
35-
});
35+
}));
3636

3737
// cleanup anyway
3838
process.on('exit', () => {
3939
worker1.send(BYE);
4040
worker2.send(BYE);
4141
});
42-
});
42+
}));
4343
// end primary code
4444
} else {
4545
// worker code
Collapse file

‎test/known_issues/test-fs-cp-non-utf8.js‎

Copy file name to clipboardExpand all lines: test/known_issues/test-fs-cp-non-utf8.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (!common.isLinux) {
99
common.skip('This test is only applicable to Linux');
1010
}
1111

12-
const { ok, strictEqual } = require('assert');
12+
const assert = require('assert');
1313
const { join } = require('path');
1414
const path = require('path');
1515
const tmpdir = require('../common/tmpdir');
@@ -42,8 +42,8 @@ const name = Buffer.from([
4242
const testPath = Buffer.concat([tmpdirPath, sepBuf, name]);
4343

4444
writeFileSync(testPath, 'test content');
45-
ok(existsSync(testPath));
46-
strictEqual(readFileSync(testPath, 'utf8'), 'test content');
45+
assert.ok(existsSync(testPath));
46+
assert.strictEqual(readFileSync(testPath, 'utf8'), 'test content');
4747

4848
// The cpSync is expected to fail because the implementation does not
4949
// properly handle non-UTF8 names in the path.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.