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

Side by Side Diff: test/runner/signal_test.dart

Issue 1096943003: Rename {run,start}Unittest to {run,start}Test. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « test/runner/runner_test.dart ('k') | test/runner/test_on_test.dart » ('j') | 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) 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 @TestOn("vm") 5 @TestOn("vm")
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 25 matching lines...) Expand all
36 group("during loading,", () { 36 group("during loading,", () {
37 test("cleans up if killed while loading a VM test", () { 37 test("cleans up if killed while loading a VM test", () {
38 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 38 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
39 void main() { 39 void main() {
40 print("in test.dart"); 40 print("in test.dart");
41 // Spin for a long time so the test is probably killed while still loading. 41 // Spin for a long time so the test is probably killed while still loading.
42 for (var i = 0; i < 100000000; i++) {} 42 for (var i = 0; i < 100000000; i++) {}
43 } 43 }
44 """); 44 """);
45 45
46 return _startUnittest(["test.dart"]).then((process) { 46 return _startTest(["test.dart"]).then((process) {
47 return _lines.bind(process.stdout).first.then((line) { 47 return _lines.bind(process.stdout).first.then((line) {
48 expect(line, equals("in test.dart")); 48 expect(line, equals("in test.dart"));
49 process.kill(); 49 process.kill();
50 return process.exitCode; 50 return process.exitCode;
51 }).then((_) { 51 }).then((_) {
52 expect(new Directory(_tempDir).listSync(), isEmpty); 52 expect(new Directory(_tempDir).listSync(), isEmpty);
53 }); 53 });
54 }); 54 });
55 }); 55 });
56 56
57 test("cleans up if killed while loading a browser test", () { 57 test("cleans up if killed while loading a browser test", () {
58 new File(p.join(_sandbox, "test.dart")) 58 new File(p.join(_sandbox, "test.dart"))
59 .writeAsStringSync("void main() {}"); 59 .writeAsStringSync("void main() {}");
60 60
61 return _startUnittest(["-p", "chrome", "test.dart"]).then((process) { 61 return _startTest(["-p", "chrome", "test.dart"]).then((process) {
62 return _lines.bind(process.stdout).first.then((line) { 62 return _lines.bind(process.stdout).first.then((line) {
63 expect(line, equals("Compiling test.dart...")); 63 expect(line, equals("Compiling test.dart..."));
64 process.kill(); 64 process.kill();
65 return process.exitCode; 65 return process.exitCode;
66 }).then((_) { 66 }).then((_) {
67 expect(new Directory(_tempDir).listSync(), isEmpty); 67 expect(new Directory(_tempDir).listSync(), isEmpty);
68 }); 68 });
69 }); 69 });
70 }); 70 });
71 71
72 test("exits immediately if ^C is sent twice", () { 72 test("exits immediately if ^C is sent twice", () {
73 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 73 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
74 void main() { 74 void main() {
75 print("in test.dart"); 75 print("in test.dart");
76 while (true) {} 76 while (true) {}
77 } 77 }
78 """); 78 """);
79 79
80 return _startUnittest(["test.dart"]).then((process) { 80 return _startTest(["test.dart"]).then((process) {
81 return _lines.bind(process.stdout).first.then((line) { 81 return _lines.bind(process.stdout).first.then((line) {
82 expect(line, equals("in test.dart")); 82 expect(line, equals("in test.dart"));
83 process.kill(); 83 process.kill();
84 84
85 // TODO(nweiz): Sending two signals in close succession can cause the 85 // TODO(nweiz): Sending two signals in close succession can cause the
86 // second one to be ignored, so we wait a bit before the second 86 // second one to be ignored, so we wait a bit before the second
87 // one. Remove this hack when issue 23047 is fixed. 87 // one. Remove this hack when issue 23047 is fixed.
88 return new Future.delayed(new Duration(seconds: 1)); 88 return new Future.delayed(new Duration(seconds: 1));
89 }).then((_) { 89 }).then((_) {
90 process.kill(); 90 process.kill();
(...skipping 16 matching lines...) Expand all
107 void main() { 107 void main() {
108 tearDown(() => new File("output").writeAsStringSync("ran teardown")); 108 tearDown(() => new File("output").writeAsStringSync("ran teardown"));
109 109
110 test("test", () { 110 test("test", () {
111 print("running test"); 111 print("running test");
112 return new Future.delayed(new Duration(seconds: 1)); 112 return new Future.delayed(new Duration(seconds: 1));
113 }); 113 });
114 } 114 }
115 """); 115 """);
116 116
117 return _startUnittest(["test.dart"]).then((process) { 117 return _startTest(["test.dart"]).then((process) {
118 return _lines.bind(process.stdout).skip(2).first.then((line) { 118 return _lines.bind(process.stdout).skip(2).first.then((line) {
119 expect(line, equals("running test")); 119 expect(line, equals("running test"));
120 process.kill(); 120 process.kill();
121 return process.exitCode; 121 return process.exitCode;
122 }).then((_) { 122 }).then((_) {
123 expect(new File(p.join(_sandbox, "output")).readAsStringSync(), 123 expect(new File(p.join(_sandbox, "output")).readAsStringSync(),
124 equals("ran teardown")); 124 equals("ran teardown"));
125 expect(new Directory(_tempDir).listSync(), isEmpty); 125 expect(new Directory(_tempDir).listSync(), isEmpty);
126 }); 126 });
127 }); 127 });
(...skipping 12 matching lines...) Expand all
140 // Allow an event loop to pass so the preceding print can be handled. 140 // Allow an event loop to pass so the preceding print can be handled.
141 return new Future(() { 141 return new Future(() {
142 // Loop forever so that if the test isn't stopped while running, it never 142 // Loop forever so that if the test isn't stopped while running, it never
143 // stops. 143 // stops.
144 while (true) {} 144 while (true) {}
145 }); 145 });
146 }); 146 });
147 } 147 }
148 """); 148 """);
149 149
150 return _startUnittest(["-p", "chrome", "test.dart"]).then((process) { 150 return _startTest(["-p", "chrome", "test.dart"]).then((process) {
151 return _lines.bind(process.stdout).skip(3).first.then((line) { 151 return _lines.bind(process.stdout).skip(3).first.then((line) {
152 expect(line, equals("running test")); 152 expect(line, equals("running test"));
153 process.kill(); 153 process.kill();
154 return process.exitCode; 154 return process.exitCode;
155 }).then((_) { 155 }).then((_) {
156 expect(new Directory(_tempDir).listSync(), isEmpty); 156 expect(new Directory(_tempDir).listSync(), isEmpty);
157 }); 157 });
158 }); 158 });
159 }); 159 });
160 160
161 test("kills a VM test immediately if ^C is sent twice", () { 161 test("kills a VM test immediately if ^C is sent twice", () {
162 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 162 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
163 import 'package:test/test.dart'; 163 import 'package:test/test.dart';
164 164
165 void main() { 165 void main() {
166 test("test", () { 166 test("test", () {
167 print("running test"); 167 print("running test");
168 while (true) {} 168 while (true) {}
169 }); 169 });
170 } 170 }
171 """); 171 """);
172 172
173 return _startUnittest(["test.dart"]).then((process) { 173 return _startTest(["test.dart"]).then((process) {
174 return _lines.bind(process.stdout).skip(2).first.then((line) { 174 return _lines.bind(process.stdout).skip(2).first.then((line) {
175 expect(line, equals("running test")); 175 expect(line, equals("running test"));
176 process.kill(); 176 process.kill();
177 177
178 // TODO(nweiz): Sending two signals in close succession can cause the 178 // TODO(nweiz): Sending two signals in close succession can cause the
179 // second one to be ignored, so we wait a bit before the second 179 // second one to be ignored, so we wait a bit before the second
180 // one. Remove this hack when issue 23047 is fixed. 180 // one. Remove this hack when issue 23047 is fixed.
181 return new Future.delayed(new Duration(seconds: 1)); 181 return new Future.delayed(new Duration(seconds: 1));
182 }).then((_) { 182 }).then((_) {
183 process.kill(); 183 process.kill();
(...skipping 23 matching lines...) Expand all
207 try { 207 try {
208 expect(true, isTrue); 208 expect(true, isTrue);
209 } catch (_) { 209 } catch (_) {
210 expectThrewError = true; 210 expectThrewError = true;
211 } 211 }
212 }); 212 });
213 }); 213 });
214 } 214 }
215 """); 215 """);
216 216
217 return _startUnittest(["test.dart"]).then((process) { 217 return _startTest(["test.dart"]).then((process) {
218 return _lines.bind(process.stdout).skip(2).first.then((line) { 218 return _lines.bind(process.stdout).skip(2).first.then((line) {
219 expect(line, equals("running test")); 219 expect(line, equals("running test"));
220 process.kill(); 220 process.kill();
221 return process.exitCode; 221 return process.exitCode;
222 }).then((_) { 222 }).then((_) {
223 expect(new File(p.join(_sandbox, "output")).readAsStringSync(), 223 expect(new File(p.join(_sandbox, "output")).readAsStringSync(),
224 equals("true")); 224 equals("true"));
225 expect(new Directory(_tempDir).listSync(), isEmpty); 225 expect(new Directory(_tempDir).listSync(), isEmpty);
226 }); 226 });
227 }); 227 });
(...skipping 20 matching lines...) Expand all
248 try { 248 try {
249 expectAsync(() {}); 249 expectAsync(() {});
250 } catch (_) { 250 } catch (_) {
251 expectAsyncThrewError = true; 251 expectAsyncThrewError = true;
252 } 252 }
253 }); 253 });
254 }); 254 });
255 } 255 }
256 """); 256 """);
257 257
258 return _startUnittest(["test.dart"]).then((process) { 258 return _startTest(["test.dart"]).then((process) {
259 return _lines.bind(process.stdout).skip(2).first.then((line) { 259 return _lines.bind(process.stdout).skip(2).first.then((line) {
260 expect(line, equals("running test")); 260 expect(line, equals("running test"));
261 process.kill(); 261 process.kill();
262 return process.exitCode; 262 return process.exitCode;
263 }).then((_) { 263 }).then((_) {
264 expect(new File(p.join(_sandbox, "output")).readAsStringSync(), 264 expect(new File(p.join(_sandbox, "output")).readAsStringSync(),
265 equals("true")); 265 equals("true"));
266 expect(new Directory(_tempDir).listSync(), isEmpty); 266 expect(new Directory(_tempDir).listSync(), isEmpty);
267 }); 267 });
268 }); 268 });
269 }); 269 });
270 }); 270 });
271 } 271 }
272 272
273 Future<Process> _startUnittest(List<String> args) { 273 Future<Process> _startTest(List<String> args) {
274 new Directory(_tempDir).create(); 274 new Directory(_tempDir).create();
275 return startUnittest(args, workingDirectory: _sandbox, 275 return startTest(args, workingDirectory: _sandbox,
276 environment: {"_UNITTEST_TEMP_DIR": _tempDir}); 276 environment: {"_UNITTEST_TEMP_DIR": _tempDir});
277 } 277 }
OLDNEW
« no previous file with comments | « test/runner/runner_test.dart ('k') | test/runner/test_on_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698