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'; |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 import 'package:unittest/src/util/io.dart'; | 10 import 'package:test/src/util/io.dart'; |
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 _otherOS = Platform.isWindows ? "mac-os" : "windows"; | 17 final _otherOS = Platform.isWindows ? "mac-os" : "windows"; |
18 | 18 |
19 void main() { | 19 void main() { |
20 setUp(() { | 20 setUp(() { |
21 _sandbox = Directory.systemTemp.createTempSync('unittest_').path; | 21 _sandbox = Directory.systemTemp.createTempSync('test_').path; |
22 }); | 22 }); |
23 | 23 |
24 tearDown(() { | 24 tearDown(() { |
25 new Directory(_sandbox).deleteSync(recursive: true); | 25 new Directory(_sandbox).deleteSync(recursive: true); |
26 }); | 26 }); |
27 | 27 |
28 group("for suite", () { | 28 group("for suite", () { |
29 test("runs a test suite on a matching platform", () { | 29 test("runs a test suite on a matching platform", () { |
30 _writeTestFile("vm_test.dart", suiteTestOn: "vm"); | 30 _writeTestFile("vm_test.dart", suiteTestOn: "vm"); |
31 | 31 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 /// Each of [suiteTestOn], [groupTestOn], and [testTestOn] is a platform | 185 /// Each of [suiteTestOn], [groupTestOn], and [testTestOn] is a platform |
186 /// selector that's suite-, group-, and test-level respectively. If [loadable] | 186 /// selector that's suite-, group-, and test-level respectively. If [loadable] |
187 /// is `false`, the test file will be made unloadable on the Dart VM. | 187 /// is `false`, the test file will be made unloadable on the Dart VM. |
188 void _writeTestFile(String filename, {String suiteTestOn, String groupTestOn, | 188 void _writeTestFile(String filename, {String suiteTestOn, String groupTestOn, |
189 String testTestOn, bool loadable: true}) { | 189 String testTestOn, bool loadable: true}) { |
190 var buffer = new StringBuffer(); | 190 var buffer = new StringBuffer(); |
191 if (suiteTestOn != null) buffer.writeln("@TestOn('$suiteTestOn')"); | 191 if (suiteTestOn != null) buffer.writeln("@TestOn('$suiteTestOn')"); |
192 if (!loadable) buffer.writeln("import 'dart:html';"); | 192 if (!loadable) buffer.writeln("import 'dart:html';"); |
193 | 193 |
194 buffer | 194 buffer |
195 ..writeln("import 'package:unittest/unittest.dart';") | 195 ..writeln("import 'package:test/test.dart';") |
196 ..writeln("void main() {") | 196 ..writeln("void main() {") |
197 ..writeln(" group('group', () {"); | 197 ..writeln(" group('group', () {"); |
198 | 198 |
199 if (testTestOn != null) { | 199 if (testTestOn != null) { |
200 buffer.writeln(" test('test', () {}, testOn: '$testTestOn');"); | 200 buffer.writeln(" test('test', () {}, testOn: '$testTestOn');"); |
201 } else { | 201 } else { |
202 buffer.writeln(" test('test', () {});"); | 202 buffer.writeln(" test('test', () {});"); |
203 } | 203 } |
204 | 204 |
205 if (groupTestOn != null) { | 205 if (groupTestOn != null) { |
206 buffer.writeln(" }, testOn: '$groupTestOn');"); | 206 buffer.writeln(" }, testOn: '$groupTestOn');"); |
207 } else { | 207 } else { |
208 buffer.writeln(" });"); | 208 buffer.writeln(" });"); |
209 } | 209 } |
210 | 210 |
211 buffer.writeln("}"); | 211 buffer.writeln("}"); |
212 | 212 |
213 new File(p.join(_sandbox, filename)).writeAsStringSync(buffer.toString()); | 213 new File(p.join(_sandbox, filename)).writeAsStringSync(buffer.toString()); |
214 } | 214 } |
215 | 215 |
216 ProcessResult _runUnittest(List<String> args) => | 216 ProcessResult _runUnittest(List<String> args) => |
217 runUnittest(args, workingDirectory: _sandbox); | 217 runUnittest(args, workingDirectory: _sandbox); |
OLD | NEW |