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

Unified Diff: sdk/lib/_internal/pub/test/test_pub.dart

Issue 472173004: Skeleton code for running the forthcoming async/await compiler on pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
Index: sdk/lib/_internal/pub/test/test_pub.dart
diff --git a/sdk/lib/_internal/pub/test/test_pub.dart b/sdk/lib/_internal/pub/test/test_pub.dart
index ff5d9f9db1aebe6e56d5e2059722ce075e36ac57..77cac39731d453ebb352da1d048e205c78a28581 100644
--- a/sdk/lib/_internal/pub/test/test_pub.dart
+++ b/sdk/lib/_internal/pub/test/test_pub.dart
@@ -606,6 +606,37 @@ void confirmPublish(ScheduledProcess pub) {
pub.writeLine("y");
}
+/// Whether the async/await compiler has already been run.
+///
+/// If a test suite runs pub more than once, we only need to run the compiler
+/// the first time.
+// TODO(rnystrom): Remove this when #104 is fixed.
+bool _compiledAsync = false;
+
+/// Gets the path to the pub entrypoint Dart script to run.
+// TODO(rnystrom): This exists to run the async/await compiler on pub and then
+// get the path to the output of that. Once #104 is fixed, remove this.
+String _getPubPath(String dartBin) {
+ var buildDir = path.join(path.dirname(dartBin), '../../');
+
+ // Run the async/await compiler if needed.
nweiz 2014/08/22 19:29:16 When I first read this, I was confused as to why e
Bob Nystrom 2014/08/25 17:40:00 Done.
+ if (!_compiledAsync) {
+ var result = Process.runSync(dartBin, [
+ '--package-root=$_packageRoot/',
+ path.join(testDirectory, '..', 'bin', 'async_compile.dart'),
+ buildDir,
+ '--silent'
+ ]);
+ stdout.write(result.stdout);
+ stderr.write(result.stderr);
+ if (result.exitCode != 0) fail("Async/await compiler failed.");
+
+ _compiledAsync = true;
+ }
+
+ return path.join(buildDir, 'pub_async/bin/pub.dart');
+}
+
/// Starts a Pub process and returns a [ScheduledProcess] that supports
/// interaction with that process.
///
@@ -628,7 +659,10 @@ ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) {
}
// Find the main pub entrypoint.
- var pubPath = path.join(testDirectory, '..', 'bin', 'pub.dart');
+ var pubPath = _getPubPath(dartBin);
+ // TODO(rnystrom): Replace the above line with the following when #104 is
+ // fixed.
+ //var pubPath = path.join(testDirectory, '..', 'bin', 'pub.dart');
var dartArgs = ['--package-root=$_packageRoot/', '--checked', pubPath,
'--verbose'];

Powered by Google App Engine
This is Rietveld 408576698