OLD | NEW |
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:convert'; | 7 import 'dart:convert'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 workingDirectory: _sandbox) | 129 workingDirectory: _sandbox) |
130 .then((process) { | 130 .then((process) { |
131 return _lines.bind(process.stdout) | 131 return _lines.bind(process.stdout) |
132 .firstWhere(_servingRegExp.hasMatch) | 132 .firstWhere(_servingRegExp.hasMatch) |
133 .then((line) { | 133 .then((line) { |
134 var match = _servingRegExp.firstMatch(line); | 134 var match = _servingRegExp.firstMatch(line); |
135 | 135 |
136 try { | 136 try { |
137 var result = runUnittest(['--pub-serve=${match[1]}'], | 137 var result = runUnittest(['--pub-serve=${match[1]}'], |
138 workingDirectory: _sandbox); | 138 workingDirectory: _sandbox); |
139 expect(result.stderr, contains( | 139 expect(result.stdout, allOf([ |
140 'Failed to load "test/my_test.dart":')); | 140 contains('-1: load error'), |
141 expect(result.stderr, contains('404 Not Found')); | 141 contains('Failed to load "test/my_test.dart":'), |
142 expect(result.stderr, contains( | 142 contains('404 Not Found'), |
143 'Make sure "pub serve" is serving the test/ directory.')); | 143 contains('Make sure "pub serve" is serving the test/ directory.') |
144 expect(result.exitCode, equals(exit_codes.data)); | 144 ])); |
| 145 expect(result.exitCode, equals(1)); |
145 } finally { | 146 } finally { |
146 process.kill(); | 147 process.kill(); |
147 } | 148 } |
148 }); | 149 }); |
149 }); | 150 }); |
150 }); | 151 }); |
151 | 152 |
152 test("gracefully handles pub serve running on the wrong directory for " | 153 test("gracefully handles pub serve running on the wrong directory for " |
153 "browser tests", () { | 154 "browser tests", () { |
154 new Directory(p.join(_sandbox, "web")).createSync(); | 155 new Directory(p.join(_sandbox, "web")).createSync(); |
155 | 156 |
156 return startPub(['serve', '--port', '0', 'web'], | 157 return startPub(['serve', '--port', '0', 'web'], |
157 workingDirectory: _sandbox) | 158 workingDirectory: _sandbox) |
158 .then((process) { | 159 .then((process) { |
159 return _lines.bind(process.stdout) | 160 return _lines.bind(process.stdout) |
160 .firstWhere(_servingRegExp.hasMatch) | 161 .firstWhere(_servingRegExp.hasMatch) |
161 .then((line) { | 162 .then((line) { |
162 var match = _servingRegExp.firstMatch(line); | 163 var match = _servingRegExp.firstMatch(line); |
163 | 164 |
164 try { | 165 try { |
165 var result = runUnittest( | 166 var result = runUnittest( |
166 ['--pub-serve=${match[1]}', '-p', 'chrome'], | 167 ['--pub-serve=${match[1]}', '-p', 'chrome'], |
167 workingDirectory: _sandbox); | 168 workingDirectory: _sandbox); |
168 expect(result.stderr, contains( | 169 expect(result.stdout, allOf([ |
169 'Failed to load "test/my_test.dart":')); | 170 contains('-1: load error'), |
170 expect(result.stderr, contains('404 Not Found')); | 171 contains('Failed to load "test/my_test.dart":'), |
171 expect(result.stderr, contains( | 172 contains('404 Not Found'), |
172 'Make sure "pub serve" is serving the test/ directory.')); | 173 contains('Make sure "pub serve" is serving the test/ directory.') |
173 expect(result.exitCode, equals(exit_codes.data)); | 174 ])); |
| 175 expect(result.exitCode, equals(1)); |
174 } finally { | 176 } finally { |
175 process.kill(); | 177 process.kill(); |
176 } | 178 } |
177 }); | 179 }); |
178 }); | 180 }); |
179 }); | 181 }); |
180 | 182 |
181 test("gracefully handles unconfigured transformers", () { | 183 test("gracefully handles unconfigured transformers", () { |
182 new File(p.join(_sandbox, "pubspec.yaml")).writeAsStringSync(""" | 184 new File(p.join(_sandbox, "pubspec.yaml")).writeAsStringSync(""" |
183 name: myapp | 185 name: myapp |
(...skipping 26 matching lines...) Expand all Loading... |
210 process.kill(); | 212 process.kill(); |
211 } | 213 } |
212 }); | 214 }); |
213 }); | 215 }); |
214 }); | 216 }); |
215 }); | 217 }); |
216 | 218 |
217 test("gracefully handles pub serve not running for VM tests", () { | 219 test("gracefully handles pub serve not running for VM tests", () { |
218 var result = runUnittest(['--pub-serve=54321'], | 220 var result = runUnittest(['--pub-serve=54321'], |
219 workingDirectory: _sandbox); | 221 workingDirectory: _sandbox); |
220 expect(result.stderr, equals(''' | 222 expect(result.stdout, allOf([ |
221 Failed to load "test/my_test.dart": | 223 contains('-1: load error'), |
222 Error getting http://localhost:54321/my_test.vm_test.dart: Connection refused | 224 contains(''' |
223 Make sure "pub serve" is running. | 225 Failed to load "test/my_test.dart": |
224 ''')); | 226 Error getting http://localhost:54321/my_test.vm_test.dart: Connection refused |
225 expect(result.exitCode, equals(exit_codes.data)); | 227 Make sure "pub serve" is running.''') |
| 228 ])); |
| 229 expect(result.exitCode, equals(1)); |
226 }); | 230 }); |
227 | 231 |
228 test("gracefully handles pub serve not running for browser tests", () { | 232 test("gracefully handles pub serve not running for browser tests", () { |
229 var result = runUnittest(['--pub-serve=54321', '-p', 'chrome'], | 233 var result = runUnittest(['--pub-serve=54321', '-p', 'chrome'], |
230 workingDirectory: _sandbox); | 234 workingDirectory: _sandbox); |
231 expect(result.stderr, matches(r''' | 235 expect(result.stdout, allOf([ |
232 Failed to load "test/my_test\.dart": | 236 contains('-1: load error'), |
233 Error getting http://localhost:54321/my_test\.browser_test.dart\.js: Connection
refused \(errno \d+\) | 237 contains('Failed to load "test/my_test.dart":'), |
234 Make sure "pub serve" is running\. | 238 contains('Error getting http://localhost:54321/my_test.browser_test.dart' |
235 ''')); | 239 '.js: Connection refused (errno '), |
236 expect(result.exitCode, equals(exit_codes.data)); | 240 contains('Make sure "pub serve" is running.') |
| 241 ])); |
| 242 expect(result.exitCode, equals(1)); |
237 }); | 243 }); |
238 | 244 |
239 test("gracefully handles a test file not being in test/", () { | 245 test("gracefully handles a test file not being in test/", () { |
240 new File(p.join(_sandbox, 'test/my_test.dart')) | 246 new File(p.join(_sandbox, 'test/my_test.dart')) |
241 .copySync(p.join(_sandbox, 'my_test.dart')); | 247 .copySync(p.join(_sandbox, 'my_test.dart')); |
242 | 248 |
243 var result = runUnittest(['--pub-serve=54321', 'my_test.dart'], | 249 var result = runUnittest(['--pub-serve=54321', 'my_test.dart'], |
244 workingDirectory: _sandbox); | 250 workingDirectory: _sandbox); |
245 expect(result.stderr, equals( | 251 expect(result.stdout, allOf([ |
246 'Failed to load "my_test.dart": When using "pub serve", all test files ' | 252 contains('-1: load error'), |
247 'must be in test/.\n')); | 253 contains( |
| 254 'Failed to load "my_test.dart": When using "pub serve", all test ' |
| 255 'files must be in test/.\n') |
| 256 ])); |
| 257 expect(result.exitCode, equals(1)); |
248 }); | 258 }); |
249 } | 259 } |
OLD | NEW |