| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bd9cc92 commit 1bda582
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,11 +21,15 @@ | |||
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | 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 | + | ||
| 24 | 30 | const assert = require('assert'); | |
| 25 | 31 | const fs = require('fs'); | |
| 26 | 32 | ||
| 27 | - const tmpdir = require('../common/tmpdir'); | ||
| 28 | - | ||
| 29 | 33 | const filename = `${tmpdir.path}/truncate-file.txt`; | |
| 30 | 34 | ||
| 31 | 35 | tmpdir.refresh(); | |
@@ -42,8 +46,12 @@ tmpdir.refresh(); | |||
| 42 | 46 | { | |
| 43 | 47 | fs.writeFileSync(filename, '0123456789'); | |
| 44 | 48 | 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 | + ); | ||
| 49 | 57 | } | |
| Original file line number | Diff line number | Diff 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 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments