-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix chmod mask testing on windows
Currently this uncovers a regression in `fs.fchmodSync(fd, mode_sync);` No solution yet... Also as issue on macOS in test-fs-chmod:94 fail to access file1 Fixes:#12803
- Loading branch information
Showing
3 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
// Windows only: Test fchmod on files with `attrib -a -h -i -r -s` | ||
// setting RO then can't set RW back | ||
|
||
const {strictEqual, ok} = require('assert'); | ||
const {execSync} = require('child_process'); | ||
const fs = require('fs'); | ||
|
||
ok(common.isWindows, 'reset of test only for windows'); | ||
|
||
process.on('exit', function() { | ||
console.log('Trying to cleanup'); | ||
try { | ||
execSync(`del /q /f ${tmpFile}`); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}); | ||
|
||
const RO = 0o100444; // 33060 0b1000000100100100 | ||
const RW = 0o100666; // 33206 0b1000000110110110 | ||
|
||
const tmpFile = `${common.tmpDir}\\${Date.now()}gigi.js`; | ||
|
||
const fd = fs.openSync(tmpFile, 'a'); | ||
execSync(`attrib -a -h -i -r -s ${tmpFile}`); | ||
fs.fchmodSync(fd, RO); | ||
const actual2 = fs.fstatSync(fd).mode; | ||
console.log(`${tmpFile} mode: ${actual2}`); | ||
strictEqual(actual2, RO); | ||
|
||
fs.fchmodSync(fd, RW); // This does not work. | ||
const actual3 = fs.fstatSync(fd).mode; | ||
console.log(`${tmpFile} mode: ${actual3}`); | ||
strictEqual(actual3, RW); // BANG! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters