Browse Source

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.
v0.7.4-release
Bert Belder 13 years ago
parent
commit
236b217cd7
  1. 25
      test/simple/test-fs-chmod.js

25
test/simple/test-fs-chmod.js

@ -65,38 +65,39 @@ function closeSync() {
// On Windows chmod is only able to manipulate read-only bit // On Windows chmod is only able to manipulate read-only bit
if (is_windows) { if (is_windows) {
mode_async = 0600; // read-write mode_async = 0400; // read-only
mode_sync = 0400; // read-only mode_sync = 0600; // read-write
} else { } else {
mode_async = 0777; mode_async = 0777;
mode_sync = 0644; 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) { if (err) {
got_error = true; got_error = true;
} else { } else {
console.log(fs.statSync(file).mode); console.log(fs.statSync(file1).mode);
if (is_windows) { if (is_windows) {
assert.ok((fs.statSync(file).mode & 0777) & mode_async); assert.ok((fs.statSync(file1).mode & 0777) & mode_async);
} else { } 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) { if (is_windows) {
assert.ok((fs.statSync(file).mode & 0777) & mode_sync); assert.ok((fs.statSync(file1).mode & 0777) & mode_sync);
} else { } else {
assert.equal(mode_sync, fs.statSync(file).mode & 0777); assert.equal(mode_sync, fs.statSync(file1).mode & 0777);
} }
success_count++; success_count++;
} }
}); });
fs.open(file, 'a', function(err, fd) { fs.open(file2, 'a', function(err, fd) {
if (err) { if (err) {
got_error = true; got_error = true;
console.error(err.stack); console.error(err.stack);
@ -133,7 +134,7 @@ if (fs.lchmod) {
try { try {
fs.unlinkSync(link); fs.unlinkSync(link);
} catch (er) {} } catch (er) {}
fs.symlinkSync(file, link); fs.symlinkSync(file2, link);
fs.lchmod(link, mode_async, function(err) { fs.lchmod(link, mode_async, function(err) {
if (err) { if (err) {

Loading…
Cancel
Save