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'; | |
7 import 'dart:io'; | 6 import 'dart:io'; |
8 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
9 | 8 |
10 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
11 import 'package:pub_semver/pub_semver.dart'; | 10 import 'package:pub_semver/pub_semver.dart'; |
12 | 11 |
13 import '../backend/operating_system.dart'; | 12 import '../backend/operating_system.dart'; |
14 import '../runner/application_exception.dart'; | 13 import '../runner/application_exception.dart'; |
15 import '../util/stream_queue.dart'; | 14 import '../util/stream_queue.dart'; |
16 import '../utils.dart'; | 15 import '../utils.dart'; |
(...skipping 15 matching lines...) Expand all Loading... |
32 /// Returns the current operating system. | 31 /// Returns the current operating system. |
33 final OperatingSystem currentOS = (() { | 32 final OperatingSystem currentOS = (() { |
34 var name = Platform.operatingSystem; | 33 var name = Platform.operatingSystem; |
35 var os = OperatingSystem.findByIoName(name); | 34 var os = OperatingSystem.findByIoName(name); |
36 if (os != null) return os; | 35 if (os != null) return os; |
37 | 36 |
38 throw new UnsupportedError('Unsupported operating system "$name".'); | 37 throw new UnsupportedError('Unsupported operating system "$name".'); |
39 })(); | 38 })(); |
40 | 39 |
41 /// A queue of lines of standard input. | 40 /// A queue of lines of standard input. |
42 final stdinLines = new StreamQueue( | 41 final stdinLines = new StreamQueue(lineSplitter.bind(stdin)); |
43 UTF8.decoder.fuse(const LineSplitter()).bind(stdin)); | |
44 | 42 |
45 /// Whether this is being run as a subprocess in the test package's own tests. | 43 /// Whether this is being run as a subprocess in the test package's own tests. |
46 bool inTestTests = Platform.environment["_DART_TEST_TESTING"] == "true"; | 44 bool inTestTests = Platform.environment["_DART_TEST_TESTING"] == "true"; |
47 | 45 |
48 /// The root directory below which to nest temporary directories created by the | 46 /// The root directory below which to nest temporary directories created by the |
49 /// test runner. | 47 /// test runner. |
50 /// | 48 /// |
51 /// This is configurable so that the test code can validate that the runner | 49 /// This is configurable so that the test code can validate that the runner |
52 /// cleans up after itself fully. | 50 /// cleans up after itself fully. |
53 final _tempDir = Platform.environment.containsKey("_UNITTEST_TEMP_DIR") | 51 final _tempDir = Platform.environment.containsKey("_UNITTEST_TEMP_DIR") |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 /// | 173 /// |
176 /// This has a built-in race condition: another process may bind this port at | 174 /// 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 | 175 /// any time after this call has returned. If at all possible, callers should |
178 /// use [getUnusedPort] instead. | 176 /// use [getUnusedPort] instead. |
179 Future<int> getUnsafeUnusedPort() async { | 177 Future<int> getUnsafeUnusedPort() async { |
180 var socket = await RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0); | 178 var socket = await RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0); |
181 var port = socket.port; | 179 var port = socket.port; |
182 await socket.close(); | 180 await socket.close(); |
183 return port; | 181 return port; |
184 } | 182 } |
OLD | NEW |