Skip to content

Commit

Permalink
test: update test-fs-fsync to run from temp
Browse files Browse the repository at this point in the history
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: #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>
  • Loading branch information
atvoicu authored and jasnell committed Sep 25, 2017
1 parent 29f0ad6 commit 0503c44
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/parallel/test-fs-fsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0503c44

Please sign in to comment.