Skip to content

Commit

Permalink
test: add known_issues test for fs.copyFile()
Browse files Browse the repository at this point in the history
On macOS, fs.copyFile() may not respect file permissions. There is a PR
for libuv that should fix this, but until it lands and we can either
float a patch or upgrade libuv, have a known_issues test.

Ref: nodejs#26936
Ref: libuv/libuv#2233
  • Loading branch information
Trott committed Mar 27, 2019
1 parent 6342af7 commit 1b8fcee
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/known_issues/known_issues.status
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ prefix known_issues
[true] # This section applies to all platforms

[$system==win32]
test-fs-copyfile-respect-permissions: SKIP

[$system==linux]
test-vm-timeout-escape-promise: PASS,FLAKY
test-fs-copyfile-respect-permissions: SKIP

[$system==macos]

[$system==solaris]
test-fs-copyfile-respect-permissions: SKIP

[$system==freebsd]
test-fs-copyfile-respect-permissions: SKIP

[$system==aix]
test-fs-copyfile-respect-permissions: SKIP

[$arch==arm]
# https://github.com/nodejs/node/issues/24120
test-vm-timeout-escape-nexttick: PASS,FLAKY
test-fs-copyfile-respect-permissions: SKIP
25 changes: 25 additions & 0 deletions test/known_issues/test-fs-copyfile-respect-permissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

// Test that fs.copyFile() respects file permissions.
// Ref: https://github.com/nodejs/node/issues/26936

require('../common');

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

const assert = require('assert');
const fs = require('fs');
const path = require('path');

const source = path.join(tmpdir.path, 'source');
const dest = path.join(tmpdir.path, 'dest');

fs.writeFileSync(source, 'source');
fs.writeFileSync(dest, 'dest');
fs.chmodSync(dest, '444');

fs.copyFile(source, dest, (err) => {
assert.strictEqual(err.code, 'EACCESS');
assert.strictEqual(fs.readFileSync(dest, 'utf8'), 'dest');
});

0 comments on commit 1b8fcee

Please sign in to comment.