summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUjjwal Sharma <usharma1998@gmail.com>2018-03-29 08:18:03 +0530
committerBeth Griggs <Bethany.Griggs@uk.ibm.com>2018-12-04 15:40:17 +0000
commit1bda58289a1256b154e6ae15db23db83a3e6d130 (patch)
treeb8cc72911e2fa86273250c1fabade19940937799
parentbd9cc92e8d0267b58492ea4b83d5b62876bb0cf2 (diff)
downloadnode-new-1bda58289a1256b154e6ae15db23db83a3e6d130.tar.gz
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: https://github.com/nodejs/node/pull/19668 Refs: https://github.com/nodejs/node/issues/19105 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r--test/parallel/test-fs-truncate-clear-file-zero.js (renamed from test/parallel/test-fs-truncate-GH-6233.js)20
-rw-r--r--test/parallel/test-process-exit-GH-12322.js7
-rw-r--r--test/parallel/test-process-exit-handler.js11
3 files changed, 25 insertions, 13 deletions
diff --git a/test/parallel/test-fs-truncate-GH-6233.js b/test/parallel/test-fs-truncate-clear-file-zero.js
index 87663c6361..4f3dce9099 100644
--- a/test/parallel/test-fs-truncate-GH-6233.js
+++ b/test/parallel/test-fs-truncate-clear-file-zero.js
@@ -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();
@@ -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');
+ })
+ );
}
diff --git a/test/parallel/test-process-exit-GH-12322.js b/test/parallel/test-process-exit-GH-12322.js
deleted file mode 100644
index 890dfd4df7..0000000000
--- a/test/parallel/test-process-exit-GH-12322.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-require('../common');
-
-process.on('exit', () => {
- setTimeout(process.abort, 0); // Should not run.
- for (const start = Date.now(); Date.now() - start < 10; /* Empty. */);
-});
diff --git a/test/parallel/test-process-exit-handler.js b/test/parallel/test-process-exit-handler.js
new file mode 100644
index 0000000000..22d84f3434
--- /dev/null
+++ b/test/parallel/test-process-exit-handler.js
@@ -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;);
+});