mirror of
https://github.com/jprichardson/node-fs-extra.git
synced 2026-01-25 16:42:57 +00:00
test/mkdirp: more fixes for windows tests
This commit is contained in:
parent
ed2d4c32dc
commit
cf3c44e55f
@ -9,6 +9,7 @@ var fse = require('../../')
|
||||
var o755 = parseInt('755', 8)
|
||||
var o744 = parseInt('744', 8)
|
||||
var o777 = parseInt('777', 8)
|
||||
var o666 = parseInt('666', 8)
|
||||
|
||||
describe('mkdirp / chmod', function () {
|
||||
var TEST_DIR
|
||||
@ -40,7 +41,13 @@ describe('mkdirp / chmod', function () {
|
||||
fs.stat(TEST_SUBDIR, function (er, stat) {
|
||||
assert.ifError(er, 'should exist')
|
||||
assert.ok(stat && stat.isDirectory(), 'should be directory')
|
||||
assert.equal(stat && stat.mode & o777, mode, 'should be 0744')
|
||||
|
||||
if (os.platform().indexOf('win') === 0) {
|
||||
assert.equal(stat && stat.mode & o777, o666, 'windows shit')
|
||||
} else {
|
||||
assert.equal(stat && stat.mode & o777, mode, 'should be 0744')
|
||||
}
|
||||
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
@ -8,6 +8,7 @@ var fse = require(process.cwd())
|
||||
|
||||
var o755 = parseInt('755', 8)
|
||||
var o777 = parseInt('777', 8)
|
||||
var o666 = parseInt('666', 8)
|
||||
|
||||
describe('mkdirp / mkdirp', function () {
|
||||
var TEST_DIR
|
||||
@ -26,7 +27,7 @@ describe('mkdirp / mkdirp', function () {
|
||||
var y = Math.floor(Math.random() * Math.pow(16, 4)).toString(16)
|
||||
var z = Math.floor(Math.random() * Math.pow(16, 4)).toString(16)
|
||||
|
||||
var file = TEST_DIR + [x, y, z].join(path.sep)
|
||||
var file = path.join(TEST_DIR, x, y, z)
|
||||
|
||||
fse.mkdirp(file, o755, function (err) {
|
||||
assert.ifError(err)
|
||||
@ -34,7 +35,13 @@ describe('mkdirp / mkdirp', function () {
|
||||
assert.ok(ex, 'file created')
|
||||
fs.stat(file, function (err, stat) {
|
||||
assert.ifError(err)
|
||||
assert.equal(stat.mode & o777, o755)
|
||||
|
||||
if (os.platform().indexOf('win') === 0) {
|
||||
assert.equal(stat.mode & o777, o666)
|
||||
} else {
|
||||
assert.equal(stat.mode & o777, o755)
|
||||
}
|
||||
|
||||
assert.ok(stat.isDirectory(), 'target not a directory')
|
||||
done()
|
||||
})
|
||||
|
||||
@ -8,6 +8,7 @@ var fse = require('../../')
|
||||
|
||||
var o755 = parseInt('755', 8)
|
||||
var o777 = parseInt('777', 8)
|
||||
var o666 = parseInt('666', 8)
|
||||
|
||||
describe('mkdirp / perm', function () {
|
||||
var TEST_DIR
|
||||
@ -30,7 +31,13 @@ describe('mkdirp / perm', function () {
|
||||
assert.ok(ex, 'file created')
|
||||
fs.stat(file, function (err, stat) {
|
||||
assert.ifError(err)
|
||||
assert.equal(stat.mode & o777, o755)
|
||||
|
||||
if (os.platform().indexOf('win') === 0) {
|
||||
assert.equal(stat.mode & o777, o666)
|
||||
} else {
|
||||
assert.equal(stat.mode & o777, o755)
|
||||
}
|
||||
|
||||
assert.ok(stat.isDirectory(), 'target not a directory')
|
||||
done()
|
||||
})
|
||||
|
||||
@ -8,6 +8,7 @@ var fse = require(process.cwd())
|
||||
|
||||
var o755 = parseInt('755', 8)
|
||||
var o777 = parseInt('777', 8)
|
||||
var o666 = parseInt('666', 8)
|
||||
|
||||
describe('mkdirp / perm_sync', function () {
|
||||
var TEST_DIR
|
||||
@ -29,7 +30,13 @@ describe('mkdirp / perm_sync', function () {
|
||||
assert.ok(ex, 'file created')
|
||||
fs.stat(file, function (err, stat) {
|
||||
assert.ifError(err)
|
||||
assert.equal(stat.mode & o777, o755)
|
||||
|
||||
if (os.platform().indexOf('win') === 0) {
|
||||
assert.equal(stat.mode & o777, o666)
|
||||
} else {
|
||||
assert.equal(stat.mode & o777, o755)
|
||||
}
|
||||
|
||||
assert.ok(stat.isDirectory(), 'target not a directory')
|
||||
done()
|
||||
})
|
||||
|
||||
@ -8,6 +8,7 @@ var fse = require(process.cwd())
|
||||
|
||||
var o755 = parseInt('755', 8)
|
||||
var o777 = parseInt('777', 8)
|
||||
var o666 = parseInt('666', 8)
|
||||
|
||||
describe('mkdirp / race', function () {
|
||||
var TEST_DIR, file
|
||||
@ -43,16 +44,22 @@ describe('mkdirp / race', function () {
|
||||
if (--res === 0) done()
|
||||
})
|
||||
|
||||
function mk (file, cb) {
|
||||
function mk (file, callback) {
|
||||
fse.mkdirp(file, o755, function (err) {
|
||||
assert.ifError(err)
|
||||
fs.exists(file, function (ex) {
|
||||
assert.ok(ex, 'file created')
|
||||
fs.stat(file, function (err, stat) {
|
||||
assert.ifError(err)
|
||||
assert.equal(stat.mode & o777, o755)
|
||||
|
||||
if (os.platform().indexOf('win') === 0) {
|
||||
assert.equal(stat.mode & o777, o666)
|
||||
} else {
|
||||
assert.equal(stat.mode & o777, o755)
|
||||
}
|
||||
|
||||
assert.ok(stat.isDirectory(), 'target not a directory')
|
||||
if (cb) cb()
|
||||
if (callback) callback()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -8,6 +8,7 @@ var fse = require(process.cwd())
|
||||
|
||||
var o755 = parseInt('755', 8)
|
||||
var o777 = parseInt('777', 8)
|
||||
var o666 = parseInt('666', 8)
|
||||
|
||||
describe('mkdirp / relative', function () {
|
||||
var TEST_DIR, file
|
||||
@ -42,8 +43,15 @@ describe('mkdirp / relative', function () {
|
||||
assert.ok(ex, 'file created')
|
||||
fs.stat(file, function (err, stat) {
|
||||
assert.ifError(err)
|
||||
// restore
|
||||
process.chdir(cwd)
|
||||
assert.equal(stat.mode & o777, o755)
|
||||
|
||||
if (os.platform().indexOf('win') === 0) {
|
||||
assert.equal(stat.mode & o777, o666)
|
||||
} else {
|
||||
assert.equal(stat.mode & o777, o755)
|
||||
}
|
||||
|
||||
assert.ok(stat.isDirectory(), 'target not a directory')
|
||||
done()
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user