node/test/simple/test-mkdir-rmdir.js

34 lines
760 B
JavaScript
Raw Normal View History

2010-12-05 07:20:34 +08:00
var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
2009-09-04 17:46:31 +08:00
var dirname = path.dirname(__filename);
var d = path.join(common.tmpDir, 'dir');
2009-09-04 17:46:31 +08:00
var mkdir_error = false;
var rmdir_error = false;
fs.mkdir(d, 0666, function(err) {
2010-02-20 08:02:30 +08:00
if (err) {
console.log('mkdir error: ' + err.message);
2010-02-20 08:02:30 +08:00
mkdir_error = true;
} else {
console.log('mkdir okay!');
fs.rmdir(d, function(err) {
2010-02-20 08:02:30 +08:00
if (err) {
console.log('rmdir error: ' + err.message);
2010-02-20 08:02:30 +08:00
rmdir_error = true;
} else {
console.log('rmdir okay!');
2010-02-20 08:02:30 +08:00
}
});
}
2009-09-04 17:46:31 +08:00
});
process.addListener('exit', function() {
assert.equal(false, mkdir_error);
assert.equal(false, rmdir_error);
console.log('exit');
2009-09-04 17:46:31 +08:00
});