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

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

Issue 12732004: Add a bunch of ugly debugging prints to figure out why the bots are failing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge 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 100 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 // TODO(nweiz): re-enable this (issue 9022). 121 expectTestsPass("a process that ends while waiting for stdout shouldn't "
122 // expectTestsPass("a process that ends while waiting for stdout shouldn't " 122 "block the test", () {
123 // "block the test", () { 123 print("beginning test: a process that ends while waiting for stdout shouldn' t block the test");
124 // var errors; 124 var errors;
125 // test('test 1', () { 125 test('test 1', () {
126 // currentSchedule.onException.schedule(() { 126 currentSchedule.onException.schedule(() {
127 // errors = currentSchedule.errors; 127 errors = currentSchedule.errors;
128 // }); 128 });
129 // 129
130 // var process = startDartProcess(''); 130 var process = startDartProcess('');
131 // expect(process.nextLine(), completion(equals('hello'))); 131 expect(process.nextLine(), completion(equals('hello')));
132 // expect(process.nextLine(), completion(equals('world'))); 132 expect(process.nextLine(), completion(equals('world')));
133 // process.shouldExit(0); 133 process.shouldExit(0);
134 // }); 134 });
135 // 135
136 // test('test 2', () { 136 test('test 2', () {
137 // expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 137 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
138 // expect(errors.length, equals(2)); 138 expect(errors.length, equals(2));
139 // expect(errors[0].error, isStateError); 139 expect(errors[0].error, isStateError);
140 // expect(errors[0].error.message, equals("No elements")); 140 expect(errors[0].error.message, equals("No elements"));
141 // expect(errors[1].error, matches(r"^Process " 141 expect(errors[1].error, matches(r"^Process "
142 // r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with " 142 r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with "
143 // r"exit code 0\.")); 143 r"exit code 0\."));
144 // }); 144 });
145 // }, passing: ['test 2']); 145 }, passing: ['test 2']);
146 146
147 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 "
148 "scheduled to end shouldn't cause an error", () { 148 "scheduled to end shouldn't cause an error", () {
149 test('test', () { 149 test('test', () {
150 var process = startDartProcess('stdin.toList();'); 150 var process = startDartProcess('stdin.toList();');
151 process.closeStdin(); 151 process.closeStdin();
152 // Unfortunately, sleeping for a second seems like the best way of 152 // Unfortunately, sleeping for a second seems like the best way of
153 // guaranteeing that the process ends during this task. 153 // guaranteeing that the process ends during this task.
154 schedule(() => new Future.delayed(new Duration(seconds: 1))); 154 schedule(() => new Future.delayed(new Duration(seconds: 1)));
155 process.shouldExit(0); 155 process.shouldExit(0);
156 }); 156 });
157 }); 157 });
158 158
159 expectTestsPass("nextLine returns the next line of stdout from the process", 159 expectTestsPass("nextLine returns the next line of stdout from the process",
160 () { 160 () {
161 test('test', () { 161 test('test', () {
162 var process = startDartProcess(r'print("hello\n\nworld"); print("hi");'); 162 var process = startDartProcess(r'print("hello\n\nworld"); print("hi");');
163 expect(process.nextLine(), completion(equals('hello'))); 163 expect(process.nextLine(), completion(equals('hello')));
164 expect(process.nextLine(), completion(equals(''))); 164 expect(process.nextLine(), completion(equals('')));
165 expect(process.nextLine(), completion(equals('world'))); 165 expect(process.nextLine(), completion(equals('world')));
166 expect(process.nextLine(), completion(equals('hi'))); 166 expect(process.nextLine(), completion(equals('hi')));
167 process.shouldExit(0); 167 process.shouldExit(0);
168 }); 168 });
169 }); 169 });
170 170
171 expectTestsPass("nextLine throws an error if there's no more stdout", () { 171 expectTestsPass("nextLine throws an error if there's no more stdout", () {
172 print("beginning test: nextLine throws an error if there's no more stdout");
172 var errors; 173 var errors;
173 test('test 1', () { 174 test('test 1', () {
174 currentSchedule.onException.schedule(() { 175 currentSchedule.onException.schedule(() {
175 errors = currentSchedule.errors; 176 errors = currentSchedule.errors;
176 }); 177 });
177 178
178 var process = startDartProcess('print("hello");'); 179 var process = startDartProcess('print("hello");');
179 expect(process.nextLine(), completion(equals('hello'))); 180 expect(process.nextLine(), completion(equals('hello')));
180 expect(process.nextLine(), completion(equals('world'))); 181 expect(process.nextLine(), completion(equals('world')));
181 process.shouldExit(0); 182 process.shouldExit(0);
(...skipping 19 matching lines...) Expand all
201 '''); 202 ''');
202 expect(process.nextErrLine(), completion(equals('hello'))); 203 expect(process.nextErrLine(), completion(equals('hello')));
203 expect(process.nextErrLine(), completion(equals(''))); 204 expect(process.nextErrLine(), completion(equals('')));
204 expect(process.nextErrLine(), completion(equals('world'))); 205 expect(process.nextErrLine(), completion(equals('world')));
205 expect(process.nextErrLine(), completion(equals('hi'))); 206 expect(process.nextErrLine(), completion(equals('hi')));
206 process.shouldExit(0); 207 process.shouldExit(0);
207 }); 208 });
208 }); 209 });
209 210
210 expectTestsPass("nextErrLine throws an error if there's no more stderr", () { 211 expectTestsPass("nextErrLine throws an error if there's no more stderr", () {
212 print("beginning test: nextErrLine throws an error if there's no more stdout ");
211 var errors; 213 var errors;
212 test('test 1', () { 214 test('test 1', () {
213 currentSchedule.onException.schedule(() { 215 currentSchedule.onException.schedule(() {
214 errors = currentSchedule.errors; 216 errors = currentSchedule.errors;
215 }); 217 });
216 218
217 var process = startDartProcess(r'stderr.write("hello\n");'); 219 var process = startDartProcess(r'stderr.write("hello\n");');
218 expect(process.nextErrLine(), completion(equals('hello'))); 220 expect(process.nextErrLine(), completion(equals('hello')));
219 expect(process.nextErrLine(), completion(equals('world'))); 221 expect(process.nextErrLine(), completion(equals('world')));
220 process.shouldExit(0); 222 process.shouldExit(0);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 371
370 currentSchedule.onComplete.schedule(() { 372 currentSchedule.onComplete.schedule(() {
371 return tempDir.catchError((_) => null).then((dir) { 373 return tempDir.catchError((_) => null).then((dir) {
372 if (dir == null) return; 374 if (dir == null) return;
373 return new Directory(dir).delete(recursive: true); 375 return new Directory(dir).delete(recursive: true);
374 }); 376 });
375 }, 'clean up temp dir'); 377 }, 'clean up temp dir');
376 378
377 return new ScheduledProcess.start(dartExecutable, ['--checked', dartPath]); 379 return new ScheduledProcess.start(dartExecutable, ['--checked', dartPath]);
378 } 380 }
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