| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Test for a race condition that can occur when recursively creating | 5 // Test for a race condition that can occur when recursively creating |
| 6 // a directory multiple times simultaneously. This consistently reproduces | 6 // a directory multiple times simultaneously. This consistently reproduces |
| 7 // issue https://code.google.com/p/dart/issues/detail?id=7679 in revisions | 7 // issue https://code.google.com/p/dart/issues/detail?id=7679 in revisions |
| 8 // without the fix for this issue. | 8 // without the fix for this issue. |
| 9 | 9 |
| 10 import "dart:async"; | 10 import "dart:async"; |
| 11 import "dart:io"; | 11 import "dart:io"; |
| 12 import "dart:isolate"; | 12 import "dart:isolate"; |
| 13 | 13 |
| 14 void testCreateRecursiveRace() { | 14 void testCreateRecursiveRace() { |
| 15 var keepAlive = new ReceivePort(); | 15 var keepAlive = new ReceivePort(); |
| 16 var temp = new Directory('').createTempSync(); | 16 var temp = new Directory('').createTempSync(); |
| 17 var d = new Directory('${temp.path}/a/b/c/d/e'); | 17 var d = new Directory('${temp.path}/a/b/c/d/e'); |
| 18 Futures.wait([ | 18 Future.wait([ |
| 19 d.create(recursive: true), | 19 d.create(recursive: true), |
| 20 d.create(recursive: true), | 20 d.create(recursive: true), |
| 21 d.create(recursive: true), | 21 d.create(recursive: true), |
| 22 d.create(recursive: true), | 22 d.create(recursive: true), |
| 23 d.create(recursive: true), | 23 d.create(recursive: true), |
| 24 d.create(recursive: true), | 24 d.create(recursive: true), |
| 25 d.create(recursive: true), | 25 d.create(recursive: true), |
| 26 d.create(recursive: true), | 26 d.create(recursive: true), |
| 27 d.create(recursive: true), | 27 d.create(recursive: true), |
| 28 d.create(recursive: true)]).then((_) { | 28 d.create(recursive: true)]).then((_) { |
| 29 Expect.isTrue(new Directory('${temp.path}/a').existsSync()); | 29 Expect.isTrue(new Directory('${temp.path}/a').existsSync()); |
| 30 Expect.isTrue(new Directory('${temp.path}/a/b').existsSync()); | 30 Expect.isTrue(new Directory('${temp.path}/a/b').existsSync()); |
| 31 Expect.isTrue(new Directory('${temp.path}/a/b/c').existsSync()); | 31 Expect.isTrue(new Directory('${temp.path}/a/b/c').existsSync()); |
| 32 Expect.isTrue(new Directory('${temp.path}/a/b/c/d').existsSync()); | 32 Expect.isTrue(new Directory('${temp.path}/a/b/c/d').existsSync()); |
| 33 Expect.isTrue(new Directory('${temp.path}/a/b/c/d/e').existsSync()); | 33 Expect.isTrue(new Directory('${temp.path}/a/b/c/d/e').existsSync()); |
| 34 temp.delete(recursive: true).then((_) { | 34 temp.delete(recursive: true).then((_) { |
| 35 keepAlive.close(); | 35 keepAlive.close(); |
| 36 }); | 36 }); |
| 37 }); | 37 }); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void main() { | 40 void main() { |
| 41 testCreateRecursiveRace(); | 41 testCreateRecursiveRace(); |
| 42 testCreateRecursiveRace(); | 42 testCreateRecursiveRace(); |
| 43 } | 43 } |
| OLD | NEW |