Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1647)

Side by Side Diff: pkg/scheduled_test/test/scheduled_process_test.dart

Issue 18356011: Rename "pathos" package to "path". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:io'; 8 import 'dart:io';
9 9
10 import 'package:pathos/path.dart' as path; 10 import 'package:path/path.dart' as path;
11 import 'package:scheduled_test/scheduled_process.dart'; 11 import 'package:scheduled_test/scheduled_process.dart';
12 import 'package:scheduled_test/scheduled_test.dart'; 12 import 'package:scheduled_test/scheduled_test.dart';
13 import 'package:scheduled_test/src/mock_clock.dart' as mock_clock; 13 import 'package:scheduled_test/src/mock_clock.dart' as mock_clock;
14 14
15 import 'metatest.dart'; 15 import 'metatest.dart';
16 import 'utils.dart'; 16 import 'utils.dart';
17 17
18 void main() { 18 void main() {
19 setUpTimeout(); 19 setUpTimeout();
20 20
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 }); 120 });
121 }); 121 });
122 122
123 expectTestsPass("a process that ends while waiting for stdout shouldn't " 123 expectTestsPass("a process that ends while waiting for stdout shouldn't "
124 "block the test", () { 124 "block the test", () {
125 var errors; 125 var errors;
126 test('test 1', () { 126 test('test 1', () {
127 currentSchedule.onException.schedule(() { 127 currentSchedule.onException.schedule(() {
128 errors = currentSchedule.errors; 128 errors = currentSchedule.errors;
129 }); 129 });
130 130
131 var process = startDartProcess(''); 131 var process = startDartProcess('');
132 expect(process.nextLine(), completion(equals('hello'))); 132 expect(process.nextLine(), completion(equals('hello')));
133 expect(process.nextLine(), completion(equals('world'))); 133 expect(process.nextLine(), completion(equals('world')));
134 process.shouldExit(0); 134 process.shouldExit(0);
135 }); 135 });
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, matches(r"^Process "
(...skipping 26 matching lines...) Expand all
173 process.shouldExit(0); 173 process.shouldExit(0);
174 }); 174 });
175 }); 175 });
176 176
177 expectTestsPass("nextLine throws an error if there's no more stdout", () { 177 expectTestsPass("nextLine throws an error if there's no more stdout", () {
178 var errors; 178 var errors;
179 test('test 1', () { 179 test('test 1', () {
180 currentSchedule.onException.schedule(() { 180 currentSchedule.onException.schedule(() {
181 errors = currentSchedule.errors; 181 errors = currentSchedule.errors;
182 }); 182 });
183 183
184 var process = startDartProcess('print("hello");'); 184 var process = startDartProcess('print("hello");');
185 expect(process.nextLine(), completion(equals('hello'))); 185 expect(process.nextLine(), completion(equals('hello')));
186 expect(process.nextLine(), completion(equals('world'))); 186 expect(process.nextLine(), completion(equals('world')));
187 process.shouldExit(0); 187 process.shouldExit(0);
188 }); 188 });
189 189
190 test('test 2', () { 190 test('test 2', () {
191 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 191 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
192 expect(errors.length, anyOf(1, 2)); 192 expect(errors.length, anyOf(1, 2));
193 expect(errors[0].error, isStateError); 193 expect(errors[0].error, isStateError);
194 expect(errors[0].error.message, equals("No elements")); 194 expect(errors[0].error.message, equals("No elements"));
195 195
196 // Whether or not this error appears depends on how quickly the "no 196 // Whether or not this error appears depends on how quickly the "no
197 // elements" error is handled. 197 // elements" error is handled.
198 if (errors.length == 2) { 198 if (errors.length == 2) {
199 expect(errors[1].error, matches(r"^Process " 199 expect(errors[1].error, matches(r"^Process "
(...skipping 17 matching lines...) Expand all
217 process.shouldExit(0); 217 process.shouldExit(0);
218 }); 218 });
219 }); 219 });
220 220
221 expectTestsPass("nextErrLine throws an error if there's no more stderr", () { 221 expectTestsPass("nextErrLine throws an error if there's no more stderr", () {
222 var errors; 222 var errors;
223 test('test 1', () { 223 test('test 1', () {
224 currentSchedule.onException.schedule(() { 224 currentSchedule.onException.schedule(() {
225 errors = currentSchedule.errors; 225 errors = currentSchedule.errors;
226 }); 226 });
227 227
228 var process = startDartProcess(r'stderr.write("hello\n");'); 228 var process = startDartProcess(r'stderr.write("hello\n");');
229 expect(process.nextErrLine(), completion(equals('hello'))); 229 expect(process.nextErrLine(), completion(equals('hello')));
230 expect(process.nextErrLine(), completion(equals('world'))); 230 expect(process.nextErrLine(), completion(equals('world')));
231 process.shouldExit(0); 231 process.shouldExit(0);
232 }); 232 });
233 233
234 test('test 2', () { 234 test('test 2', () {
235 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 235 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
236 expect(errors.length, anyOf(1, 2)); 236 expect(errors.length, anyOf(1, 2));
237 expect(errors[0].error, isStateError); 237 expect(errors[0].error, isStateError);
238 expect(errors[0].error.message, equals("No elements")); 238 expect(errors[0].error.message, equals("No elements"));
239 239
240 // Whether or not this error appears depends on how quickly the "no 240 // Whether or not this error appears depends on how quickly the "no
241 // elements" error is handled. 241 // elements" error is handled.
242 if (errors.length == 2) { 242 if (errors.length == 2) {
243 expect(errors[1].error, matches(r"^Process " 243 expect(errors[1].error, matches(r"^Process "
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 currentSchedule.onComplete.schedule(() { 384 currentSchedule.onComplete.schedule(() {
385 return tempDir.catchError((_) => null).then((dir) { 385 return tempDir.catchError((_) => null).then((dir) {
386 if (dir == null) return; 386 if (dir == null) return;
387 return new Directory(dir).delete(recursive: true); 387 return new Directory(dir).delete(recursive: true);
388 }); 388 });
389 }, 'clean up temp dir'); 389 }, 'clean up temp dir');
390 390
391 return new ScheduledProcess.start(dartExecutable, ['--checked', dartPath]); 391 return new ScheduledProcess.start(dartExecutable, ['--checked', dartPath]);
392 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698