| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:convert'; | 6 import 'dart:convert'; |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
| 9 | 9 |
| 10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // TODO(nweiz): Make this check [stdioType] once that works within "pub run". | 63 // TODO(nweiz): Make this check [stdioType] once that works within "pub run". |
| 64 /// Whether "special" strings such as Unicode characters or color escapes are | 64 /// Whether "special" strings such as Unicode characters or color escapes are |
| 65 /// safe to use. | 65 /// safe to use. |
| 66 /// | 66 /// |
| 67 /// On Windows or when not printing to a terminal, only printable ASCII | 67 /// On Windows or when not printing to a terminal, only printable ASCII |
| 68 /// characters should be used. | 68 /// characters should be used. |
| 69 bool get canUseSpecialChars => | 69 bool get canUseSpecialChars => |
| 70 Platform.operatingSystem != 'windows' && !inTestTests; | 70 Platform.operatingSystem != 'windows' && !inTestTests; |
| 71 | 71 |
| 72 /// Creates a temporary directory and returns its path. | 72 /// Creates a temporary directory and returns its path. |
| 73 String createTempDir() => | 73 String createTempDir() => new Directory(_tempDir) |
| 74 new Directory(_tempDir).createTempSync('dart_test_').path; | 74 .createTempSync('dart_test_').resolveSymbolicLinksSync(); |
| 75 | 75 |
| 76 /// Creates a temporary directory and passes its path to [fn]. | 76 /// Creates a temporary directory and passes its path to [fn]. |
| 77 /// | 77 /// |
| 78 /// Once the [Future] returned by [fn] completes, the temporary directory and | 78 /// Once the [Future] returned by [fn] completes, the temporary directory and |
| 79 /// all its contents are deleted. [fn] can also return `null`, in which case | 79 /// all its contents are deleted. [fn] can also return `null`, in which case |
| 80 /// the temporary directory is deleted immediately afterwards. | 80 /// the temporary directory is deleted immediately afterwards. |
| 81 /// | 81 /// |
| 82 /// Returns a future that completes to the value that the future returned from | 82 /// Returns a future that completes to the value that the future returned from |
| 83 /// [fn] completes to. | 83 /// [fn] completes to. |
| 84 Future withTempDir(Future fn(String path)) { | 84 Future withTempDir(Future fn(String path)) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 /// | 175 /// |
| 176 /// This has a built-in race condition: another process may bind this port at | 176 /// This has a built-in race condition: another process may bind this port at |
| 177 /// any time after this call has returned. If at all possible, callers should | 177 /// any time after this call has returned. If at all possible, callers should |
| 178 /// use [getUnusedPort] instead. | 178 /// use [getUnusedPort] instead. |
| 179 Future<int> getUnsafeUnusedPort() async { | 179 Future<int> getUnsafeUnusedPort() async { |
| 180 var socket = await RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0); | 180 var socket = await RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0); |
| 181 var port = socket.port; | 181 var port = socket.port; |
| 182 await socket.close(); | 182 await socket.close(); |
| 183 return port; | 183 return port; |
| 184 } | 184 } |
| OLD | NEW |