| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library unittest.io; | 5 library unittest.util.io; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
| 11 | 11 |
| 12 /// Returns whether the current Dart version supports [Isolate.kill]. | 12 /// Returns whether the current Dart version supports [Isolate.kill]. |
| 13 final bool supportsIsolateKill = _supportsIsolateKill; | 13 final bool supportsIsolateKill = _supportsIsolateKill; |
| 14 bool get _supportsIsolateKill { | 14 bool get _supportsIsolateKill { |
| 15 // This isn't 100% accurate, since early 1.9 dev releases didn't support | 15 // This isn't 100% accurate, since early 1.9 dev releases didn't support |
| (...skipping 30 matching lines...) Expand all Loading... |
| 46 /// [fn] completes to. | 46 /// [fn] completes to. |
| 47 Future withTempDir(Future fn(String path)) { | 47 Future withTempDir(Future fn(String path)) { |
| 48 return new Future.sync(() { | 48 return new Future.sync(() { |
| 49 // TODO(nweiz): Empirically test whether sync or async functions perform | 49 // TODO(nweiz): Empirically test whether sync or async functions perform |
| 50 // better here when starting a bunch of isolates. | 50 // better here when starting a bunch of isolates. |
| 51 var tempDir = Directory.systemTemp.createTempSync('unittest_'); | 51 var tempDir = Directory.systemTemp.createTempSync('unittest_'); |
| 52 return new Future.sync(() => fn(tempDir.path)) | 52 return new Future.sync(() => fn(tempDir.path)) |
| 53 .whenComplete(() => tempDir.deleteSync(recursive: true)); | 53 .whenComplete(() => tempDir.deleteSync(recursive: true)); |
| 54 }); | 54 }); |
| 55 } | 55 } |
| OLD | NEW |