Skip to content

Commit

Permalink
test: rename regression tests more expressively
Browse files Browse the repository at this point in the history
- 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 <gpunathi@in.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
ryzokuken authored and BethGriggs committed Dec 4, 2018
1 parent bd9cc92 commit 1bda582
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@

'use strict';
const common = require('../common');
const tmpdir = require('../common/tmpdir');

// This test ensures that `fs.truncate` opens the file with `r+` and not `w`,
// which had earlier resulted in the target file's content getting zeroed out.
// https://github.com/nodejs/node-v0.x-archive/issues/6233

const assert = require('assert');
const fs = require('fs');

const tmpdir = require('../common/tmpdir');

const filename = `${tmpdir.path}/truncate-file.txt`;

tmpdir.refresh();
Expand All @@ -42,8 +46,12 @@ tmpdir.refresh();
{
fs.writeFileSync(filename, '0123456789');
assert.strictEqual(fs.readFileSync(filename).toString(), '0123456789');
fs.truncate(filename, 5, common.mustCall(function(err) {
assert.ifError(err);
assert.strictEqual(fs.readFileSync(filename).toString(), '01234');
}));
fs.truncate(
filename,
5,
common.mustCall(function(err) {
assert.ifError(err);
assert.strictEqual(fs.readFileSync(filename).toString(), '01234');
})
);
}
7 changes: 0 additions & 7 deletions test/parallel/test-process-exit-GH-12322.js

This file was deleted.

11 changes: 11 additions & 0 deletions test/parallel/test-process-exit-handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';
require('../common');

// This test ensures that no asynchronous operations are performed in the 'exit'
// handler.
// https://github.com/nodejs/node/issues/12322

process.on('exit', () => {
setTimeout(process.abort, 0); // Should not run.
for (const start = Date.now(); Date.now() - start < 10;);
});

0 comments on commit 1bda582

Please sign in to comment.