Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

race.js 972B

12345678910111213141516171819202122232425262728293031323334353637
  1. var mkdirp = require('../').mkdirp;
  2. var path = require('path');
  3. var fs = require('fs');
  4. var exists = fs.exists || path.exists;
  5. var test = require('tap').test;
  6. var _0777 = parseInt('0777', 8);
  7. var _0755 = parseInt('0755', 8);
  8. test('race', function (t) {
  9. t.plan(10);
  10. var ps = [ '', 'tmp' ];
  11. for (var i = 0; i < 25; i++) {
  12. var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
  13. ps.push(dir);
  14. }
  15. var file = ps.join('/');
  16. var res = 2;
  17. mk(file);
  18. mk(file);
  19. function mk (file, cb) {
  20. mkdirp(file, _0755, function (err) {
  21. t.ifError(err);
  22. exists(file, function (ex) {
  23. t.ok(ex, 'file created');
  24. fs.stat(file, function (err, stat) {
  25. t.ifError(err);
  26. t.equal(stat.mode & _0777, _0755);
  27. t.ok(stat.isDirectory(), 'target not a directory');
  28. });
  29. })
  30. });
  31. }
  32. });