Skip to content

Commit 1bda582

Browse files
ryzokukenBethGriggs
authored andcommitted
test: rename regression tests more expressively
- Rename test-fs-truncate-GH-6233 to test-fs-truncate-clear-file-zero - Rename test-process-exit-GH-12322 to test-process-exit-handler PR-URL: #19668 Refs: #19105 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent bd9cc92 commit 1bda582

3 files changed

+25
-13
lines changed

test/parallel/test-fs-truncate-GH-6233.js test/parallel/test-fs-truncate-clear-file-zero.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@
2121

2222
'use strict';
2323
const common = require('../common');
24+
const tmpdir = require('../common/tmpdir');
25+
26+
// This test ensures that `fs.truncate` opens the file with `r+` and not `w`,
27+
// which had earlier resulted in the target file's content getting zeroed out.
28+
// https://github.com/nodejs/node-v0.x-archive/issues/6233
29+
2430
const assert = require('assert');
2531
const fs = require('fs');
2632

27-
const tmpdir = require('../common/tmpdir');
28-
2933
const filename = `${tmpdir.path}/truncate-file.txt`;
3034

3135
tmpdir.refresh();
@@ -42,8 +46,12 @@ tmpdir.refresh();
4246
{
4347
fs.writeFileSync(filename, '0123456789');
4448
assert.strictEqual(fs.readFileSync(filename).toString(), '0123456789');
45-
fs.truncate(filename, 5, common.mustCall(function(err) {
46-
assert.ifError(err);
47-
assert.strictEqual(fs.readFileSync(filename).toString(), '01234');
48-
}));
49+
fs.truncate(
50+
filename,
51+
5,
52+
common.mustCall(function(err) {
53+
assert.ifError(err);
54+
assert.strictEqual(fs.readFileSync(filename).toString(), '01234');
55+
})
56+
);
4957
}

test/parallel/test-process-exit-GH-12322.js

-7
This file was deleted.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
require('../common');
3+
4+
// This test ensures that no asynchronous operations are performed in the 'exit'
5+
// handler.
6+
// https://github.com/nodejs/node/issues/12322
7+
8+
process.on('exit', () => {
9+
setTimeout(process.abort, 0); // Should not run.
10+
for (const start = Date.now(); Date.now() - start < 10;);
11+
});

0 commit comments

Comments
 (0)