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

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

Issue 1053443002: Rename the package to "test". (Closed) Base URL: git@github.com:dart-lang/test@master
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/loader_test.dart ('k') | test/runner/compact_reporter_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: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:unittest/src/util/exit_codes.dart' as exit_codes; 10 import 'package:test/src/util/exit_codes.dart' as exit_codes;
11 import 'package:unittest/unittest.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:unittest/unittest.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 void main() { 27 void main() {
28 setUp(() { 28 setUp(() {
29 _sandbox = Directory.systemTemp.createTempSync('unittest_').path; 29 _sandbox = Directory.systemTemp.createTempSync('test_').path;
30 }); 30 });
31 31
32 tearDown(() { 32 tearDown(() {
33 new Directory(_sandbox).deleteSync(recursive: true); 33 new Directory(_sandbox).deleteSync(recursive: true);
34 }); 34 });
35 35
36 group("fails gracefully if", () { 36 group("fails gracefully if", () {
37 test("a test file fails to compile", () { 37 test("a test file fails to compile", () {
38 var testPath = p.join(_sandbox, "test.dart"); 38 var testPath = p.join(_sandbox, "test.dart");
39 new File(testPath).writeAsStringSync("invalid Dart file"); 39 new File(testPath).writeAsStringSync("invalid Dart file");
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 var result = _runUnittest(["-p", "chrome", "-p", "vm", "test.dart"]); 106 var result = _runUnittest(["-p", "chrome", "-p", "vm", "test.dart"]);
107 expect(result.exitCode, equals(0)); 107 expect(result.exitCode, equals(0));
108 }); 108 });
109 }); 109 });
110 110
111 group("runs failing tests", () { 111 group("runs failing tests", () {
112 test("on the browser only", () { 112 test("on the browser only", () {
113 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 113 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
114 import 'dart:async'; 114 import 'dart:async';
115 115
116 import 'package:unittest/unittest.dart'; 116 import 'package:test/test.dart';
117 117
118 void main() { 118 void main() {
119 test("failure", () => throw new TestFailure("oh no")); 119 test("failure", () => throw new TestFailure("oh no"));
120 } 120 }
121 """); 121 """);
122 var result = _runUnittest(["-p", "chrome", "test.dart"]); 122 var result = _runUnittest(["-p", "chrome", "test.dart"]);
123 expect(result.exitCode, equals(1)); 123 expect(result.exitCode, equals(1));
124 }); 124 });
125 125
126 test("that fail only on the browser", () { 126 test("that fail only on the browser", () {
127 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 127 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
128 import 'dart:async'; 128 import 'dart:async';
129 129
130 import 'package:path/path.dart' as p; 130 import 'package:path/path.dart' as p;
131 import 'package:unittest/unittest.dart'; 131 import 'package:test/test.dart';
132 132
133 void main() { 133 void main() {
134 test("test", () { 134 test("test", () {
135 if (p.style == p.Style.url) throw new TestFailure("oh no"); 135 if (p.style == p.Style.url) throw new TestFailure("oh no");
136 }); 136 });
137 } 137 }
138 """); 138 """);
139 var result = _runUnittest(["-p", "chrome", "-p", "vm", "test.dart"]); 139 var result = _runUnittest(["-p", "chrome", "-p", "vm", "test.dart"]);
140 expect(result.exitCode, equals(1)); 140 expect(result.exitCode, equals(1));
141 }); 141 });
142 142
143 test("that fail only on the VM", () { 143 test("that fail only on the VM", () {
144 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 144 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
145 import 'dart:async'; 145 import 'dart:async';
146 146
147 import 'package:path/path.dart' as p; 147 import 'package:path/path.dart' as p;
148 import 'package:unittest/unittest.dart'; 148 import 'package:test/test.dart';
149 149
150 void main() { 150 void main() {
151 test("test", () { 151 test("test", () {
152 if (p.style != p.Style.url) throw new TestFailure("oh no"); 152 if (p.style != p.Style.url) throw new TestFailure("oh no");
153 }); 153 });
154 } 154 }
155 """); 155 """);
156 var result = _runUnittest(["-p", "chrome", "-p", "vm", "test.dart"]); 156 var result = _runUnittest(["-p", "chrome", "-p", "vm", "test.dart"]);
157 expect(result.exitCode, equals(1)); 157 expect(result.exitCode, equals(1));
158 }); 158 });
159 }); 159 });
160 160
161 test("forwards prints from the browser test", () { 161 test("forwards prints from the browser test", () {
162 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" 162 new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
163 import 'dart:async'; 163 import 'dart:async';
164 164
165 import 'package:unittest/unittest.dart'; 165 import 'package:test/test.dart';
166 166
167 void main() { 167 void main() {
168 test("test", () { 168 test("test", () {
169 print("Hello,"); 169 print("Hello,");
170 return new Future(() => print("world!")); 170 return new Future(() => print("world!"));
171 }); 171 });
172 } 172 }
173 """); 173 """);
174 174
175 var result = _runUnittest(["-p", "chrome", "test.dart"]); 175 var result = _runUnittest(["-p", "chrome", "test.dart"]);
176 expect(result.stdout, contains("Hello,\nworld!\n")); 176 expect(result.stdout, contains("Hello,\nworld!\n"));
177 expect(result.exitCode, equals(0)); 177 expect(result.exitCode, equals(0));
178 }); 178 });
179 } 179 }
180 180
181 ProcessResult _runUnittest(List<String> args) => 181 ProcessResult _runUnittest(List<String> args) =>
182 runUnittest(args, workingDirectory: _sandbox); 182 runUnittest(args, workingDirectory: _sandbox);
OLDNEW
« no previous file with comments | « test/runner/browser/loader_test.dart ('k') | test/runner/compact_reporter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698