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

Unified Diff: utils/tests/pub/test_pub.dart

Issue 11187011: Add a Pub test that runs against the real Dart SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | « utils/tests/pub/install/sdk/check_out_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/test_pub.dart
diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart
index 2fcac50880bf6d502406384ce2033cfca24296d1..b5bad6734322f434122e523b2b363a09f453f5da 100644
--- a/utils/tests/pub/test_pub.dart
+++ b/utils/tests/pub/test_pub.dart
@@ -445,6 +445,12 @@ final String appPath = "myapp";
final String packagesPath = "$appPath/packages";
/**
+ * The path to the build directory of the Dart repository. This is only set if
+ * [ensureBuild] has been run for this test.
+ */
+String _buildPath;
+
+/**
* The type for callbacks that will be fired during [runPub]. Takes the sandbox
* directory as a parameter.
*/
@@ -509,12 +515,18 @@ String get testDirectory {
return new File(dir.toNativePath()).fullPathSync();
}
+/// Whether the tests are running on a build bot.
+bool get onBuildBot => Platform.environment.containsKey('BUILDBOT_BUILDERNAME');
+
/**
* Schedules a call to the Pub command-line utility. Runs Pub with [args] and
* validates that its results match [output], [error], and [exitCode].
+ *
+ * If [realSdk] is true, runs Pub against the real Dart SDK. [ensureBuild] must
+ * be called before this method if [realSdk] is true.
*/
void schedulePub({List<String> args, Pattern output, Pattern error,
- int exitCode: 0}) {
+ int exitCode: 0, bool realSdk: false}) {
_schedule((sandboxDir) {
String pathInSandbox(path) => join(getFullPath(sandboxDir), path);
@@ -538,7 +550,14 @@ void schedulePub({List<String> args, Pattern output, Pattern error,
var environment = new Map.from(Platform.environment);
environment['PUB_CACHE'] = pathInSandbox(cachePath);
- environment['DART_SDK'] = pathInSandbox(sdkPath);
+ if (realSdk) {
+ if (_buildPath == null) {
+ throw "Test error: expected a Dart build directory to exist.";
+ }
+ environment['DART_SDK'] = join(_buildPath, "dart-sdk");
+ } else {
+ environment['DART_SDK'] = pathInSandbox(sdkPath);
+ }
return runProcess(dartBin, dartArgs, workingDir: pathInSandbox(appPath),
environment: environment);
@@ -589,8 +608,7 @@ void runPub({List<String> args, Pattern output, Pattern error,
void ensureGit() {
_schedule((_) {
return isGitInstalled.transform((installed) {
- if (!installed &&
- !Platform.environment.containsKey('BUILDBOT_BUILDERNAME')) {
+ if (!installed && !onBuildBot) {
_abortScheduled = true;
}
return null;
@@ -598,6 +616,45 @@ void ensureGit() {
});
}
+/// Skips the current test if the Dart repository's build step has not been run.
+/// If we're running on a build bot, this will not skip the test.
+///
+/// This ensures that users don't need to have built Dart themselves to run the
+/// test, and that the test will always run on the build bot.
Bob Nystrom 2012/10/16 21:00:02 "and" -> "but"
nweiz 2012/10/16 21:09:24 Done.
+void ensureBuild() {
+ _schedule((_) {
+ return _findBuildDirectory().transform((dir) {
+ if (dir == null && !onBuildBot) {
+ _abortScheduled = true;
+ }
+ });
+ });
+}
+
+/// All possible names for the output directory of the Dart build.
+final List<String> _buildNames = [
+ 'ReleaseIA32', 'DebugIA32', 'ReleaseX64', 'DebugX64', 'ReleaseSIMARM',
+ 'DebugSIMARM', 'ReleaseARM', 'DebugARM'
+];
+
+/// Returns the path to the output directory of the Dart build, or null if none
+/// is found. This also sets [_buildPath] if a build directory is found.
+Future<String> _findBuildDirectory() {
+ if (_buildPath != null) return new Future.immediate(_buildPath);
+
+ var buildDirectories = _buildNames.map((name) =>
+ join(testDirectory, '../../../out', name));
Bob Nystrom 2012/10/16 21:00:02 This directory is only "out" on Linux. On Mac, it'
nweiz 2012/10/16 21:09:24 It's like they want this to be difficult :p. Fixed
+ return Futures.wait(buildDirectories.map(dirExists)).transform((found) {
+ for (var i = 0; i < found.length; i++) {
+ if (found[i]) {
+ _buildPath = buildDirectories[i];
+ return _buildPath;
+ }
+ }
+ return null;
+ });
+}
+
Future<Directory> _setUpSandbox() {
return createTempDir();
}
« no previous file with comments | « utils/tests/pub/install/sdk/check_out_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698