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

Side by Side Diff: test/runner/compact_reporter_test.dart

Issue 983573002: Add support for running browser tests to the test runner. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 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
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 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'package:path/path.dart' as p; 7 import 'package:path/path.dart' as p;
8 import 'package:unittest/src/util/io.dart'; 8 import 'package:unittest/src/util/io.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
11 import '../io.dart'; 11 import '../io.dart';
12 12
13 String _sandbox;
14
15 void main() { 13 void main() {
16 test("reports when no tests are run", () { 14 test("reports when no tests are run", () {
17 return withTempDir((path) { 15 return withTempDir((path) {
18 new File(p.join(path, "test.dart")).writeAsStringSync("void main() {}"); 16 new File(p.join(path, "test.dart")).writeAsStringSync("void main() {}");
19 var result = runUnittest(["test.dart"], workingDirectory: path); 17 var result = runUnittest(["test.dart"], workingDirectory: path);
20 expect(result.stdout, equals("No tests ran.\n")); 18 expect(result.stdout, equals("No tests ran.\n"));
21 }); 19 });
22 }); 20 });
23 21
24 test("runs several successful tests and reports when each completes", () { 22 test("runs several successful tests and reports when each completes", () {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 dart:async Future.Future.microtask 122 dart:async Future.Future.microtask
125 test.dart 12:15 main.<fn> 123 test.dart 12:15 main.<fn>
126 124
127 125
128 +0 -1: wait 126 +0 -1: wait
129 +1 -1: wait 127 +1 -1: wait
130 +1 -1: Some tests failed."""); 128 +1 -1: Some tests failed.""");
131 }); 129 });
132 } 130 }
133 131
134 final _prefixLength = "XX:XX ".length; 132 void _expectReport(String tests, String expected, {List<String> args}) {
135
136 void _expectReport(String tests, String expected) {
137 var dart = """ 133 var dart = """
138 import 'dart:async'; 134 import 'dart:async';
139 135
140 import 'package:unittest/unittest.dart'; 136 import 'package:unittest/unittest.dart';
141 137
142 void main() { 138 void main() {
143 $tests 139 $tests
144 } 140 }
145 """; 141 """;
146 142
147 expect(withTempDir((path) { 143 expect(withTempDir((path) {
148 new File(p.join(path, "test.dart")).writeAsStringSync(dart); 144 new File(p.join(path, "test.dart")).writeAsStringSync(dart);
149 var result = runUnittest(["test.dart"], workingDirectory: path); 145 if (args == null) args = [];
146 args = args.toList()..add("test.dart");
147 var result = runUnittest(args, workingDirectory: path);
150 148
151 // Convert CRs into newlines, remove excess trailing whitespace, and trim 149 // Convert CRs into newlines, remove excess trailing whitespace, and trim
152 // off timestamps. 150 // off timestamps.
153 var actual = result.stdout.trim().split(new RegExp(r"[\r\n]")).map((line) { 151 var actual = result.stdout.trim().split(new RegExp(r"[\r\n]")).map((line) {
154 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); 152 if (line.startsWith(" ") || line.isEmpty) return line.trimRight();
155 return line.trim().substring(_prefixLength); 153 return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), "");
156 }).join("\n"); 154 }).join("\n");
157 155
158 // Un-indent the expected string. 156 // Un-indent the expected string.
159 var indentation = expected.indexOf(new RegExp("[^ ]")); 157 var indentation = expected.indexOf(new RegExp("[^ ]"));
160 expected = expected.split("\n").map((line) { 158 expected = expected.split("\n").map((line) {
161 if (line.isEmpty) return line; 159 if (line.isEmpty) return line;
162 return line.substring(indentation); 160 return line.substring(indentation);
163 }).join("\n"); 161 }).join("\n");
164 162
165 expect(actual, equals(expected)); 163 expect(actual, equals(expected));
166 }), completes); 164 }), completes);
167 } 165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698