From c339931d8b3dbf3fb2a4fa4164bbf585759831c0 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 21 Dec 2017 14:46:46 -0800 Subject: [PATCH] test: do not open fixture files for writing Use temp directory for open with `O_DSYNC` (which indicates a write may occur) rather than `fixtures` directory. Additionally, test can be run on macOS so allow that in addition to Linux. PR-URL: https://github.com/nodejs/node/pull/17810 Reviewed-By: Colin Ihrig Reviewed-By: Jon Moss Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- test/parallel/test-fs-open-flags.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-fs-open-flags.js b/test/parallel/test-fs-open-flags.js index c73dbb5c6ed4c3..aa87f8ced8793e 100644 --- a/test/parallel/test-fs-open-flags.js +++ b/test/parallel/test-fs-open-flags.js @@ -22,10 +22,12 @@ // Flags: --expose_internals 'use strict'; const common = require('../common'); + const fixtures = require('../common/fixtures'); -const assert = require('assert'); +const assert = require('assert'); const fs = require('fs'); +const path = require('path'); const O_APPEND = fs.constants.O_APPEND || 0; const O_CREAT = fs.constants.O_CREAT || 0; @@ -81,8 +83,9 @@ common.expectsError( { code: 'ERR_INVALID_OPT_VALUE', type: TypeError } ); -if (common.isLinux) { - const file = fixtures.path('a.js'); - +if (common.isLinux || common.isOSX) { + common.refreshTmpDir(); + const file = path.join(common.tmpDir, 'a.js'); + fs.copyFileSync(fixtures.path('a.js'), file); fs.open(file, O_DSYNC, common.mustCall(assert.ifError)); }