Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fix issues with test-fs-chmod
Browse files Browse the repository at this point in the history
- The test simultaneously chmods and fchmods the same file.
- On windows, it leaves behind a fixture in read-only mode,
  which causes test-fs-fsync to fail.
  • Loading branch information
piscisaureus committed Nov 25, 2011
1 parent d51a0c3 commit 236b217
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions test/simple/test-fs-chmod.js
Expand Up @@ -65,38 +65,39 @@ function closeSync() {

// On Windows chmod is only able to manipulate read-only bit
if (is_windows) {
mode_async = 0600; // read-write
mode_sync = 0400; // read-only
mode_async = 0400; // read-only
mode_sync = 0600; // read-write
} else {
mode_async = 0777;
mode_sync = 0644;
}

var file = path.join(common.fixturesDir, 'a.js');
var file1 = path.join(common.fixturesDir, 'a.js'),
file2 = path.join(common.fixturesDir, 'a1.js');

fs.chmod(file, mode_async.toString(8), function(err) {
fs.chmod(file1, mode_async.toString(8), function(err) {
if (err) {
got_error = true;
} else {
console.log(fs.statSync(file).mode);
console.log(fs.statSync(file1).mode);

if (is_windows) {
assert.ok((fs.statSync(file).mode & 0777) & mode_async);
assert.ok((fs.statSync(file1).mode & 0777) & mode_async);
} else {
assert.equal(mode_async, fs.statSync(file).mode & 0777);
assert.equal(mode_async, fs.statSync(file1).mode & 0777);
}

fs.chmodSync(file, mode_sync);
fs.chmodSync(file1, mode_sync);
if (is_windows) {
assert.ok((fs.statSync(file).mode & 0777) & mode_sync);
assert.ok((fs.statSync(file1).mode & 0777) & mode_sync);
} else {
assert.equal(mode_sync, fs.statSync(file).mode & 0777);
assert.equal(mode_sync, fs.statSync(file1).mode & 0777);
}
success_count++;
}
});

fs.open(file, 'a', function(err, fd) {
fs.open(file2, 'a', function(err, fd) {
if (err) {
got_error = true;
console.error(err.stack);
Expand Down Expand Up @@ -133,7 +134,7 @@ if (fs.lchmod) {
try {
fs.unlinkSync(link);
} catch (er) {}
fs.symlinkSync(file, link);
fs.symlinkSync(file2, link);

fs.lchmod(link, mode_async, function(err) {
if (err) {
Expand Down

0 comments on commit 236b217

Please sign in to comment.