OLD | NEW |
---|---|
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'; |
kevmoo
2015/04/09 22:10:01
Update the expected output for help --platform to
nweiz
2015/04/09 22:24:55
Done.
| |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 import 'package:test/src/util/exit_codes.dart' as exit_codes; | 10 import 'package:test/src/util/exit_codes.dart' as exit_codes; |
11 import 'package:test/src/util/io.dart'; | 11 import 'package:test/src/util/io.dart'; |
12 import 'package:test/test.dart'; | 12 import 'package:test/test.dart'; |
13 | 13 |
14 import '../../io.dart'; | 14 import '../../io.dart'; |
15 | 15 |
16 String _sandbox; | 16 String _sandbox; |
17 | 17 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 'Failed to load "${p.relative(testPath, from: _sandbox)}": Top-level ' | 89 'Failed to load "${p.relative(testPath, from: _sandbox)}": Top-level ' |
90 'main() function takes arguments.\n')); | 90 'main() function takes arguments.\n')); |
91 expect(result.exitCode, equals(exit_codes.data)); | 91 expect(result.exitCode, equals(exit_codes.data)); |
92 }); | 92 }); |
93 | 93 |
94 // TODO(nweiz): test what happens when a test file is unreadable once issue | 94 // TODO(nweiz): test what happens when a test file is unreadable once issue |
95 // 15078 is fixed. | 95 // 15078 is fixed. |
96 }); | 96 }); |
97 | 97 |
98 group("runs successful tests", () { | 98 group("runs successful tests", () { |
99 test("on the browser only", () { | 99 test("on Chrome", () { |
100 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success); | 100 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success); |
101 var result = _runUnittest(["-p", "chrome", "test.dart"]); | 101 var result = _runUnittest(["-p", "chrome", "test.dart"]); |
102 expect(result.exitCode, equals(0)); | 102 expect(result.exitCode, equals(0)); |
103 }); | 103 }); |
104 | 104 |
105 test("on Firefox", () { | |
106 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success); | |
107 var result = _runUnittest(["-p", "firefox", "test.dart"]); | |
108 expect(result.exitCode, equals(0)); | |
109 }); | |
110 | |
105 test("on the browser and the VM", () { | 111 test("on the browser and the VM", () { |
106 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success); | 112 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_success); |
107 var result = _runUnittest(["-p", "chrome", "-p", "vm", "test.dart"]); | 113 var result = _runUnittest(["-p", "chrome", "-p", "vm", "test.dart"]); |
108 expect(result.exitCode, equals(0)); | 114 expect(result.exitCode, equals(0)); |
109 }); | 115 }); |
110 }); | 116 }); |
111 | 117 |
112 group("runs failing tests", () { | 118 group("runs failing tests", () { |
113 test("on the browser only", () { | 119 test("on Chrome", () { |
114 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" | 120 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" |
115 import 'dart:async'; | 121 import 'dart:async'; |
116 | 122 |
117 import 'package:test/test.dart'; | 123 import 'package:test/test.dart'; |
118 | 124 |
119 void main() { | 125 void main() { |
120 test("failure", () => throw new TestFailure("oh no")); | 126 test("failure", () => throw new TestFailure("oh no")); |
121 } | 127 } |
122 """); | 128 """); |
123 var result = _runUnittest(["-p", "chrome", "test.dart"]); | 129 var result = _runUnittest(["-p", "chrome", "test.dart"]); |
124 expect(result.exitCode, equals(1)); | 130 expect(result.exitCode, equals(1)); |
125 }); | 131 }); |
126 | 132 |
133 test("on Firefox", () { | |
134 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" | |
135 import 'dart:async'; | |
136 | |
137 import 'package:test/test.dart'; | |
138 | |
139 void main() { | |
140 test("failure", () => throw new TestFailure("oh no")); | |
141 } | |
142 """); | |
143 var result = _runUnittest(["-p", "firefox", "test.dart"]); | |
144 expect(result.exitCode, equals(1)); | |
145 }); | |
146 | |
127 test("that fail only on the browser", () { | 147 test("that fail only on the browser", () { |
128 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" | 148 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(""" |
129 import 'dart:async'; | 149 import 'dart:async'; |
130 | 150 |
131 import 'package:path/path.dart' as p; | 151 import 'package:path/path.dart' as p; |
132 import 'package:test/test.dart'; | 152 import 'package:test/test.dart'; |
133 | 153 |
134 void main() { | 154 void main() { |
135 test("test", () { | 155 test("test", () { |
136 if (p.style == p.Style.url) throw new TestFailure("oh no"); | 156 if (p.style == p.Style.url) throw new TestFailure("oh no"); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 """); | 194 """); |
175 | 195 |
176 var result = _runUnittest(["-p", "chrome", "test.dart"]); | 196 var result = _runUnittest(["-p", "chrome", "test.dart"]); |
177 expect(result.stdout, contains("Hello,\nworld!\n")); | 197 expect(result.stdout, contains("Hello,\nworld!\n")); |
178 expect(result.exitCode, equals(0)); | 198 expect(result.exitCode, equals(0)); |
179 }); | 199 }); |
180 } | 200 } |
181 | 201 |
182 ProcessResult _runUnittest(List<String> args) => | 202 ProcessResult _runUnittest(List<String> args) => |
183 runUnittest(args, workingDirectory: _sandbox); | 203 runUnittest(args, workingDirectory: _sandbox); |
OLD | NEW |