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');