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

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

Issue 1080103002: Add support for running tests on Dartium. (Closed) Base URL: git@github.com:dart-lang/test@wip.dartium
Patch Set: Code review changes 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') | 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 @TestOn("vm") 5 @TestOn("vm")
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 import 'package:test/src/util/io.dart'; 10 import 'package:test/src/util/io.dart';
11 import 'package:test/test.dart'; 11 import 'package:test/test.dart';
12 12
13 import '../../io.dart'; 13 import '../../io.dart';
14 14
15 String _sandbox; 15 String _sandbox;
16 16
17 final _success = """ 17 final _success = """
18 import 'dart:async'; 18 import 'dart:async';
19 19
20 import 'package:test/test.dart'; 20 import 'package:test/test.dart';
21 21
22 void main() { 22 void main() {
23 test("success", () {}); 23 test("success", () {});
24 } 24 }
25 """; 25 """;
26 26
27 final _failure = """
28 import 'dart:async';
29
30 import 'package:test/test.dart';
31
32 void main() {
33 test("failure", () => throw new TestFailure("oh no"));
34 }
35 """;
36
27 void main() { 37 void main() {
28 setUp(() { 38 setUp(() {
29 _sandbox = createTempDir(); 39 _sandbox = createTempDir();
30 }); 40 });
31 41
32 tearDown(() { 42 tearDown(() {
33 new Directory(_sandbox).deleteSync(recursive: true); 43 new Directory(_sandbox).deleteSync(recursive: true);
34 }); 44 });
35 45
36 group("fails gracefully if", () { 46 group("fails gracefully if", () {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 var result = _runUnittest(["-p", "chrome", "test.dart"]); 125 var result = _runUnittest(["-p", "chrome", "test.dart"]);
116 expect(result.exitCode, equals(0)); 126 expect(result.exitCode, equals(0));
117 }); 127 });
118 128
119 test("on Firefox", () { 129 test("on Firefox", () {
120 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success); 130 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success);
121 var result = _runUnittest(["-p", "firefox", "test.dart"]); 131 var result = _runUnittest(["-p", "firefox", "test.dart"]);
122 expect(result.exitCode, equals(0)); 132 expect(result.exitCode, equals(0));
123 }); 133 });
124 134
135 test("on Dartium", () {
136 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success);
137 var result = _runUnittest(["-p", "dartium", "test.dart"]);
138 expect(result.stdout, isNot(contains("Compiling")));
139 expect(result.exitCode, equals(0));
140 });
141
125 test("on multiple browsers", () { 142 test("on multiple browsers", () {
126 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success); 143 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success);
127 var result = _runUnittest(["-p", "firefox", "-p", "chrome", "test.dart"]); 144 var result = _runUnittest(["-p", "firefox", "-p", "chrome", "test.dart"]);
128 expect("Compiling".allMatches(result.stdout), hasLength(1)); 145 expect("Compiling".allMatches(result.stdout), hasLength(1));
129 expect(result.exitCode, equals(0)); 146 expect(result.exitCode, equals(0));
130 }); 147 });
131 148
149 test("on a JS and non-JS browser", () {
150 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success);
151 var result = _runUnittest(["-p", "dartium", "-p", "chrome", "test.dart"]);
152 expect("Compiling".allMatches(result.stdout), hasLength(1));
153 expect(result.exitCode, equals(0));
154 });
155
132 test("on the browser and the VM", () { 156 test("on the browser and the VM", () {
133 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success); 157 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success);
134 var result = _runUnittest(["-p", "chrome", "-p", "vm", "test.dart"]); 158 var result = _runUnittest(["-p", "chrome", "-p", "vm", "test.dart"]);
135 expect(result.exitCode, equals(0)); 159 expect(result.exitCode, equals(0));
136 }); 160 });
137 }); 161 });
138 162
139 group("runs failing tests", () { 163 group("runs failing tests", () {
140 test("on Chrome", () { 164 test("on Chrome", () {
141 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 165 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_failure);
142 import 'dart:async';
143
144 import 'package:test/test.dart';
145
146 void main() {
147 test("failure", () => throw new TestFailure("oh no"));
148 }
149 """);
150 var result = _runUnittest(["-p", "chrome", "test.dart"]); 166 var result = _runUnittest(["-p", "chrome", "test.dart"]);
151 expect(result.exitCode, equals(1)); 167 expect(result.exitCode, equals(1));
152 }); 168 });
153 169
154 test("on Firefox", () { 170 test("on Firefox", () {
155 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 171 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_failure);
156 import 'dart:async'; 172 var result = _runUnittest(["-p", "firefox", "test.dart"]);
173 expect(result.exitCode, equals(1));
174 });
157 175
158 import 'package:test/test.dart'; 176 test("on Dartium", () {
159 177 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_failure);
160 void main() { 178 var result = _runUnittest(["-p", "dartium", "test.dart"]);
161 test("failure", () => throw new TestFailure("oh no"));
162 }
163 """);
164 var result = _runUnittest(["-p", "firefox", "test.dart"]);
165 expect(result.exitCode, equals(1)); 179 expect(result.exitCode, equals(1));
166 }); 180 });
167 181
168 test("that fail only on the browser", () { 182 test("that fail only on the browser", () {
169 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 183 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
170 import 'dart:async'; 184 import 'dart:async';
171 185
172 import 'package:path/path.dart' as p; 186 import 'package:path/path.dart' as p;
173 import 'package:test/test.dart'; 187 import 'package:test/test.dart';
174 188
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 """); 229 """);
216 230
217 var result = _runUnittest(["-p", "chrome", "test.dart"]); 231 var result = _runUnittest(["-p", "chrome", "test.dart"]);
218 expect(result.stdout, contains("Hello,\nworld!\n")); 232 expect(result.stdout, contains("Hello,\nworld!\n"));
219 expect(result.exitCode, equals(0)); 233 expect(result.exitCode, equals(0));
220 }); 234 });
221 } 235 }
222 236
223 ProcessResult _runUnittest(List<String> args) => 237 ProcessResult _runUnittest(List<String> args) =>
224 runUnittest(args, workingDirectory: _sandbox); 238 runUnittest(args, workingDirectory: _sandbox);
OLDNEW
« no previous file with comments | « test/runner/browser/dartium_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698