Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Unified Diff: test/io.dart

Issue 2184543002: Use the package_resolver package. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pubspec.yaml ('k') | test/runner/browser/loader_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/io.dart
diff --git a/test/io.dart b/test/io.dart
index b89e40cb90916bcf5f8b41d6fe663dc5262114ae..331a220b38545ad6cf5213663178e6ec9b876fb9 100644
--- a/test/io.dart
+++ b/test/io.dart
@@ -8,7 +8,9 @@ library test.test.io;
import 'dart:async';
import 'dart:io';
+import 'dart:isolate';
+import 'package:package_resolver/package_resolver.dart';
import 'package:path/path.dart' as p;
import 'package:scheduled_test/descriptor.dart' as d;
import 'package:scheduled_test/scheduled_process.dart';
@@ -17,7 +19,7 @@ import 'package:scheduled_test/scheduled_test.dart';
import 'package:test/src/util/io.dart';
/// The path to the root directory of the `test` package.
-final String packageDir = p.dirname(p.dirname(libraryPath(#test.test.io)));
+final Future<String> packageDir = PackageResolver.current.packagePath('test');
/// The path to the `pub` executable in the current Dart SDK.
final _pubPath = p.absolute(p.join(
@@ -108,8 +110,7 @@ ScheduledProcess runTest(List<String> args, {String reporter,
concurrency ??= 1;
var allArgs = [
- p.absolute(p.join(packageDir, 'bin/test.dart')),
- "--package-root=${p.join(packageDir, 'packages')}",
+ packageDir.then((dir) => p.absolute(p.join(dir, 'bin/test.dart'))),
"--concurrency=$concurrency"
];
if (reporter != null) allArgs.add("--reporter=$reporter");
@@ -133,13 +134,12 @@ ScheduledProcess runTest(List<String> args, {String reporter,
/// Runs Dart.
ScheduledProcess runDart(List<String> args, {Map<String, String> environment,
String description}) {
- var allArgs = Platform.executableArguments.map((arg) {
- // The package root might be relative, so we need to make it absolute if
- // we're going to run in a different working directory.
- if (!arg.startsWith("--package-root=")) return arg;
- return "--package-root=" +
- p.absolute(p.fromUri(arg.substring("--package-root=".length)));
- }).toList()..addAll(args);
+ var allArgs = Platform.executableArguments
+ .where((arg) =>
+ !arg.startsWith("--package-root=") && !arg.startsWith("--packages="))
+ .toList()
+ ..add(PackageResolver.current.processArgument)
+ ..addAll(args);
return new ScheduledProcess.start(
p.absolute(Platform.resolvedExecutable), allArgs,
« no previous file with comments | « pubspec.yaml ('k') | test/runner/browser/loader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698