test: do not modify fixtures in test-fs-chmod · nodejs/node@644d990

@@ -50,14 +50,17 @@ if (common.isWindows) {

5050

mode_sync = 0o644;

5151

}

525253-

const file1 = path.join(common.fixturesDir, 'a.js');

54-

const file2 = path.join(common.fixturesDir, 'a1.js');

53+

common.refreshTmpDir();

54+55+

const file1 = path.join(common.tmpDir, 'a.js');

56+

const file2 = path.join(common.tmpDir, 'a1.js');

57+58+

// Create file1.

59+

fs.closeSync(fs.openSync(file1, 'w'));

55605661

fs.chmod(file1, mode_async.toString(8), common.mustCall((err) => {

5762

assert.ifError(err);

586359-

console.log(fs.statSync(file1).mode);

60-6164

if (common.isWindows) {

6265

assert.ok((fs.statSync(file1).mode & 0o777) & mode_async);

6366

} else {

@@ -72,14 +75,12 @@ fs.chmod(file1, mode_async.toString(8), common.mustCall((err) => {

7275

}

7376

}));

747775-

fs.open(file2, 'a', common.mustCall((err, fd) => {

78+

fs.open(file2, 'w', common.mustCall((err, fd) => {

7679

assert.ifError(err);

77807881

fs.fchmod(fd, mode_async.toString(8), common.mustCall((err) => {

7982

assert.ifError(err);

808381-

console.log(fs.fstatSync(fd).mode);

82-8384

if (common.isWindows) {

8485

assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_async);

8586

} else {

@@ -101,13 +102,11 @@ fs.open(file2, 'a', common.mustCall((err, fd) => {

101102

if (fs.lchmod) {

102103

const link = path.join(common.tmpDir, 'symbolic-link');

103104104-

common.refreshTmpDir();

105105

fs.symlinkSync(file2, link);

106106107107

fs.lchmod(link, mode_async, common.mustCall((err) => {

108108

assert.ifError(err);

109109110-

console.log(fs.lstatSync(link).mode);

111110

assert.strictEqual(mode_async, fs.lstatSync(link).mode & 0o777);

112111113112

fs.lchmodSync(link, mode_sync);