From ea74b1a4bccc4a1db823ac8310ae028a4887d320 Mon Sep 17 00:00:00 2001 From: atvoicu Date: Thu, 21 Sep 2017 11:13:37 -0700 Subject: [PATCH] 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 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- test/parallel/test-fs-fsync.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-fs-fsync.js b/test/parallel/test-fs-fsync.js index 006ec3fcc0..3f43dd7545 100644 --- a/test/parallel/test-fs-fsync.js +++ b/test/parallel/test-fs-fsync.js @@ -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);