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 test.test.io; | 5 library test.test.io; |
6 | 6 |
| 7 import 'dart:async'; |
7 import 'dart:io'; | 8 import 'dart:io'; |
8 | 9 |
9 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
10 import 'package:test/src/util/io.dart'; | 11 import 'package:test/src/util/io.dart'; |
11 | 12 |
12 /// The path to the root directory of the `test` package. | 13 /// The path to the root directory of the `test` package. |
13 final String packageDir = p.dirname(p.dirname(libraryPath(#test.test.io))); | 14 final String packageDir = p.dirname(p.dirname(libraryPath(#test.test.io))); |
14 | 15 |
15 /// Runs the test executable with the package root set properly. | 16 /// Runs the test executable with the package root set properly. |
16 ProcessResult runUnittest(List<String> args, {String workingDirectory, | 17 ProcessResult runUnittest(List<String> args, {String workingDirectory, |
(...skipping 13 matching lines...) Expand all Loading... |
30 | 31 |
31 /// Runs Dart. | 32 /// Runs Dart. |
32 ProcessResult runDart(List<String> args, {String workingDirectory, | 33 ProcessResult runDart(List<String> args, {String workingDirectory, |
33 Map<String, String> environment}) { | 34 Map<String, String> environment}) { |
34 var allArgs = Platform.executableArguments.toList()..addAll(args); | 35 var allArgs = Platform.executableArguments.toList()..addAll(args); |
35 | 36 |
36 // TODO(nweiz): Use ScheduledProcess once it's compatible. | 37 // TODO(nweiz): Use ScheduledProcess once it's compatible. |
37 return Process.runSync(Platform.executable, allArgs, | 38 return Process.runSync(Platform.executable, allArgs, |
38 workingDirectory: workingDirectory, environment: environment); | 39 workingDirectory: workingDirectory, environment: environment); |
39 } | 40 } |
| 41 |
| 42 /// Starts the test executable with the package root set properly. |
| 43 Future<Process> startUnittest(List<String> args, {String workingDirectory, |
| 44 Map<String, String> environment}) { |
| 45 var allArgs = [ |
| 46 p.absolute(p.join(packageDir, 'bin/test.dart')), |
| 47 "--package-root=${p.join(packageDir, 'packages')}" |
| 48 ]..addAll(args); |
| 49 |
| 50 if (environment == null) environment = {}; |
| 51 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false"); |
| 52 |
| 53 return startDart(allArgs, workingDirectory: workingDirectory, |
| 54 environment: environment); |
| 55 } |
| 56 |
| 57 /// Starts Dart. |
| 58 Future<Process> startDart(List<String> args, {String workingDirectory, |
| 59 Map<String, String> environment}) { |
| 60 var allArgs = Platform.executableArguments.toList()..addAll(args); |
| 61 |
| 62 // TODO(nweiz): Use ScheduledProcess once it's compatible. |
| 63 return Process.start(Platform.executable, allArgs, |
| 64 workingDirectory: workingDirectory, environment: environment); |
| 65 } |
OLD | NEW |