Skip to content

Commit

Permalink
test: do not open fixture files for writing
Browse files Browse the repository at this point in the history
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: #17810
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Trott authored and gibfahn committed Jan 24, 2018
1 parent 7f6780d commit 68fbe08
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/parallel/test-fs-open-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
// Flags: --expose_internals
'use strict';
const common = require('../common');

const fixtures = require('../common/fixtures');

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;
Expand Down Expand Up @@ -79,9 +83,10 @@ assert.throws(
/^Error: Unknown file open flag: null$/
);

if (common.isLinux) {
const file = `${__dirname}/../fixtures/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));
}

Expand Down

0 comments on commit 68fbe08

Please sign in to comment.