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

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

Issue 12663006: Fix the build breakages caused by r19742. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
« no previous file with comments | « pkg/scheduled_test/lib/src/schedule.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:pathos/path.dart' as path;
(...skipping 13 matching lines...) Expand all
24 }); 24 });
25 25
26 startDartProcess('print("hello!");'); 26 startDartProcess('print("hello!");');
27 }); 27 });
28 28
29 test('test 2', () { 29 test('test 2', () {
30 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 30 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
31 expect(errors.length, equals(1)); 31 expect(errors.length, equals(1));
32 expect(errors.first.error, isStateError); 32 expect(errors.first.error, isStateError);
33 expect(errors.first.error.message, matches(r"^Scheduled process " 33 expect(errors.first.error.message, matches(r"^Scheduled process "
34 r"'[^']+[\\/]dart' must have shouldExit\(\) or kill\(\) called " 34 r"'[^']+[\\/]dart(\.exe)?' must have shouldExit\(\) or kill\(\) "
35 r"before the test is run\.$")); 35 r"called before the test is run\.$"));
36 }); 36 });
37 }, passing: ['test 2']); 37 }, passing: ['test 2']);
38 38
39 expectTestsPass("a process exits with the expected exit code", () { 39 expectTestsPass("a process exits with the expected exit code", () {
40 test('exit code 0', () { 40 test('exit code 0', () {
41 var process = startDartProcess('exitCode = 0;'); 41 var process = startDartProcess('exitCode = 0;');
42 process.shouldExit(0); 42 process.shouldExit(0);
43 }); 43 });
44 44
45 test('exit code 42', () { 45 test('exit code 42', () {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 }); 111 });
112 112
113 expectTestsPass("shouldExit can't be called after kill", () { 113 expectTestsPass("shouldExit can't be called after kill", () {
114 test('test', () { 114 test('test', () {
115 var process = startDartProcess(''); 115 var process = startDartProcess('');
116 process.kill(); 116 process.kill();
117 expect(() => process.shouldExit(0), throwsA(isStateError)); 117 expect(() => process.shouldExit(0), throwsA(isStateError));
118 }); 118 });
119 }); 119 });
120 120
121 expectTestsPass("a process that ends while waiting for stdout shouldn't " 121 // TODO(nweiz): re-enable this (issue 9022).
122 "block the test", () { 122 // expectTestsPass("a process that ends while waiting for stdout shouldn't "
123 var errors; 123 // "block the test", () {
124 test('test 1', () { 124 // var errors;
125 currentSchedule.onException.schedule(() { 125 // test('test 1', () {
126 errors = currentSchedule.errors; 126 // currentSchedule.onException.schedule(() {
127 }); 127 // errors = currentSchedule.errors;
128 128 // });
129 var process = startDartProcess(''); 129 //
130 expect(process.nextLine(), completion(equals('hello'))); 130 // var process = startDartProcess('');
131 expect(process.nextLine(), completion(equals('world'))); 131 // expect(process.nextLine(), completion(equals('hello')));
132 process.shouldExit(0); 132 // expect(process.nextLine(), completion(equals('world')));
133 }); 133 // process.shouldExit(0);
134 134 // });
135 test('test 2', () { 135 //
136 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 136 // test('test 2', () {
137 expect(errors.length, equals(2)); 137 // expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
138 expect(errors[0].error, isStateError); 138 // expect(errors.length, equals(2));
139 expect(errors[0].error.message, equals("No elements")); 139 // expect(errors[0].error, isStateError);
140 expect(errors[1].error, matches(r"^Process '[^']+[\\/]dart [^']+' ended " 140 // expect(errors[0].error.message, equals("No elements"));
141 r"earlier than scheduled with exit code 0\.")); 141 // expect(errors[1].error, matches(r"^Process "
142 }); 142 // r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with "
143 }, passing: ['test 2']); 143 // r"exit code 0\."));
144 // });
145 // }, passing: ['test 2']);
144 146
145 expectTestsPass("a process that ends during the task immediately before it's " 147 expectTestsPass("a process that ends during the task immediately before it's "
146 "scheduled to end shouldn't cause an error", () { 148 "scheduled to end shouldn't cause an error", () {
147 test('test', () { 149 test('test', () {
148 var process = startDartProcess('stdin.toList();'); 150 var process = startDartProcess('stdin.toList();');
149 process.closeStdin(); 151 process.closeStdin();
150 // Unfortunately, sleeping for a second seems like the best way of 152 // Unfortunately, sleeping for a second seems like the best way of
151 // guaranteeing that the process ends during this task. 153 // guaranteeing that the process ends during this task.
152 schedule(() => new Future.delayed(new Duration(seconds: 1))); 154 schedule(() => new Future.delayed(new Duration(seconds: 1)));
153 process.shouldExit(0); 155 process.shouldExit(0);
(...skipping 23 matching lines...) Expand all
177 expect(process.nextLine(), completion(equals('hello'))); 179 expect(process.nextLine(), completion(equals('hello')));
178 expect(process.nextLine(), completion(equals('world'))); 180 expect(process.nextLine(), completion(equals('world')));
179 process.shouldExit(0); 181 process.shouldExit(0);
180 }); 182 });
181 183
182 test('test 2', () { 184 test('test 2', () {
183 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 185 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
184 expect(errors.length, equals(2)); 186 expect(errors.length, equals(2));
185 expect(errors[0].error, isStateError); 187 expect(errors[0].error, isStateError);
186 expect(errors[0].error.message, equals("No elements")); 188 expect(errors[0].error.message, equals("No elements"));
187 expect(errors[1].error, matches(r"^Process '[^']+[\\/]dart [^']+' ended " 189 expect(errors[1].error, matches(r"^Process "
188 r"earlier than scheduled with exit code 0\.")); 190 r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with "
191 r"exit code 0\."));
189 }); 192 });
190 }, passing: ['test 2']); 193 }, passing: ['test 2']);
191 194
192 expectTestsPass("nextErrLine returns the next line of stderr from the " 195 expectTestsPass("nextErrLine returns the next line of stderr from the "
193 "process", () { 196 "process", () {
194 test('test', () { 197 test('test', () {
195 var process = startDartProcess(r''' 198 var process = startDartProcess(r'''
196 stderr.write("hello\n\nworld\n"); 199 stderr.write("hello\n\nworld\n");
197 stderr.write("hi"); 200 stderr.write("hi");
198 '''); 201 ''');
(...skipping 16 matching lines...) Expand all
215 expect(process.nextErrLine(), completion(equals('hello'))); 218 expect(process.nextErrLine(), completion(equals('hello')));
216 expect(process.nextErrLine(), completion(equals('world'))); 219 expect(process.nextErrLine(), completion(equals('world')));
217 process.shouldExit(0); 220 process.shouldExit(0);
218 }); 221 });
219 222
220 test('test 2', () { 223 test('test 2', () {
221 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 224 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
222 expect(errors.length, equals(2)); 225 expect(errors.length, equals(2));
223 expect(errors[0].error, isStateError); 226 expect(errors[0].error, isStateError);
224 expect(errors[0].error.message, equals("No elements")); 227 expect(errors[0].error.message, equals("No elements"));
225 expect(errors[1].error, matches(r"^Process '[^']+[\\/]dart [^']+' ended " 228 expect(errors[1].error, matches(r"^Process "
226 r"earlier than scheduled with exit code 0\.")); 229 r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with "
230 r"exit code 0\."));
227 }); 231 });
228 }, passing: ['test 2']); 232 }, passing: ['test 2']);
229 233
230 expectTestsPass("remainingStdout returns all the stdout if it's not consumed " 234 expectTestsPass("remainingStdout returns all the stdout if it's not consumed "
231 "any other way", () { 235 "any other way", () {
232 test('test', () { 236 test('test', () {
233 var process = startDartProcess(r'print("hello\n\nworld"); print("hi");'); 237 var process = startDartProcess(r'print("hello\n\nworld"); print("hi");');
234 process.shouldExit(0); 238 process.shouldExit(0);
235 expect(process.remainingStdout(), 239 expect(process.remainingStdout(),
236 completion(equals("hello\n\nworld\nhi"))); 240 completion(equals("hello\n\nworld\nhi")));
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 369
366 currentSchedule.onComplete.schedule(() { 370 currentSchedule.onComplete.schedule(() {
367 return tempDir.catchError((_) => null).then((dir) { 371 return tempDir.catchError((_) => null).then((dir) {
368 if (dir == null) return; 372 if (dir == null) return;
369 return new Directory(dir).delete(recursive: true); 373 return new Directory(dir).delete(recursive: true);
370 }); 374 });
371 }, 'clean up temp dir'); 375 }, 'clean up temp dir');
372 376
373 return new ScheduledProcess.start(dartExecutable, ['--checked', dartPath]); 377 return new ScheduledProcess.start(dartExecutable, ['--checked', dartPath]);
374 } 378 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/schedule.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698