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:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
11 import 'package:test/src/util/io.dart'; | 11 import 'package:test/src/util/io.dart'; |
12 | 12 |
13 /// The path to the root directory of the `test` package. | 13 /// The path to the root directory of the `test` package. |
14 final String packageDir = p.dirname(p.dirname(libraryPath(#test.test.io))); | 14 final String packageDir = p.dirname(p.dirname(libraryPath(#test.test.io))); |
15 | 15 |
16 /// The path to the `pub` executable in the current Dart SDK. | 16 /// The path to the `pub` executable in the current Dart SDK. |
17 final _pubPath = p.join( | 17 final _pubPath = p.join( |
18 p.dirname(Platform.executable), | 18 p.dirname(Platform.executable), |
19 Platform.isWindows ? 'pub.bat' : 'pub'); | 19 Platform.isWindows ? 'pub.bat' : 'pub'); |
20 | 20 |
21 /// Runs the test executable with the package root set properly. | 21 /// Runs the test executable with the package root set properly. |
22 ProcessResult runUnittest(List<String> args, {String workingDirectory, | 22 ProcessResult runTest(List<String> args, {String workingDirectory, |
23 Map<String, String> environment}) { | 23 Map<String, String> environment}) { |
24 var allArgs = [ | 24 var allArgs = [ |
25 p.absolute(p.join(packageDir, 'bin/test.dart')), | 25 p.absolute(p.join(packageDir, 'bin/test.dart')), |
26 "--package-root=${p.join(packageDir, 'packages')}" | 26 "--package-root=${p.join(packageDir, 'packages')}" |
27 ]..addAll(args); | 27 ]..addAll(args); |
28 | 28 |
29 if (environment == null) environment = {}; | 29 if (environment == null) environment = {}; |
30 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false"); | 30 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false"); |
31 | 31 |
32 // TODO(nweiz): Use ScheduledProcess once it's compatible. | 32 // TODO(nweiz): Use ScheduledProcess once it's compatible. |
(...skipping 13 matching lines...) Expand all Loading... |
46 | 46 |
47 /// Runs Pub. | 47 /// Runs Pub. |
48 ProcessResult runPub(List<String> args, {String workingDirectory, | 48 ProcessResult runPub(List<String> args, {String workingDirectory, |
49 Map<String, String> environment}) { | 49 Map<String, String> environment}) { |
50 // TODO(nweiz): Use ScheduledProcess once it's compatible. | 50 // TODO(nweiz): Use ScheduledProcess once it's compatible. |
51 return Process.runSync(_pubPath, args, | 51 return Process.runSync(_pubPath, args, |
52 workingDirectory: workingDirectory, environment: environment); | 52 workingDirectory: workingDirectory, environment: environment); |
53 } | 53 } |
54 | 54 |
55 /// Starts the test executable with the package root set properly. | 55 /// Starts the test executable with the package root set properly. |
56 Future<Process> startUnittest(List<String> args, {String workingDirectory, | 56 Future<Process> startTest(List<String> args, {String workingDirectory, |
57 Map<String, String> environment}) { | 57 Map<String, String> environment}) { |
58 var allArgs = [ | 58 var allArgs = [ |
59 p.absolute(p.join(packageDir, 'bin/test.dart')), | 59 p.absolute(p.join(packageDir, 'bin/test.dart')), |
60 "--package-root=${p.join(packageDir, 'packages')}" | 60 "--package-root=${p.join(packageDir, 'packages')}" |
61 ]..addAll(args); | 61 ]..addAll(args); |
62 | 62 |
63 if (environment == null) environment = {}; | 63 if (environment == null) environment = {}; |
64 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false"); | 64 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false"); |
65 | 65 |
66 return startDart(allArgs, workingDirectory: workingDirectory, | 66 return startDart(allArgs, workingDirectory: workingDirectory, |
(...skipping 10 matching lines...) Expand all Loading... |
77 workingDirectory: workingDirectory, environment: environment); | 77 workingDirectory: workingDirectory, environment: environment); |
78 } | 78 } |
79 | 79 |
80 /// Starts Pub. | 80 /// Starts Pub. |
81 Future<Process> startPub(List<String> args, {String workingDirectory, | 81 Future<Process> startPub(List<String> args, {String workingDirectory, |
82 Map<String, String> environment}) { | 82 Map<String, String> environment}) { |
83 // TODO(nweiz): Use ScheduledProcess once it's compatible. | 83 // TODO(nweiz): Use ScheduledProcess once it's compatible. |
84 return Process.start(_pubPath, args, | 84 return Process.start(_pubPath, args, |
85 workingDirectory: workingDirectory, environment: environment); | 85 workingDirectory: workingDirectory, environment: environment); |
86 } | 86 } |
OLD | NEW |