Index: sdk/lib/_internal/pub/lib/src/sdk.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/sdk.dart b/sdk/lib/_internal/pub/lib/src/sdk.dart |
index 65aaef6077c543e3a69014e73311fa963e072898..c99f516a3a57077265bba483aa0854240612d470 100644 |
--- a/sdk/lib/_internal/pub/lib/src/sdk.dart |
+++ b/sdk/lib/_internal/pub/lib/src/sdk.dart |
@@ -10,7 +10,6 @@ import 'dart:io'; |
import 'package:path/path.dart' as path; |
import 'io.dart'; |
-import 'log.dart' as log; |
import 'version.dart'; |
/// Matches an Eclipse-style SDK version number. This is four dotted numbers |
@@ -20,19 +19,14 @@ final _versionPattern = new RegExp(r'^(\d+)\.(\d+)\.(\d+)\.(\d+.*)$'); |
/// Gets the path to the root directory of the SDK. |
String get rootDirectory { |
- // If the environment variable was provided, use it. This is mainly used for |
- // the pub tests. |
- var dir = Platform.environment["DART_SDK"]; |
- if (dir != null) { |
- log.fine("Using DART_SDK to find SDK at $dir"); |
- return dir; |
- } |
- |
// Assume the Dart executable is always coming from the SDK. |
return path.dirname(path.dirname(Platform.executable)); |
} |
-/// Gets the SDK's revision number formatted to be a semantic version. |
+/// The SDK's revision number formatted to be a semantic version. |
+/// |
+/// This can be set so that the version solver tests can artificially select |
+/// different SDK versions. |
Version version = _getVersion(); |
/// Is `true` if the current SDK is an unreleased bleeding edge version. |
@@ -41,11 +35,8 @@ bool get isBleedingEdge { |
return version.major == 0 && version.minor == 1 && version.patch == 2; |
} |
-/// Determine the SDK's version number. |
-Version _getVersion() { |
- var revisionPath = path.join(rootDirectory, "version"); |
- var version = readTextFile(revisionPath).trim(); |
- |
+/// Parse an Eclipse-style version number using the SDK's versioning convention. |
+Version parseVersion(String version) { |
// Given a version file like: 0.1.2.0_r17495 |
// We create a semver like: 0.1.2+0.r17495 |
var match = _versionPattern.firstMatch(version); |
@@ -61,3 +52,17 @@ Version _getVersion() { |
int.parse(match[1]), int.parse(match[2]), int.parse(match[3]), |
build: build); |
} |
+ |
+/// Determine the SDK's version number. |
+Version _getVersion() { |
+ // Some of the pub integration tests require an SDK version number, but the |
+ // tests on the bots are not run from a built SDK so this lets us avoid |
+ // parsing the missing version file. |
+ var sdkVersion = Platform.environment["_PUB_TEST_SDK_VERSION"]; |
+ if (sdkVersion != null) return new Version.parse(sdkVersion); |
+ |
+ // Read the "version" file. |
+ var revisionPath = path.join(rootDirectory, "version"); |
+ var version = readTextFile(revisionPath).trim(); |
+ return parseVersion(version); |
+} |