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 library unittest.test.io; | 5 library test.test.io; |
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 | 11 |
12 /// The path to the root directory of the `unittest` package. | 12 /// The path to the root directory of the `test` package. |
13 final String packageDir = p.dirname(p.dirname(libraryPath(#unittest.test.io))); | 13 final String packageDir = p.dirname(p.dirname(libraryPath(#test.test.io))); |
14 | 14 |
15 /// Runs the unittest executable with the package root set properly. | 15 /// Runs the test executable with the package root set properly. |
16 ProcessResult runUnittest(List<String> args, {String workingDirectory, | 16 ProcessResult runUnittest(List<String> args, {String workingDirectory, |
17 Map<String, String> environment}) { | 17 Map<String, String> environment}) { |
18 var allArgs = [ | 18 var allArgs = [ |
19 p.absolute(p.join(packageDir, 'bin/unittest.dart')), | 19 p.absolute(p.join(packageDir, 'bin/test.dart')), |
20 "--package-root=${p.join(packageDir, 'packages')}" | 20 "--package-root=${p.join(packageDir, 'packages')}" |
21 ]..addAll(args); | 21 ]..addAll(args); |
22 | 22 |
23 if (environment == null) environment = {}; | 23 if (environment == null) environment = {}; |
24 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false"); | 24 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false"); |
25 | 25 |
26 // TODO(nweiz): Use ScheduledProcess once it's compatible. | 26 // TODO(nweiz): Use ScheduledProcess once it's compatible. |
27 return runDart(allArgs, workingDirectory: workingDirectory, | 27 return runDart(allArgs, workingDirectory: workingDirectory, |
28 environment: environment); | 28 environment: environment); |
29 } | 29 } |
30 | 30 |
31 /// Runs Dart. | 31 /// Runs Dart. |
32 ProcessResult runDart(List<String> args, {String workingDirectory, | 32 ProcessResult runDart(List<String> args, {String workingDirectory, |
33 Map<String, String> environment}) { | 33 Map<String, String> environment}) { |
34 var allArgs = Platform.executableArguments.toList()..addAll(args); | 34 var allArgs = Platform.executableArguments.toList()..addAll(args); |
35 | 35 |
36 // TODO(nweiz): Use ScheduledProcess once it's compatible. | 36 // TODO(nweiz): Use ScheduledProcess once it's compatible. |
37 return Process.runSync(Platform.executable, allArgs, | 37 return Process.runSync(Platform.executable, allArgs, |
38 workingDirectory: workingDirectory, environment: environment); | 38 workingDirectory: workingDirectory, environment: environment); |
39 } | 39 } |
OLD | NEW |