(mode, asString)
| 20 | tmpdir.refresh(); |
| 21 | |
| 22 | function test(mode, asString) { |
| 23 | const suffix = asString ? 'str' : 'num'; |
| 24 | const input = asString ? |
| 25 | (mode | maskToIgnore).toString(8) : (mode | maskToIgnore); |
| 26 | |
| 27 | { |
| 28 | const file = tmpdir.resolve(`chmod-async-${suffix}.txt`); |
| 29 | fs.writeFileSync(file, 'test', 'utf-8'); |
| 30 | |
| 31 | fs.chmod(file, input, common.mustSucceed(() => { |
| 32 | assert.strictEqual(fs.statSync(file).mode & 0o777, mode); |
| 33 | })); |
| 34 | } |
| 35 | |
| 36 | { |
| 37 | const file = tmpdir.resolve(`chmodSync-${suffix}.txt`); |
| 38 | fs.writeFileSync(file, 'test', 'utf-8'); |
| 39 | |
| 40 | fs.chmodSync(file, input); |
| 41 | assert.strictEqual(fs.statSync(file).mode & 0o777, mode); |
| 42 | } |
| 43 | |
| 44 | { |
| 45 | const file = tmpdir.resolve(`fchmod-async-${suffix}.txt`); |
| 46 | fs.writeFileSync(file, 'test', 'utf-8'); |
| 47 | fs.open(file, 'w', common.mustSucceed((fd) => { |
| 48 | fs.fchmod(fd, input, common.mustSucceed(() => { |
| 49 | assert.strictEqual(fs.fstatSync(fd).mode & 0o777, mode); |
| 50 | fs.close(fd, assert.ifError); |
| 51 | })); |
| 52 | })); |
| 53 | } |
| 54 | |
| 55 | { |
| 56 | const file = tmpdir.resolve(`fchmodSync-${suffix}.txt`); |
| 57 | fs.writeFileSync(file, 'test', 'utf-8'); |
| 58 | const fd = fs.openSync(file, 'w'); |
| 59 | |
| 60 | fs.fchmodSync(fd, input); |
| 61 | assert.strictEqual(fs.fstatSync(fd).mode & 0o777, mode); |
| 62 | |
| 63 | fs.close(fd, assert.ifError); |
| 64 | } |
| 65 | |
| 66 | if (fs.lchmod) { |
| 67 | const link = tmpdir.resolve(`lchmod-src-${suffix}`); |
| 68 | const file = tmpdir.resolve(`lchmod-dest-${suffix}`); |
| 69 | fs.writeFileSync(file, 'test', 'utf-8'); |
| 70 | fs.symlinkSync(file, link); |
| 71 | |
| 72 | fs.lchmod(link, input, common.mustSucceed(() => { |
| 73 | assert.strictEqual(fs.lstatSync(link).mode & 0o777, mode); |
| 74 | })); |
| 75 | } |
| 76 | |
| 77 | if (fs.lchmodSync) { |
| 78 | const link = tmpdir.resolve(`lchmodSync-src-${suffix}`); |
| 79 | const file = tmpdir.resolve(`lchmodSync-dest-${suffix}`); |
no test coverage detected
searching dependent graphs…