| 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:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; |
| 8 | 9 |
| 10 import 'package:path/path.dart' as p; |
| 9 import 'package:shelf/shelf.dart' as shelf; | 11 import 'package:shelf/shelf.dart' as shelf; |
| 10 import 'package:shelf/shelf_io.dart' as shelf_io; | 12 import 'package:shelf/shelf_io.dart' as shelf_io; |
| 11 import 'package:shelf_web_socket/shelf_web_socket.dart'; | 13 import 'package:shelf_web_socket/shelf_web_socket.dart'; |
| 12 import 'package:test/src/runner/browser/dartium.dart'; | 14 import 'package:test/src/runner/browser/dartium.dart'; |
| 13 import 'package:test/src/util/io.dart'; | 15 import 'package:test/src/util/io.dart'; |
| 14 import 'package:test/src/utils.dart'; | 16 import 'package:test/src/utils.dart'; |
| 15 import 'package:test/test.dart'; | 17 import 'package:test/test.dart'; |
| 16 | 18 |
| 19 import '../../io.dart'; |
| 17 import '../../utils.dart'; | 20 import '../../utils.dart'; |
| 18 | 21 |
| 22 String _sandbox; |
| 23 |
| 19 void main() { | 24 void main() { |
| 25 setUp(() { |
| 26 _sandbox = createTempDir(); |
| 27 }); |
| 28 |
| 29 tearDown(() { |
| 30 new Directory(_sandbox).deleteSync(recursive: true); |
| 31 }); |
| 32 |
| 20 group("running Dart", () { | 33 group("running Dart", () { |
| 21 // The Dart to serve in the server. | 34 // The Dart to serve in the server. |
| 22 var dart; | 35 var dart; |
| 23 | 36 |
| 24 var servePage = (request) { | 37 var servePage = (request) { |
| 25 var path = shelfUrl(request).path; | 38 var path = shelfUrl(request).path; |
| 26 | 39 |
| 27 if (path.isEmpty) { | 40 if (path.isEmpty) { |
| 28 return new shelf.Response.ok(""" | 41 return new shelf.Response.ok(""" |
| 29 <!doctype html> | 42 <!doctype html> |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return dartium.close().whenComplete(server.close); | 145 return dartium.close().whenComplete(server.close); |
| 133 }); | 146 }); |
| 134 }); | 147 }); |
| 135 | 148 |
| 136 test("reports an error in onExit", () { | 149 test("reports an error in onExit", () { |
| 137 var dartium = new Dartium("http://dart-lang.org", | 150 var dartium = new Dartium("http://dart-lang.org", |
| 138 executable: "_does_not_exist"); | 151 executable: "_does_not_exist"); |
| 139 expect(dartium.onExit, throwsA(isApplicationException(startsWith( | 152 expect(dartium.onExit, throwsA(isApplicationException(startsWith( |
| 140 "Failed to start Dartium: No such file or directory")))); | 153 "Failed to start Dartium: No such file or directory")))); |
| 141 }); | 154 }); |
| 155 |
| 156 test("can run successful tests", () { |
| 157 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" |
| 158 import 'package:test/test.dart'; |
| 159 |
| 160 void main() { |
| 161 test("success", () {}); |
| 142 } | 162 } |
| 163 """); |
| 164 |
| 165 var result = _runTest(["-p", "dartium", "test.dart"]); |
| 166 expect(result.stdout, isNot(contains("Compiling"))); |
| 167 expect(result.exitCode, equals(0)); |
| 168 }); |
| 169 |
| 170 test("can run failing tests", () { |
| 171 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" |
| 172 import 'package:test/test.dart'; |
| 173 |
| 174 void main() { |
| 175 test("failure", () => throw new TestFailure("oh no")); |
| 176 } |
| 177 """); |
| 178 |
| 179 var result = _runTest(["-p", "dartium", "test.dart"]); |
| 180 expect(result.exitCode, equals(1)); |
| 181 }); |
| 182 } |
| 183 |
| 184 ProcessResult _runTest(List<String> args) => |
| 185 runTest(args, workingDirectory: _sandbox); |
| OLD | NEW |