]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/space-pen/node_modules/grim/node_modules/coffeestack/node_modules/fs-plus/node_modules/mkdirp/test/race.js
96a04476365e366ff6dd3df6dcc0c6da1998d845
1 var mkdirp
= require('../').mkdirp
;
2 var path
= require('path');
3 var fs
= require('fs');
4 var test
= require('tap').test
;
6 test('race', function (t
) {
8 var ps
= [ '', 'tmp' ];
10 for (var i
= 0; i
< 25; i
++) {
11 var dir
= Math
.floor(Math
.random() * Math
.pow(16,4)).toString(16);
14 var file
= ps
.join('/');
17 mk(file
, function () {
18 if (--res
=== 0) t
.end();
21 mk(file
, function () {
22 if (--res
=== 0) t
.end();
25 function mk (file
, cb
) {
26 mkdirp(file
, 0755, function (err
) {
28 else path
.exists(file
, function (ex
) {
29 if (!ex
) t
.fail('file not created')
30 else fs
.stat(file
, function (err
, stat
) {
33 t
.equal(stat
.mode
& 0777, 0755);
34 t
.ok(stat
.isDirectory(), 'target not a directory');