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 unittest.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:stack_trace/stack_trace.dart'; | 10 import 'package:stack_trace/stack_trace.dart'; |
11 | 11 |
12 /// The root directory of the `unittest` package. | 12 /// The root directory of the `unittest` package. |
13 final String packageDir = _computePackageDir(); | 13 final String packageDir = _computePackageDir(); |
14 String _computePackageDir() { | 14 String _computePackageDir() { |
15 var trace = new Trace.current(); | 15 var trace = new Trace.current(); |
16 return p.dirname(p.dirname(p.fromUri(trace.frames.first.uri))); | 16 return p.dirname(p.dirname(p.fromUri(trace.frames.first.uri))); |
17 } | 17 } |
18 | 18 |
19 /// Runs the unittest executable with the package root set properly. | 19 /// Runs the unittest executable with the package root set properly. |
20 ProcessResult runUnittest(List<String> args, {String workingDirectory}) { | 20 ProcessResult runUnittest(List<String> args, {String workingDirectory}) { |
21 var allArgs = Platform.executableArguments.toList() | 21 var allArgs = [ |
22 ..add(p.join(packageDir, 'bin/unittest.dart')) | 22 p.join(packageDir, 'bin/unittest.dart'), |
23 ..add("--package-root=${p.join(packageDir, 'packages')}") | 23 "--package-root=${p.join(packageDir, 'packages')}" |
24 ..addAll(args); | 24 ]..addAll(args); |
| 25 |
| 26 // TODO(nweiz): Use ScheduledProcess once it's compatible. |
| 27 return runDart(allArgs, workingDirectory: workingDirectory); |
| 28 } |
| 29 |
| 30 /// Runs Dart. |
| 31 ProcessResult runDart(List<String> args, {String workingDirectory}) { |
| 32 var allArgs = Platform.executableArguments.toList()..addAll(args); |
25 | 33 |
26 // TODO(nweiz): Use ScheduledProcess once it's compatible. | 34 // TODO(nweiz): Use ScheduledProcess once it's compatible. |
27 return Process.runSync(Platform.executable, allArgs, | 35 return Process.runSync(Platform.executable, allArgs, |
28 workingDirectory: workingDirectory); | 36 workingDirectory: workingDirectory); |
29 } | 37 } |
OLD | NEW |