OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 scheduled_process_test; | 5 library scheduled_process_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 test('test 2', () { | 137 test('test 2', () { |
138 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 138 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
139 expect(errors.length, anyOf(1, 2)); | 139 expect(errors.length, anyOf(1, 2)); |
140 expect(errors[0].error, isStateError); | 140 expect(errors[0].error, isStateError); |
141 expect(errors[0].error.message, equals("No elements")); | 141 expect(errors[0].error.message, equals("No elements")); |
142 | 142 |
143 // Whether or not this error appears depends on how quickly the "no | 143 // Whether or not this error appears depends on how quickly the "no |
144 // elements" error is handled. | 144 // elements" error is handled. |
145 if (errors.length == 2) { | 145 if (errors.length == 2) { |
146 expect(errors[1].error, matches(r"^Process " | 146 expect(errors[1].error, new isInstanceOf<TestFailure>()); |
| 147 expect(errors[1].error.message, matches(r"^Process " |
147 r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with " | 148 r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with " |
148 r"exit code 0\.")); | 149 r"exit code 0\.")); |
149 } | 150 } |
150 }); | 151 }); |
151 }, passing: ['test 2']); | 152 }, passing: ['test 2']); |
152 | 153 |
153 expectTestsPass("a process that ends during the task immediately before it's " | 154 expectTestsPass("a process that ends during the task immediately before it's " |
154 "scheduled to end shouldn't cause an error", () { | 155 "scheduled to end shouldn't cause an error", () { |
155 test('test', () { | 156 test('test', () { |
156 var process = startDartProcess('stdin.toList();'); | 157 var process = startDartProcess('stdin.toList();'); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 190 |
190 test('test 2', () { | 191 test('test 2', () { |
191 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 192 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
192 expect(errors.length, anyOf(1, 2)); | 193 expect(errors.length, anyOf(1, 2)); |
193 expect(errors[0].error, isStateError); | 194 expect(errors[0].error, isStateError); |
194 expect(errors[0].error.message, equals("No elements")); | 195 expect(errors[0].error.message, equals("No elements")); |
195 | 196 |
196 // Whether or not this error appears depends on how quickly the "no | 197 // Whether or not this error appears depends on how quickly the "no |
197 // elements" error is handled. | 198 // elements" error is handled. |
198 if (errors.length == 2) { | 199 if (errors.length == 2) { |
199 expect(errors[1].error, matches(r"^Process " | 200 expect(errors[1].error, new isInstanceOf<TestFailure>()); |
| 201 expect(errors[1].error.message, matches(r"^Process " |
200 r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with " | 202 r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with " |
201 r"exit code 0\.")); | 203 r"exit code 0\.")); |
202 } | 204 } |
203 }); | 205 }); |
204 }, passing: ['test 2']); | 206 }, passing: ['test 2']); |
205 | 207 |
206 expectTestsPass("nextErrLine returns the next line of stderr from the " | 208 expectTestsPass("nextErrLine returns the next line of stderr from the " |
207 "process", () { | 209 "process", () { |
208 test('test', () { | 210 test('test', () { |
209 var process = startDartProcess(r''' | 211 var process = startDartProcess(r''' |
(...skipping 23 matching lines...) Expand all Loading... |
233 | 235 |
234 test('test 2', () { | 236 test('test 2', () { |
235 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 237 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
236 expect(errors.length, anyOf(1, 2)); | 238 expect(errors.length, anyOf(1, 2)); |
237 expect(errors[0].error, isStateError); | 239 expect(errors[0].error, isStateError); |
238 expect(errors[0].error.message, equals("No elements")); | 240 expect(errors[0].error.message, equals("No elements")); |
239 | 241 |
240 // Whether or not this error appears depends on how quickly the "no | 242 // Whether or not this error appears depends on how quickly the "no |
241 // elements" error is handled. | 243 // elements" error is handled. |
242 if (errors.length == 2) { | 244 if (errors.length == 2) { |
243 expect(errors[1].error, matches(r"^Process " | 245 expect(errors[1].error, new isInstanceOf<TestFailure>()); |
| 246 expect(errors[1].error.message, matches(r"^Process " |
244 r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with " | 247 r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with " |
245 r"exit code 0\.")); | 248 r"exit code 0\.")); |
246 } | 249 } |
247 }); | 250 }); |
248 }, passing: ['test 2']); | 251 }, passing: ['test 2']); |
249 | 252 |
250 expectTestsPass("remainingStdout returns all the stdout if it's not consumed " | 253 expectTestsPass("remainingStdout returns all the stdout if it's not consumed " |
251 "any other way", () { | 254 "any other way", () { |
252 test('test', () { | 255 test('test', () { |
253 var process = startDartProcess(r'print("hello\n\nworld"); print("hi");'); | 256 var process = startDartProcess(r'print("hello\n\nworld"); print("hi");'); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 387 |
385 currentSchedule.onComplete.schedule(() { | 388 currentSchedule.onComplete.schedule(() { |
386 return tempDir.catchError((_) => null).then((dir) { | 389 return tempDir.catchError((_) => null).then((dir) { |
387 if (dir == null) return; | 390 if (dir == null) return; |
388 return new Directory(dir).delete(recursive: true); | 391 return new Directory(dir).delete(recursive: true); |
389 }); | 392 }); |
390 }, 'clean up temp dir'); | 393 }, 'clean up temp dir'); |
391 | 394 |
392 return new ScheduledProcess.start(dartExecutable, ['--checked', dartPath]); | 395 return new ScheduledProcess.start(dartExecutable, ['--checked', dartPath]); |
393 } | 396 } |
OLD | NEW |