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 // TODO(nweiz): This is under lib so that it can be used by the unittest dummy | 5 // TODO(nweiz): This is under lib so that it can be used by the unittest dummy |
6 // package. Once that package is no longer being updated, move this back into | 6 // package. Once that package is no longer being updated, move this back into |
7 // bin. | 7 // bin. |
8 library test.executable; | 8 library test.executable; |
9 | 9 |
10 import 'dart:io'; | 10 import 'dart:io'; |
11 | 11 |
12 import 'package:stack_trace/stack_trace.dart'; | 12 import 'package:stack_trace/stack_trace.dart'; |
13 import 'package:yaml/yaml.dart'; | 13 import 'package:yaml/yaml.dart'; |
14 | 14 |
15 import 'runner.dart'; | 15 import 'runner.dart'; |
16 import 'runner/application_exception.dart'; | 16 import 'runner/application_exception.dart'; |
17 import 'runner/configuration.dart'; | 17 import 'runner/configuration.dart'; |
18 import 'util/exit_codes.dart' as exit_codes; | 18 import 'util/exit_codes.dart' as exit_codes; |
| 19 import 'util/io.dart'; |
19 import 'utils.dart'; | 20 import 'utils.dart'; |
20 | 21 |
21 /// A merged stream of all signals that tell the test runner to shut down | 22 /// A merged stream of all signals that tell the test runner to shut down |
22 /// gracefully. | 23 /// gracefully. |
23 /// | 24 /// |
24 /// Signals will only be captured as long as this has an active subscription. | 25 /// Signals will only be captured as long as this has an active subscription. |
25 /// Otherwise, they'll be handled by Dart's default signal handler, which | 26 /// Otherwise, they'll be handled by Dart's default signal handler, which |
26 /// terminates the program immediately. | 27 /// terminates the program immediately. |
27 final _signals = Platform.isWindows | 28 final _signals = Platform.isWindows |
28 ? ProcessSignal.SIGINT.watch() | 29 ? ProcessSignal.SIGINT.watch() |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 return; | 103 return; |
103 } | 104 } |
104 | 105 |
105 var runner = new Runner(configuration); | 106 var runner = new Runner(configuration); |
106 | 107 |
107 var signalSubscription; | 108 var signalSubscription; |
108 close() async { | 109 close() async { |
109 if (signalSubscription == null) return; | 110 if (signalSubscription == null) return; |
110 signalSubscription.cancel(); | 111 signalSubscription.cancel(); |
111 signalSubscription = null; | 112 signalSubscription = null; |
| 113 stdinLines.cancel(immediate: true); |
112 await runner.close(); | 114 await runner.close(); |
113 } | 115 } |
114 | 116 |
115 signalSubscription = _signals.listen((_) => close()); | 117 signalSubscription = _signals.listen((_) => close()); |
116 | 118 |
117 try { | 119 try { |
118 exitCode = (await runner.run()) ? 0 : 1; | 120 exitCode = (await runner.run()) ? 0 : 1; |
119 } on ApplicationException catch (error) { | 121 } on ApplicationException catch (error) { |
120 stderr.writeln(error.message); | 122 stderr.writeln(error.message); |
121 exitCode = exit_codes.data; | 123 exitCode = exit_codes.data; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (description is! Map) return false; | 205 if (description is! Map) return false; |
204 var path = description["path"]; | 206 var path = description["path"]; |
205 if (path is! String) return false; | 207 if (path is! String) return false; |
206 | 208 |
207 print("$version (from $path)"); | 209 print("$version (from $path)"); |
208 return true; | 210 return true; |
209 | 211 |
210 default: return false; | 212 default: return false; |
211 } | 213 } |
212 } | 214 } |
OLD | NEW |