Skip to content

Commit 660c9df

Browse files
author
James Halliday
committed
failing test for sync umask
1 parent f74a1a0 commit 660c9df

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/umask_sync.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var mkdirp = require('../');
2+
var path = require('path');
3+
var fs = require('fs');
4+
var test = require('tap').test;
5+
6+
test('umask sync modes', function (t) {
7+
t.plan(2);
8+
var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
9+
var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
10+
var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
11+
12+
var file = '/tmp/' + [x,y,z].join('/');
13+
14+
var err = mkdirp.sync(file);
15+
if (err) t.fail(err);
16+
else path.exists(file, function (ex) {
17+
if (!ex) t.fail('file not created')
18+
else fs.stat(file, function (err, stat) {
19+
if (err) t.fail(err)
20+
else {
21+
t.equal(stat.mode & 0777, (0777 & (~process.umask())));
22+
t.ok(stat.isDirectory(), 'target not a directory');
23+
t.end();
24+
}
25+
})
26+
})
27+
});

0 commit comments

Comments
 (0)