Skip to content

Commit

Permalink
test: skip test-fs-access if root
Browse files Browse the repository at this point in the history
Currently, if this test is run as the root user the following
failure will occur:

=== release test-fs-access ===
Path: parallel/test-fs-access
(node:46733) internal/test/binding: These APIs are for internal testing
only. Do not use them.
Can't clean tmpdir: /root/node/test/.tmp.522
Files blocking: [ 'read_only_file', 'read_write_file' ]

/root/node/test/common/tmpdir.js:136
    throw e;
    ^

Error: EACCES: permission denied, rmdir '/root/node/test/.tmp.522'
    at Object.rmdirSync (fs.js:693:3)
    at rmdirSync (/root/node/test/common/tmpdir.js:72:8)
    at rimrafSync (/root/node/test/common/tmpdir.js:41:7)
    at process.onexit (/root/node/test/common/tmpdir.js:121:5)
    at process.emit (events.js:214:15) {
  errno: -13,
  syscall: 'rmdir',
  code: 'EACCES',
  path: '/root/node/test/.tmp.522'
}
Command: ./node --expose-internals test/parallel/test-fs-access.js

This commit adds a root user check and skips this test if running as the
user root.

PR-URL: #29092
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
  • Loading branch information
danbev authored and targos committed Aug 19, 2019
1 parent c7a4525 commit 0aa339e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/parallel/test-fs-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// and the errors thrown from these APIs include the desired properties

const common = require('../common');
if (!common.isWindows && process.getuid() === 0)
common.skip('as this test should not be run as `root`');

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

0 comments on commit 0aa339e

Please sign in to comment.