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

Side by Side Diff: test/runner/browser/firefox_test.dart

Issue 1088453004: Move browser tests that require installation into their own files. (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/browser/dartium_test.dart ('k') | test/runner/browser/phantom_js_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:io';
8 9
10 import 'package:path/path.dart' as p;
9 import 'package:test/test.dart'; 11 import 'package:test/test.dart';
10 import 'package:test/src/runner/browser/firefox.dart'; 12 import 'package:test/src/runner/browser/firefox.dart';
11 import 'package:test/src/util/io.dart'; 13 import 'package:test/src/util/io.dart';
12 import 'package:shelf/shelf.dart' as shelf; 14 import 'package:shelf/shelf.dart' as shelf;
13 import 'package:shelf/shelf_io.dart' as shelf_io; 15 import 'package:shelf/shelf_io.dart' as shelf_io;
14 import 'package:shelf_web_socket/shelf_web_socket.dart'; 16 import 'package:shelf_web_socket/shelf_web_socket.dart';
15 17
18 import '../../io.dart';
16 import '../../utils.dart'; 19 import '../../utils.dart';
17 20
21 String _sandbox;
22
18 void main() { 23 void main() {
24 setUp(() {
25 _sandbox = createTempDir();
26 });
27
28 tearDown(() {
29 new Directory(_sandbox).deleteSync(recursive: true);
30 });
31
19 group("running JavaScript", () { 32 group("running JavaScript", () {
20 // The JavaScript to serve in the server. We use actual JavaScript here to 33 // The JavaScript to serve in the server. We use actual JavaScript here to
21 // avoid the pain of compiling to JS in a test 34 // avoid the pain of compiling to JS in a test
22 var javaScript; 35 var javaScript;
23 36
24 var servePage = (request) { 37 var servePage = (request) {
25 var path = request.url.path; 38 var path = request.url.path;
26 39
27 // We support both shelf 0.5.x and 0.6.x. The former has a leading "/" 40 // We support both shelf 0.5.x and 0.6.x. The former has a leading "/"
28 // here, the latter does not. 41 // here, the latter does not.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return firefox.close().whenComplete(server.close); 145 return firefox.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 firefox = new Firefox("http://dart-lang.org", 150 var firefox = new Firefox("http://dart-lang.org",
138 executable: "_does_not_exist"); 151 executable: "_does_not_exist");
139 expect(firefox.onExit, throwsA(isApplicationException(startsWith( 152 expect(firefox.onExit, throwsA(isApplicationException(startsWith(
140 "Failed to start Firefox: No such file or directory")))); 153 "Failed to start Firefox: No such file or directory"))));
141 }); 154 });
155
156 group("can run successful tests", () {
157 setUp(() {
158 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
159 import 'package:test/test.dart';
160
161 void main() {
162 test("success", () {});
142 } 163 }
164 """);
165 });
166
167 test("itself", () {
168 var result = _runTest(["-p", "firefox", "test.dart"]);
169 expect(result.exitCode, equals(0));
170 });
171
172 test("alongside another browser", () {
173 var result = _runTest(["-p", "firefox", "-p", "chrome", "test.dart"]);
174 expect("Compiling".allMatches(result.stdout), hasLength(1));
175 expect(result.exitCode, equals(0));
176 });
177 });
178
179 test("can run failing tests", () {
180 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
181 import 'package:test/test.dart';
182
183 void main() {
184 test("failure", () => throw new TestFailure("oh no"));
185 }
186 """);
187
188 var result = _runTest(["-p", "firefox", "test.dart"]);
189 expect(result.exitCode, equals(1));
190 });
191 }
192
193 ProcessResult _runTest(List<String> args) =>
194 runTest(args, workingDirectory: _sandbox);
OLDNEW
« no previous file with comments | « test/runner/browser/dartium_test.dart ('k') | test/runner/browser/phantom_js_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698