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

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

Issue 1243293002: Convert a bunch of tests to use scheduled_test's infrastructure. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 5 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/signal_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:scheduled_test/descriptor.dart' as d;
10 import 'package:scheduled_test/scheduled_stream.dart';
11 import 'package:scheduled_test/scheduled_test.dart';
10 import 'package:test/src/util/io.dart'; 12 import 'package:test/src/util/io.dart';
11 import 'package:test/test.dart';
12 13
13 import '../io.dart'; 14 import '../io.dart';
14 15
15 String _sandbox;
16
17 final _otherOS = Platform.isWindows ? "mac-os" : "windows"; 16 final _otherOS = Platform.isWindows ? "mac-os" : "windows";
18 17
19 void main() { 18 void main() {
20 setUp(() { 19 useSandbox();
21 _sandbox = createTempDir();
22 });
23
24 tearDown(() {
25 new Directory(_sandbox).deleteSync(recursive: true);
26 });
27 20
28 group("for suite", () { 21 group("for suite", () {
29 test("runs a test suite on a matching platform", () { 22 test("runs a test suite on a matching platform", () {
30 _writeTestFile("vm_test.dart", suiteTestOn: "vm"); 23 _writeTestFile("vm_test.dart", suiteTestOn: "vm");
31 24
32 var result = _runTest(["vm_test.dart"]); 25 var test = runTest(["vm_test.dart"]);
33 expect(result.stdout, contains("All tests passed!")); 26 test.stdout.expect(consumeThrough(contains("All tests passed!")));
34 expect(result.exitCode, equals(0)); 27 test.shouldExit(0);
35 }); 28 });
36 29
37 test("doesn't run a test suite on a non-matching platform", () { 30 test("doesn't run a test suite on a non-matching platform", () {
38 _writeTestFile("vm_test.dart", suiteTestOn: "vm"); 31 _writeTestFile("vm_test.dart", suiteTestOn: "vm");
39 32
40 var result = _runTest(["--platform", "content-shell", "vm_test.dart"]); 33 var test = runTest(["--platform", "content-shell", "vm_test.dart"]);
41 expect(result.stdout, contains("No tests ran.")); 34 test.stdout.expect(consumeThrough(contains("No tests ran.")));
42 expect(result.exitCode, equals(0)); 35 test.shouldExit(0);
43 }); 36 });
44 37
45 test("runs a test suite on a matching operating system", () { 38 test("runs a test suite on a matching operating system", () {
46 _writeTestFile("os_test.dart", suiteTestOn: currentOS.name); 39 _writeTestFile("os_test.dart", suiteTestOn: currentOS.name);
47 40
48 var result = _runTest(["os_test.dart"]); 41 var test = runTest(["os_test.dart"]);
49 expect(result.stdout, contains("All tests passed!")); 42 test.stdout.expect(consumeThrough(contains("All tests passed!")));
50 expect(result.exitCode, equals(0)); 43 test.shouldExit(0);
51 }); 44 });
52 45
53 test("doesn't run a test suite on a non-matching operating system", () { 46 test("doesn't run a test suite on a non-matching operating system", () {
54 _writeTestFile("os_test.dart", suiteTestOn: _otherOS, 47 _writeTestFile("os_test.dart", suiteTestOn: _otherOS,
55 loadable: false); 48 loadable: false);
56 49
57 var result = _runTest(["os_test.dart"]); 50 var test = runTest(["os_test.dart"]);
58 expect(result.stdout, contains("No tests ran.")); 51 test.stdout.expect(consumeThrough(contains("No tests ran.")));
59 expect(result.exitCode, equals(0)); 52 test.shouldExit(0);
60 }); 53 });
61 54
62 test("only loads matching files when loading as a group", () { 55 test("only loads matching files when loading as a group", () {
63 _writeTestFile("vm_test.dart", suiteTestOn: "vm"); 56 _writeTestFile("vm_test.dart", suiteTestOn: "vm");
64 _writeTestFile("browser_test.dart", 57 _writeTestFile("browser_test.dart",
65 suiteTestOn: "browser", loadable: false); 58 suiteTestOn: "browser", loadable: false);
66 _writeTestFile("this_os_test.dart", suiteTestOn: currentOS.name); 59 _writeTestFile("this_os_test.dart", suiteTestOn: currentOS.name);
67 _writeTestFile("other_os_test.dart", 60 _writeTestFile("other_os_test.dart",
68 suiteTestOn: _otherOS, loadable: false); 61 suiteTestOn: _otherOS, loadable: false);
69 62
70 var result = _runTest(["."]); 63 var test = runTest(["."]);
71 expect(result.stdout, contains("+2: All tests passed!")); 64 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
72 expect(result.exitCode, equals(0)); 65 test.shouldExit(0);
73 }); 66 });
74 }); 67 });
75 68
76 group("for group", () { 69 group("for group", () {
77 test("runs a VM group on the VM", () { 70 test("runs a VM group on the VM", () {
78 _writeTestFile("vm_test.dart", groupTestOn: "vm"); 71 _writeTestFile("vm_test.dart", groupTestOn: "vm");
79 72
80 var result = _runTest(["vm_test.dart"]); 73 var test = runTest(["vm_test.dart"]);
81 expect(result.stdout, contains("All tests passed!")); 74 test.stdout.expect(consumeThrough(contains("All tests passed!")));
82 expect(result.exitCode, equals(0)); 75 test.shouldExit(0);
83 }); 76 });
84 77
85 test("doesn't run a Browser group on the VM", () { 78 test("doesn't run a Browser group on the VM", () {
86 _writeTestFile("browser_test.dart", groupTestOn: "browser"); 79 _writeTestFile("browser_test.dart", groupTestOn: "browser");
87 80
88 var result = _runTest(["browser_test.dart"]); 81 var test = runTest(["browser_test.dart"]);
89 expect(result.stdout, contains("No tests ran.")); 82 test.stdout.expect(consumeThrough(contains("No tests ran.")));
90 expect(result.exitCode, equals(0)); 83 test.shouldExit(0);
91 }); 84 });
92 85
93 test("runs a browser group on a browser", () { 86 test("runs a browser group on a browser", () {
94 _writeTestFile("browser_test.dart", groupTestOn: "browser"); 87 _writeTestFile("browser_test.dart", groupTestOn: "browser");
95 88
96 var result = _runTest( 89 var test = runTest(
97 ["--platform", "content-shell", "browser_test.dart"]); 90 ["--platform", "content-shell", "browser_test.dart"]);
98 expect(result.stdout, contains("All tests passed!")); 91 test.stdout.expect(consumeThrough(contains("All tests passed!")));
99 expect(result.exitCode, equals(0)); 92 test.shouldExit(0);
100 }); 93 });
101 94
102 test("doesn't run a VM group on a browser", () { 95 test("doesn't run a VM group on a browser", () {
103 _writeTestFile("vm_test.dart", groupTestOn: "vm"); 96 _writeTestFile("vm_test.dart", groupTestOn: "vm");
104 97
105 var result = _runTest(["--platform", "content-shell", "vm_test.dart"]); 98 var test = runTest(["--platform", "content-shell", "vm_test.dart"]);
106 expect(result.stdout, contains("No tests ran.")); 99 test.stdout.expect(consumeThrough(contains("No tests ran.")));
107 expect(result.exitCode, equals(0)); 100 test.shouldExit(0);
108 }); 101 });
109 }); 102 });
110 103
111 group("for test", () { 104 group("for test", () {
112 test("runs a VM test on the VM", () { 105 test("runs a VM test on the VM", () {
113 _writeTestFile("vm_test.dart", testTestOn: "vm"); 106 _writeTestFile("vm_test.dart", testTestOn: "vm");
114 107
115 var result = _runTest(["vm_test.dart"]); 108 var test = runTest(["vm_test.dart"]);
116 expect(result.stdout, contains("All tests passed!")); 109 test.stdout.expect(consumeThrough(contains("All tests passed!")));
117 expect(result.exitCode, equals(0)); 110 test.shouldExit(0);
118 }); 111 });
119 112
120 test("doesn't run a browser test on the VM", () { 113 test("doesn't run a browser test on the VM", () {
121 _writeTestFile("browser_test.dart", testTestOn: "browser"); 114 _writeTestFile("browser_test.dart", testTestOn: "browser");
122 115
123 var result = _runTest(["browser_test.dart"]); 116 var test = runTest(["browser_test.dart"]);
124 expect(result.stdout, contains("No tests ran.")); 117 test.stdout.expect(consumeThrough(contains("No tests ran.")));
125 expect(result.exitCode, equals(0)); 118 test.shouldExit(0);
126 }); 119 });
127 120
128 test("runs a browser test on a browser", () { 121 test("runs a browser test on a browser", () {
129 _writeTestFile("browser_test.dart", testTestOn: "browser"); 122 _writeTestFile("browser_test.dart", testTestOn: "browser");
130 123
131 var result = _runTest( 124 var test = runTest(
132 ["--platform", "content-shell", "browser_test.dart"]); 125 ["--platform", "content-shell", "browser_test.dart"]);
133 expect(result.stdout, contains("All tests passed!")); 126 test.stdout.expect(consumeThrough(contains("All tests passed!")));
134 expect(result.exitCode, equals(0)); 127 test.shouldExit(0);
135 }); 128 });
136 129
137 test("doesn't run a VM test on a browser", () { 130 test("doesn't run a VM test on a browser", () {
138 _writeTestFile("vm_test.dart", testTestOn: "vm"); 131 _writeTestFile("vm_test.dart", testTestOn: "vm");
139 132
140 var result = _runTest(["--platform", "content-shell", "vm_test.dart"]); 133 var test = runTest(["--platform", "content-shell", "vm_test.dart"]);
141 expect(result.stdout, contains("No tests ran.")); 134 test.stdout.expect(consumeThrough(contains("No tests ran.")));
142 expect(result.exitCode, equals(0)); 135 test.shouldExit(0);
143 }); 136 });
144 }); 137 });
145 138
146 group("with suite, group, and test selectors", () { 139 group("with suite, group, and test selectors", () {
147 test("runs the test if all selectors match", () { 140 test("runs the test if all selectors match", () {
148 _writeTestFile("vm_test.dart", suiteTestOn: "!browser", 141 _writeTestFile("vm_test.dart", suiteTestOn: "!browser",
149 groupTestOn: "!js", testTestOn: "vm"); 142 groupTestOn: "!js", testTestOn: "vm");
150 143
151 var result = _runTest(["vm_test.dart"]); 144 var test = runTest(["vm_test.dart"]);
152 expect(result.stdout, contains("All tests passed!")); 145 test.stdout.expect(consumeThrough(contains("All tests passed!")));
153 expect(result.exitCode, equals(0)); 146 test.shouldExit(0);
154 }); 147 });
155 148
156 test("doesn't runs the test if the suite doesn't match", () { 149 test("doesn't runs the test if the suite doesn't match", () {
157 _writeTestFile("vm_test.dart", suiteTestOn: "browser", 150 _writeTestFile("vm_test.dart", suiteTestOn: "browser",
158 groupTestOn: "!js", testTestOn: "vm"); 151 groupTestOn: "!js", testTestOn: "vm");
159 152
160 var result = _runTest(["vm_test.dart"]); 153 var test = runTest(["vm_test.dart"]);
161 expect(result.stdout, contains("No tests ran.")); 154 test.stdout.expect(consumeThrough(contains("No tests ran.")));
162 expect(result.exitCode, equals(0)); 155 test.shouldExit(0);
163 }); 156 });
164 157
165 test("doesn't runs the test if the group doesn't match", () { 158 test("doesn't runs the test if the group doesn't match", () {
166 _writeTestFile("vm_test.dart", suiteTestOn: "!browser", 159 _writeTestFile("vm_test.dart", suiteTestOn: "!browser",
167 groupTestOn: "browser", testTestOn: "vm"); 160 groupTestOn: "browser", testTestOn: "vm");
168 161
169 var result = _runTest(["vm_test.dart"]); 162 var test = runTest(["vm_test.dart"]);
170 expect(result.stdout, contains("No tests ran.")); 163 test.stdout.expect(consumeThrough(contains("No tests ran.")));
171 expect(result.exitCode, equals(0)); 164 test.shouldExit(0);
172 }); 165 });
173 166
174 test("doesn't runs the test if the test doesn't match", () { 167 test("doesn't runs the test if the test doesn't match", () {
175 _writeTestFile("vm_test.dart", suiteTestOn: "!browser", 168 _writeTestFile("vm_test.dart", suiteTestOn: "!browser",
176 groupTestOn: "!js", testTestOn: "browser"); 169 groupTestOn: "!js", testTestOn: "browser");
177 170
178 var result = _runTest(["vm_test.dart"]); 171 var test = runTest(["vm_test.dart"]);
179 expect(result.stdout, contains("No tests ran.")); 172 test.stdout.expect(consumeThrough(contains("No tests ran.")));
180 expect(result.exitCode, equals(0)); 173 test.shouldExit(0);
181 }); 174 });
182 }); 175 });
183 } 176 }
184 177
185 /// Writes a test file with some platform selectors to [filename]. 178 /// Writes a test file with some platform selectors to [filename].
186 /// 179 ///
187 /// Each of [suiteTestOn], [groupTestOn], and [testTestOn] is a platform 180 /// Each of [suiteTestOn], [groupTestOn], and [testTestOn] is a platform
188 /// selector that's suite-, group-, and test-level respectively. If [loadable] 181 /// selector that's suite-, group-, and test-level respectively. If [loadable]
189 /// is `false`, the test file will be made unloadable on the Dart VM. 182 /// is `false`, the test file will be made unloadable on the Dart VM.
190 void _writeTestFile(String filename, {String suiteTestOn, String groupTestOn, 183 void _writeTestFile(String filename, {String suiteTestOn, String groupTestOn,
(...skipping 14 matching lines...) Expand all
205 } 198 }
206 199
207 if (groupTestOn != null) { 200 if (groupTestOn != null) {
208 buffer.writeln(" }, testOn: '$groupTestOn');"); 201 buffer.writeln(" }, testOn: '$groupTestOn');");
209 } else { 202 } else {
210 buffer.writeln(" });"); 203 buffer.writeln(" });");
211 } 204 }
212 205
213 buffer.writeln("}"); 206 buffer.writeln("}");
214 207
215 new File(p.join(_sandbox, filename)).writeAsStringSync(buffer.toString()); 208 d.file(filename, buffer.toString()).create();
216 } 209 }
217
218 ProcessResult _runTest(List<String> args) =>
219 runTest(args, workingDirectory: _sandbox);
OLDNEW
« no previous file with comments | « test/runner/signal_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698