test: update test-fs-fsync to run from temp

We copy the "a.js" file fixture to a temp directory and then we open
it with write access. This makes sure we are only writing to the
provided temp-dir and not in the fixture dir.

PR-URL: https://github.com/nodejs/node/pull/15537
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
atvoicu authored and Ruben Bridgewater committed 2017-09-24 13:41:21 -03:00
1 parent 6faede7eb4
commit d9cc105102
1 file changed
+8 -2
+8 -2
View File
@@ -25,10 +25,16 @@ const assert = require('assert');
const fixtures = require('../common/fixtures');
const fs = require('fs');
const path = require('path');
const file = fixtures.path('a.js');
const fileFixture = fixtures.path('a.js');
const fileTemp = path.join(common.tmpDir, 'a.js');
fs.open(file, 'a', 0o777, common.mustCall(function(err, fd) {
// Copy fixtures to temp.
common.refreshTmpDir();
fs.copyFileSync(fileFixture, fileTemp);
fs.open(fileFixture, 'a', 0o777, common.mustCall(function(err, fd) {
assert.ifError(err);
fs.fdatasyncSync(fd);