diff options
author | Rich Trott <rtrott@gmail.com> | 2019-03-26 23:32:20 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-03-29 19:17:16 -0700 |
commit | 30e884f4f4692cc327b0ff5b3228eec88f270773 (patch) | |
tree | b45526b367a704f8cfa94a4478d437e032bb3eb2 /test/known_issues | |
parent | dd9cad9cb34f37ad47bf67996118efbc07787a2b (diff) | |
download | android-node-v8-30e884f4f4692cc327b0ff5b3228eec88f270773.tar.gz android-node-v8-30e884f4f4692cc327b0ff5b3228eec88f270773.tar.bz2 android-node-v8-30e884f4f4692cc327b0ff5b3228eec88f270773.zip |
test: add known_issues test for fs.copyFile()
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: https://github.com/nodejs/node/issues/26936
Ref: https://github.com/libuv/libuv/pull/2233
PR-URL: https://github.com/nodejs/node/pull/26939
Refs: https://github.com/nodejs/node/issues/26936
Refs: https://github.com/libuv/libuv/pull/2233
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'test/known_issues')
-rw-r--r-- | test/known_issues/known_issues.status | 6 | ||||
-rw-r--r-- | test/known_issues/test-fs-copyfile-respect-permissions.js | 50 |
2 files changed, 56 insertions, 0 deletions
diff --git a/test/known_issues/known_issues.status b/test/known_issues/known_issues.status index 3463f0a0ec..d7e0b546d4 100644 --- a/test/known_issues/known_issues.status +++ b/test/known_issues/known_issues.status @@ -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 diff --git a/test/known_issues/test-fs-copyfile-respect-permissions.js b/test/known_issues/test-fs-copyfile-respect-permissions.js new file mode 100644 index 0000000000..0ebc5fbfc1 --- /dev/null +++ b/test/known_issues/test-fs-copyfile-respect-permissions.js @@ -0,0 +1,50 @@ +'use strict'; + +// Test that fs.copyFile() respects file permissions. +// Ref: https://github.com/nodejs/node/issues/26936 + +const common = require('../common'); + +const tmpdir = require('../common/tmpdir'); +tmpdir.refresh(); + +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); + +let n = 0; + +function beforeEach() { + n++; + const source = path.join(tmpdir.path, `source${n}`); + const dest = path.join(tmpdir.path, `dest${n}`); + fs.writeFileSync(source, 'source'); + fs.writeFileSync(dest, 'dest'); + fs.chmodSync(dest, '444'); + + const check = (err) => { + assert.strictEqual(err.code, 'EACCESS'); + assert.strictEqual(fs.readFileSync(dest, 'utf8'), 'dest'); + }; + + return { source, dest, check }; +} + +// Test synchronous API. +{ + const { source, dest, check } = beforeEach(); + assert.throws(() => { fs.copyFileSync(source, dest); }, check); +} + +// Test promises API. +{ + const { source, dest, check } = beforeEach(); + assert.throws(async () => { await fs.promises.copyFile(source, dest); }, + check); +} + +// Test callback API. +{ + const { source, dest, check } = beforeEach(); + fs.copyFile(source, dest, common.mustCall(check)); +} |