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 test.test.io; | 5 library test.test.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; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 /// Returns a [StreamMatcher] that asserts that the stream emits strings | 88 /// Returns a [StreamMatcher] that asserts that the stream emits strings |
89 /// containing each string in [strings] in order. | 89 /// containing each string in [strings] in order. |
90 /// | 90 /// |
91 /// This expects each string in [strings] to match a different string in the | 91 /// This expects each string in [strings] to match a different string in the |
92 /// stream. | 92 /// stream. |
93 StreamMatcher containsInOrder(Iterable<String> strings) => | 93 StreamMatcher containsInOrder(Iterable<String> strings) => |
94 inOrder(strings.map((string) => consumeThrough(contains(string)))); | 94 inOrder(strings.map((string) => consumeThrough(contains(string)))); |
95 | 95 |
96 /// Runs the test executable with the package root set properly. | 96 /// Runs the test executable with the package root set properly. |
97 ScheduledProcess runTest(List args, {bool compact: false, | 97 ScheduledProcess runTest(List args, {String reporter, |
98 int concurrency, Map<String, String> environment}) { | 98 int concurrency, Map<String, String> environment}) { |
99 if (concurrency == null) concurrency = 1; | 99 reporter ??= "expanded"; |
| 100 concurrency ??= 1; |
100 | 101 |
101 var allArgs = [ | 102 var allArgs = [ |
102 p.absolute(p.join(packageDir, 'bin/test.dart')), | 103 p.absolute(p.join(packageDir, 'bin/test.dart')), |
103 "--package-root=${p.join(packageDir, 'packages')}", | 104 "--package-root=${p.join(packageDir, 'packages')}", |
104 "--concurrency=$concurrency" | 105 "--concurrency=$concurrency", |
105 ]; | 106 "--reporter=$reporter" |
106 | 107 ]..addAll(args); |
107 if (!compact) allArgs.addAll(["-r", "expanded"]); | |
108 allArgs.addAll(args); | |
109 | 108 |
110 if (environment == null) environment = {}; | 109 if (environment == null) environment = {}; |
111 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false"); | 110 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false"); |
112 | 111 |
113 return runDart(allArgs, | 112 return runDart(allArgs, |
114 environment: environment, | 113 environment: environment, |
115 description: "dart bin/test.dart"); | 114 description: "dart bin/test.dart"); |
116 } | 115 } |
117 | 116 |
118 /// Runs Dart. | 117 /// Runs Dart. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 var match; | 159 var match; |
161 while (match == null) { | 160 while (match == null) { |
162 var line = await pub.stdout.next(); | 161 var line = await pub.stdout.next(); |
163 match = _servingRegExp.firstMatch(line); | 162 match = _servingRegExp.firstMatch(line); |
164 } | 163 } |
165 _pubServePortCompleter.complete(int.parse(match[1])); | 164 _pubServePortCompleter.complete(int.parse(match[1])); |
166 }, "waiting for pub serve to emit its port number"); | 165 }, "waiting for pub serve to emit its port number"); |
167 | 166 |
168 return pub; | 167 return pub; |
169 } | 168 } |
OLD | NEW |