Permalink
Browse files

Fix issues with test-fs-chmod

- 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...
1 parent d51a0c3 commit 236b217cd705d03713c467b49d4c063f69187ddb @piscisaureus piscisaureus committed Nov 25, 2011
Showing with 13 additions and 12 deletions.
  1. +13 −12 test/simple/test-fs-chmod.js
@@ -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);
@@ -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) {

0 comments on commit 236b217

Please sign in to comment.