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

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

Issue 1196413003: Add a LoadSuite class. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 6 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
« lib/src/runner/load_suite.dart ('K') | « test/runner/runner_test.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) 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 // Windows doesn't support sending signals. 5 // Windows doesn't support sending signals.
6 @TestOn("vm && !windows") 6 @TestOn("vm && !windows")
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 24 matching lines...) Expand all
35 group("during loading,", () { 35 group("during loading,", () {
36 test("cleans up if killed while loading a VM test", () async { 36 test("cleans up if killed while loading a VM test", () async {
37 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 37 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
38 void main() { 38 void main() {
39 print("in test.dart"); 39 print("in test.dart");
40 // Spin for a long time so the test is probably killed while still loading. 40 // Spin for a long time so the test is probably killed while still loading.
41 for (var i = 0; i < 100000000; i++) {} 41 for (var i = 0; i < 100000000; i++) {}
42 } 42 }
43 """); 43 """);
44 44
45 var process = await _startTest(["test.dart"]); 45 var process = await _startTest(["-r", "expanded", "test.dart"]);
46 var line = await lineSplitter.bind(process.stdout).first; 46
47 // Skip a progress line.
48 var line = await lineSplitter.bind(process.stdout).skip(1).first;
47 expect(line, equals("in test.dart")); 49 expect(line, equals("in test.dart"));
48 process.kill(); 50 process.kill();
49 await process.exitCode; 51 await process.exitCode;
50 expect(new Directory(_tempDir).listSync(), isEmpty); 52 expect(new Directory(_tempDir).listSync(), isEmpty);
51 }); 53 });
52 54
53 test("cleans up if killed while loading a browser test", () async { 55 test("cleans up if killed while loading a browser test", () async {
54 new File(p.join(_sandbox, "test.dart")) 56 new File(p.join(_sandbox, "test.dart"))
55 .writeAsStringSync("void main() {}"); 57 .writeAsStringSync("void main() {}");
56 58
57 var process = await _startTest(["-p", "chrome", "test.dart"]); 59 var process = await _startTest(
60 ["-r", "expanded", "-p", "chrome", "test.dart"]);
58 var line = await lineSplitter.bind(process.stdout).first; 61 var line = await lineSplitter.bind(process.stdout).first;
59 expect(line, equals("Compiling test.dart...")); 62 expect(line, endsWith("compiling test.dart"));
60 process.kill(); 63 process.kill();
61 await process.exitCode; 64 await process.exitCode;
62 expect(new Directory(_tempDir).listSync(), isEmpty); 65 expect(new Directory(_tempDir).listSync(), isEmpty);
63 }); 66 });
64 67
65 test("exits immediately if ^C is sent twice", () async { 68 test("exits immediately if ^C is sent twice", () async {
66 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 69 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
67 void main() { 70 void main() {
68 print("in test.dart"); 71 print("in test.dart");
69 while (true) {} 72 while (true) {}
70 } 73 }
71 """); 74 """);
72 75
73 var process = await _startTest(["test.dart"]); 76 var process = await _startTest(["-r", "expanded", "test.dart"]);
74 var line = await lineSplitter.bind(process.stdout).first; 77
78 // Skip a progress line.
79 var line = await lineSplitter.bind(process.stdout).skip(1).first;
75 expect(line, equals("in test.dart")); 80 expect(line, equals("in test.dart"));
76 process.kill(); 81 process.kill();
77 82
78 // TODO(nweiz): Sending two signals in close succession can cause the 83 // TODO(nweiz): Sending two signals in close succession can cause the
79 // second one to be ignored, so we wait a bit before the second 84 // second one to be ignored, so we wait a bit before the second
80 // one. Remove this hack when issue 23047 is fixed. 85 // one. Remove this hack when issue 23047 is fixed.
81 await new Future.delayed(new Duration(seconds: 1)); 86 await new Future.delayed(new Duration(seconds: 1));
82 process.kill(); 87 process.kill();
83 await process.exitCode; 88 await process.exitCode;
84 expect(new Directory(_tempDir).listSync(), isEmpty); 89 expect(new Directory(_tempDir).listSync(), isEmpty);
(...skipping 11 matching lines...) Expand all
96 void main() { 101 void main() {
97 tearDown(() => new File("output").writeAsStringSync("ran teardown")); 102 tearDown(() => new File("output").writeAsStringSync("ran teardown"));
98 103
99 test("test", () { 104 test("test", () {
100 print("running test"); 105 print("running test");
101 return new Future.delayed(new Duration(seconds: 1)); 106 return new Future.delayed(new Duration(seconds: 1));
102 }); 107 });
103 } 108 }
104 """); 109 """);
105 110
106 var process = await _startTest(["test.dart"]); 111 var process = await _startTest(["-r", "expanded", "test.dart"]);
107 var line = await lineSplitter.bind(process.stdout).skip(2).first; 112
113 // Skip a progress line.
114 var line = await lineSplitter.bind(process.stdout).skip(1).first;
108 expect(line, equals("running test")); 115 expect(line, equals("running test"));
109 process.kill(); 116 process.kill();
110 await process.exitCode; 117 await process.exitCode;
111 expect(new File(p.join(_sandbox, "output")).readAsStringSync(), 118 expect(new File(p.join(_sandbox, "output")).readAsStringSync(),
112 equals("ran teardown")); 119 equals("ran teardown"));
113 expect(new Directory(_tempDir).listSync(), isEmpty); 120 expect(new Directory(_tempDir).listSync(), isEmpty);
114 }); 121 });
115 122
116 test("kills a browser test immediately", () async { 123 test("kills a browser test immediately", () async {
117 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 124 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
118 import 'dart:async'; 125 import 'dart:async';
119 126
120 import 'package:test/test.dart'; 127 import 'package:test/test.dart';
121 128
122 void main() { 129 void main() {
123 test("test", () { 130 test("test", () {
124 print("running test"); 131 print("running test");
125 132
126 // Allow an event loop to pass so the preceding print can be handled. 133 // Allow an event loop to pass so the preceding print can be handled.
127 return new Future(() { 134 return new Future(() {
128 // Loop forever so that if the test isn't stopped while running, it never 135 // Loop forever so that if the test isn't stopped while running, it never
129 // stops. 136 // stops.
130 while (true) {} 137 while (true) {}
131 }); 138 });
132 }); 139 });
133 } 140 }
134 """); 141 """);
135 142
136 var process = await _startTest(["-p", "content-shell", "test.dart"]); 143 var process = await _startTest(
137 // The first line is blank, and the second is a status line from the 144 ["-r", "expanded", "-p", "content-shell", "test.dart"]);
138 // reporter. 145
139 var line = await lineSplitter.bind(process.stdout).skip(2).first; 146 // Skip a progress line..
147 var line = await lineSplitter.bind(process.stdout).skip(1).first;
140 expect(line, equals("running test")); 148 expect(line, equals("running test"));
141 process.kill(); 149 process.kill();
142 await process.exitCode; 150 await process.exitCode;
143 expect(new Directory(_tempDir).listSync(), isEmpty); 151 expect(new Directory(_tempDir).listSync(), isEmpty);
144 }); 152 });
145 153
146 test("kills a VM test immediately if ^C is sent twice", () async { 154 test("kills a VM test immediately if ^C is sent twice", () async {
147 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 155 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
148 import 'package:test/test.dart'; 156 import 'package:test/test.dart';
149 157
150 void main() { 158 void main() {
151 test("test", () { 159 test("test", () {
152 print("running test"); 160 print("running test");
153 while (true) {} 161 while (true) {}
154 }); 162 });
155 } 163 }
156 """); 164 """);
157 165
158 var process = await _startTest(["test.dart"]); 166 var process = await _startTest(["-r", "expanded", "test.dart"]);
159 var line = await lineSplitter.bind(process.stdout).skip(2).first; 167
168 // Skip a progress line.
169 var line = await lineSplitter.bind(process.stdout).skip(1).first;
160 expect(line, equals("running test")); 170 expect(line, equals("running test"));
161 process.kill(); 171 process.kill();
162 172
163 // TODO(nweiz): Sending two signals in close succession can cause the 173 // TODO(nweiz): Sending two signals in close succession can cause the
164 // second one to be ignored, so we wait a bit before the second 174 // second one to be ignored, so we wait a bit before the second
165 // one. Remove this hack when issue 23047 is fixed. 175 // one. Remove this hack when issue 23047 is fixed.
166 await new Future.delayed(new Duration(seconds: 1)); 176 await new Future.delayed(new Duration(seconds: 1));
167 process.kill(); 177 process.kill();
168 await process.exitCode; 178 await process.exitCode;
169 }); 179 });
(...skipping 18 matching lines...) Expand all
188 await new Future.delayed(new Duration(seconds: 1)); 198 await new Future.delayed(new Duration(seconds: 1));
189 try { 199 try {
190 expect(true, isTrue); 200 expect(true, isTrue);
191 } catch (_) { 201 } catch (_) {
192 expectThrewError = true; 202 expectThrewError = true;
193 } 203 }
194 }); 204 });
195 } 205 }
196 """); 206 """);
197 207
198 var process = await _startTest(["test.dart"]); 208 var process = await _startTest(["-r", "expanded", "test.dart"]);
199 var line = await lineSplitter.bind(process.stdout).skip(2).first; 209
210 // Skip a progress line.
211 var line = await lineSplitter.bind(process.stdout).skip(1).first;
200 expect(line, equals("running test")); 212 expect(line, equals("running test"));
201 process.kill(); 213 process.kill();
202 await process.exitCode; 214 await process.exitCode;
203 expect(new File(p.join(_sandbox, "output")).readAsStringSync(), 215 expect(new File(p.join(_sandbox, "output")).readAsStringSync(),
204 equals("true")); 216 equals("true"));
205 expect(new Directory(_tempDir).listSync(), isEmpty); 217 expect(new Directory(_tempDir).listSync(), isEmpty);
206 }); 218 });
207 219
208 test("causes expectAsync() to always throw an error immediately", () async { 220 test("causes expectAsync() to always throw an error immediately", () async {
209 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 221 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
(...skipping 15 matching lines...) Expand all
225 await new Future.delayed(new Duration(seconds: 1)); 237 await new Future.delayed(new Duration(seconds: 1));
226 try { 238 try {
227 expectAsync(() {}); 239 expectAsync(() {});
228 } catch (_) { 240 } catch (_) {
229 expectAsyncThrewError = true; 241 expectAsyncThrewError = true;
230 } 242 }
231 }); 243 });
232 } 244 }
233 """); 245 """);
234 246
235 var process = await _startTest(["test.dart"]); 247 var process = await _startTest(["-r", "expanded", "test.dart"]);
236 var line = await lineSplitter.bind(process.stdout).skip(2).first; 248
249 // Skip a progress line.
250 var line = await lineSplitter.bind(process.stdout).skip(1).first;
237 expect(line, equals("running test")); 251 expect(line, equals("running test"));
238 process.kill(); 252 process.kill();
239 await process.exitCode; 253 await process.exitCode;
240 expect(new File(p.join(_sandbox, "output")).readAsStringSync(), 254 expect(new File(p.join(_sandbox, "output")).readAsStringSync(),
241 equals("true")); 255 equals("true"));
242 expect(new Directory(_tempDir).listSync(), isEmpty); 256 expect(new Directory(_tempDir).listSync(), isEmpty);
243 }); 257 });
244 }); 258 });
245 } 259 }
246 260
247 Future<Process> _startTest(List<String> args) { 261 Future<Process> _startTest(List<String> args) {
248 new Directory(_tempDir).create(); 262 new Directory(_tempDir).create();
249 return startTest(args, workingDirectory: _sandbox, 263 return startTest(args, workingDirectory: _sandbox,
250 environment: {"_UNITTEST_TEMP_DIR": _tempDir}); 264 environment: {"_UNITTEST_TEMP_DIR": _tempDir});
251 } 265 }
OLDNEW
« lib/src/runner/load_suite.dart ('K') | « test/runner/runner_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698