Skip to content

Commit 391710c

Browse files
authored
Convert 9 more tests to test:node (14/24) (#1369)
1 parent 6290df9 commit 391710c

11 files changed

+271
-347
lines changed

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"output": []
182182
},
183183
"test:clean": {
184-
"command": "uvu lib/test \"^clean\\.test\\.js$\"",
184+
"command": "node --test --test-reporter=dot lib/test/clean.test.js",
185185
"env": {
186186
"NODE_OPTIONS": "--enable-source-maps"
187187
},
@@ -192,7 +192,7 @@
192192
"output": []
193193
},
194194
"test:cli-options": {
195-
"command": "uvu lib/test \"^cli-options\\.test\\.js$\"",
195+
"command": "node --test --test-reporter=dot lib/test/cli-options.test.js",
196196
"env": {
197197
"NODE_OPTIONS": "--enable-source-maps"
198198
},
@@ -203,7 +203,7 @@
203203
"output": []
204204
},
205205
"test:codeactions": {
206-
"command": "uvu lib/test \"^codeactions\\.test\\.js$\"",
206+
"command": "node --test --test-reporter=dot lib/test/codeactions.test.js",
207207
"env": {
208208
"NODE_OPTIONS": "--enable-source-maps"
209209
},
@@ -236,7 +236,7 @@
236236
"output": []
237237
},
238238
"test:diagnostic": {
239-
"command": "uvu lib/test \"^diagnostic\\.test\\.js$\"",
239+
"command": "node --test --test-reporter=dot lib/test/diagnostic.test.js",
240240
"env": {
241241
"NODE_OPTIONS": "--enable-source-maps"
242242
},
@@ -247,7 +247,7 @@
247247
"output": []
248248
},
249249
"test:errors-analysis": {
250-
"command": "uvu lib/test \"^errors-analysis\\.test\\.js$\"",
250+
"command": "node --test --test-reporter=dot lib/test/errors-analysis.test.js",
251251
"env": {
252252
"NODE_OPTIONS": "--enable-source-maps"
253253
},
@@ -269,7 +269,7 @@
269269
"output": []
270270
},
271271
"test:failures": {
272-
"command": "uvu lib/test \"^failures\\.test\\.js$\"",
272+
"command": "node --test --test-reporter=dot lib/test/failures.test.js",
273273
"env": {
274274
"NODE_OPTIONS": "--enable-source-maps"
275275
},
@@ -280,7 +280,7 @@
280280
"output": []
281281
},
282282
"test:freshness": {
283-
"command": "uvu lib/test \"^freshness\\.test\\.js$\"",
283+
"command": "node --test --test-reporter=dot lib/test/freshness.test.js",
284284
"env": {
285285
"NODE_OPTIONS": "--enable-source-maps"
286286
},
@@ -291,7 +291,7 @@
291291
"output": []
292292
},
293293
"test:gc": {
294-
"command": "node --expose-gc node_modules/uvu/bin.js lib/test \"^gc\\.test\\.js$\"",
294+
"command": "node --expose-gc lib/test/gc.test.js",
295295
"env": {
296296
"NODE_OPTIONS": "--enable-source-maps"
297297
},
@@ -348,7 +348,7 @@
348348
"output": []
349349
},
350350
"test:optimize-mkdirs": {
351-
"command": "uvu lib/test \"^optimize-mkdirs\\.test\\.js$\"",
351+
"command": "node --test --test-reporter=dot lib/test/optimize-mkdirs.test.js",
352352
"env": {
353353
"NODE_OPTIONS": "--enable-source-maps"
354354
},
@@ -370,7 +370,7 @@
370370
"output": []
371371
},
372372
"test:quiet": {
373-
"command": "uvu lib/test \"^quiet-logger\\.test\\.js$\"",
373+
"command": "node --test --test-reporter=dot lib/test/quiet-logger.test.js",
374374
"env": {
375375
"NODE_OPTIONS": "--enable-source-maps"
376376
},

src/test/clean.test.ts

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import {suite} from 'uvu';
8-
import * as assert from 'uvu/assert';
9-
import {rigTest} from './util/rig-test.js';
7+
import {test} from 'node:test';
8+
import * as assert from 'node:assert';
9+
import {rigTestNode as rigTest} from './util/rig-test.js';
1010
import * as pathlib from 'path';
1111
import {checkScriptOutput} from './util/check-script-output.js';
1212

13-
const test = suite<object>();
14-
15-
test(
13+
void test(
1614
'cleans output by default',
1715
rigTest(async ({rig}) => {
1816
const cmdA = await rig.newCommand();
@@ -38,7 +36,7 @@ test(
3836
// command.
3937
const exec = rig.exec('npm run a');
4038
const inv = await cmdA.nextInvocation();
41-
assert.not(await rig.exists('output'));
39+
assert.ok(!(await rig.exists('output')));
4240

4341
inv.exit(0);
4442
const res = await exec.exit;
@@ -47,7 +45,7 @@ test(
4745
}),
4846
);
4947

50-
test(
48+
void test(
5149
'cleans output when clean is true',
5250
rigTest(async ({rig}) => {
5351
const cmdA = await rig.newCommand();
@@ -74,7 +72,7 @@ test(
7472
// command.
7573
const exec = rig.exec('npm run a');
7674
const inv = await cmdA.nextInvocation();
77-
assert.not(await rig.exists('output'));
75+
assert.ok(!(await rig.exists('output')));
7876

7977
inv.exit(0);
8078
const res = await exec.exit;
@@ -83,7 +81,7 @@ test(
8381
}),
8482
);
8583

86-
test(
84+
void test(
8785
'does not clean output when clean is false',
8886
rigTest(async ({rig}) => {
8987
const cmdA = await rig.newCommand();
@@ -116,7 +114,7 @@ test(
116114
}),
117115
);
118116

119-
test(
117+
void test(
120118
'cleaning deletes all files matched by glob pattern',
121119
rigTest(async ({rig}) => {
122120
const cmdA = await rig.newCommand();
@@ -140,8 +138,8 @@ test(
140138
const exec = rig.exec('npm run a');
141139
const inv = await cmdA.nextInvocation();
142140

143-
assert.not(await rig.exists('output/include'));
144-
assert.not(await rig.exists('output/sub/include'));
141+
assert.ok(!(await rig.exists('output/include')));
142+
assert.ok(!(await rig.exists('output/sub/include')));
145143
assert.ok(await rig.exists('output/exclude'));
146144

147145
inv.exit(0);
@@ -151,7 +149,7 @@ test(
151149
}),
152150
);
153151

154-
test(
152+
void test(
155153
'cleaning supports glob re-inclusion',
156154
rigTest(async ({rig}) => {
157155
const cmdA = await rig.newCommand();
@@ -179,7 +177,7 @@ test(
179177
const inv = await cmdA.nextInvocation();
180178

181179
assert.ok(await rig.exists('output/subdir/excluded'));
182-
assert.not(await rig.exists('output/subdir/reincluded'));
180+
assert.ok(!(await rig.exists('output/subdir/reincluded')));
183181

184182
inv.exit(0);
185183
const res = await exec.exit;
@@ -188,7 +186,7 @@ test(
188186
}),
189187
);
190188

191-
test(
189+
void test(
192190
'cleaning deletes directories',
193191
rigTest(async ({rig}) => {
194192
const cmdA = await rig.newCommand();
@@ -210,8 +208,8 @@ test(
210208
const exec = rig.exec('npm run a');
211209
const inv = await cmdA.nextInvocation();
212210

213-
assert.not(await rig.exists('output/subdir/file'));
214-
assert.not(await rig.exists('output/subdir'));
211+
assert.ok(!(await rig.exists('output/subdir/file')));
212+
assert.ok(!(await rig.exists('output/subdir')));
215213

216214
inv.exit(0);
217215
const res = await exec.exit;
@@ -220,7 +218,7 @@ test(
220218
}),
221219
);
222220

223-
test(
221+
void test(
224222
'cleaning deletes symlinks but not their targets',
225223
rigTest(async ({rig}) => {
226224
const cmdA = await rig.newCommand();
@@ -244,7 +242,7 @@ test(
244242
const inv = await cmdA.nextInvocation();
245243

246244
// The symlink itself should be deleted, but not the target of the symlink.
247-
assert.not(await rig.exists('symlink'));
245+
assert.ok(!(await rig.exists('symlink')));
248246
assert.ok(await rig.exists('symlink.target'));
249247

250248
inv.exit(0);
@@ -254,7 +252,7 @@ test(
254252
}),
255253
);
256254

257-
test(
255+
void test(
258256
'errors if cleaning output outside of the package',
259257
rigTest(async ({rig}) => {
260258
const cmdA = await rig.newCommand();
@@ -296,7 +294,7 @@ test(
296294
}),
297295
);
298296

299-
test(
297+
void test(
300298
'"if-file-deleted" cleans only when input file deleted',
301299
rigTest(async ({rig}) => {
302300
const cmdA = await rig.newCommand();
@@ -338,9 +336,9 @@ test(
338336
const inv = await cmdA.nextInvocation();
339337

340338
// No outputs have been written yet.
341-
assert.not(await rig.exists('output/a'));
342-
assert.not(await rig.exists('output/b'));
343-
assert.not(await rig.exists('output/c'));
339+
assert.ok(!(await rig.exists('output/a')));
340+
assert.ok(!(await rig.exists('output/b')));
341+
assert.ok(!(await rig.exists('output/c')));
344342

345343
// Write output A.
346344
await rig.write({'output/a': 'v0'});
@@ -359,8 +357,8 @@ test(
359357

360358
// Output A should still exist.
361359
assert.equal(await rig.read('output/a'), 'v0');
362-
assert.not(await rig.exists('output/b'));
363-
assert.not(await rig.exists('output/c'));
360+
assert.ok(!(await rig.exists('output/b')));
361+
assert.ok(!(await rig.exists('output/c')));
364362

365363
// Write outputs A and B.
366364
await rig.write({'output/a': 'v1'});
@@ -381,7 +379,7 @@ test(
381379
// Outputs A and B should still exist.
382380
assert.equal(await rig.read('output/a'), 'v1');
383381
assert.equal(await rig.read('output/b'), 'v1');
384-
assert.not(await rig.exists('output/c'));
382+
assert.ok(!(await rig.exists('output/c')));
385383

386384
// Write outputs A and B
387385
await rig.write({'output/a': 'v2'});
@@ -402,9 +400,9 @@ test(
402400
const inv = await cmdA.nextInvocation();
403401

404402
// Outputs A and B should have been cleaned.
405-
assert.not(await rig.exists('output/a'));
406-
assert.not(await rig.exists('output/b'));
407-
assert.not(await rig.exists('output/c'));
403+
assert.ok(!(await rig.exists('output/a')));
404+
assert.ok(!(await rig.exists('output/b')));
405+
assert.ok(!(await rig.exists('output/c')));
408406

409407
// Write output B.
410408
await rig.write({'output/b': 'v3'});
@@ -425,9 +423,9 @@ test(
425423
const inv = await cmdA.nextInvocation();
426424

427425
// Output B should have been cleaned.
428-
assert.not(await rig.exists('output/a'));
429-
assert.not(await rig.exists('output/b'));
430-
assert.not(await rig.exists('output/c'));
426+
assert.ok(!(await rig.exists('output/a')));
427+
assert.ok(!(await rig.exists('output/b')));
428+
assert.ok(!(await rig.exists('output/c')));
431429

432430
// Write output C.
433431
await rig.write({'output/c': 'v0'});
@@ -441,7 +439,7 @@ test(
441439
}),
442440
);
443441

444-
test(
442+
void test(
445443
'directories are not deleted unless empty',
446444
rigTest(async ({rig}) => {
447445
const cmdA = await rig.newCommand();
@@ -466,7 +464,7 @@ test(
466464
const inv = await cmdA.nextInvocation();
467465

468466
// The included file should have been deleted.
469-
assert.not(await rig.exists('output/included'));
467+
assert.ok(!(await rig.exists('output/included')));
470468

471469
// The output directory should not have been deleted, even though it was
472470
// matched, because the excluded file still exists, so it's not empty.
@@ -490,13 +488,13 @@ test(
490488
const inv = await cmdA.nextInvocation();
491489

492490
// The included file should have been deleted.
493-
assert.not(await rig.exists('output/included'));
491+
assert.ok(!(await rig.exists('output/included')));
494492

495493
// The output directory is now empty, so it should have been deleted.
496-
assert.not(await rig.exists('output'));
494+
assert.ok(!(await rig.exists('output')));
497495

498496
// The excluded file didn't exist to begin with.
499-
assert.not(await rig.exists('output/excluded'));
497+
assert.ok(!(await rig.exists('output/excluded')));
500498

501499
inv.exit(0);
502500
const res = await exec.exit;
@@ -506,7 +504,7 @@ test(
506504
}),
507505
);
508506

509-
test(
507+
void test(
510508
'leading slash on output glob is package relative',
511509
rigTest(async ({rig}) => {
512510
const cmdA = await rig.newCommand();
@@ -532,13 +530,11 @@ test(
532530
// command.
533531
const exec = rig.exec('npm run a');
534532
const inv = await cmdA.nextInvocation();
535-
assert.not(await rig.exists('output'));
533+
assert.ok(!(await rig.exists('output')));
536534

537535
inv.exit(0);
538536
const res = await exec.exit;
539537
assert.equal(res.code, 0);
540538
assert.equal(cmdA.numInvocations, 1);
541539
}),
542540
);
543-
544-
test.run();

0 commit comments

Comments
 (0)