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

Unified Diff: test/test_pub.dart

Issue 1166783002: Factor in the Dart repo's state for snapshotting. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Hash the executable rather than the repo. Created 5 years, 7 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/test_pub.dart
diff --git a/test/test_pub.dart b/test/test_pub.dart
index 381f7381b7c39695b88c25af2463cce37b19ad8f..0c2a853b71bf2689e4af092c74f630ea791184a3 100644
--- a/test/test_pub.dart
+++ b/test/test_pub.dart
@@ -559,16 +559,21 @@ void _ensureSnapshot() {
ensureDir(p.join(pubRoot, '.pub'));
var version = sdk.version.toString();
- var hash = _hashChanges();
+ var pubHash = _hashChanges();
+ var dartHash = runningFromDartRepo ? _hashExecutable() : null;
var snapshotPath = p.join(pubRoot, '.pub', 'pub.test.snapshot');
- var hashPath = p.join(pubRoot, '.pub', 'pub.hash');
+ var pubHashPath = p.join(pubRoot, '.pub', 'pub.hash');
+ var dartHashPath = p.join(pubRoot, '.pub', 'dart.hash');
var versionPath = p.join(pubRoot, '.pub', 'pub.version');
- if (fileExists(hashPath) && fileExists(versionPath)) {
- var oldHash = readTextFile(hashPath);
+ if (fileExists(pubHashPath) && fileExists(versionPath) &&
+ (!runningFromDartRepo || fileExists(dartHashPath))) {
+ var oldPubHash = readTextFile(pubHashPath);
+ var oldDartHash = runningFromDartRepo ? readTextFile(dartHashPath) : null;
var oldVersion = readTextFile(versionPath);
- if (oldHash == hash && oldVersion == version && fileExists(snapshotPath)) {
+ if (oldPubHash == pubHash && oldDartHash == dartHash &&
+ oldVersion == version && fileExists(snapshotPath)) {
return;
}
}
@@ -582,7 +587,8 @@ void _ensureSnapshot() {
var dartSnapshot = runProcessSync(Platform.executable, args);
if (dartSnapshot.exitCode != 0) throw "Failed to run dart --snapshot.";
- writeTextFile(hashPath, hash);
+ writeTextFile(pubHashPath, pubHash);
+ if (runningFromDartRepo) writeTextFile(dartHashPath, dartHash);
writeTextFile(versionPath, version);
}
@@ -613,6 +619,16 @@ String _hashChanges() {
return CryptoUtils.bytesToHex(hash.close());
}
+/// Return a SHA1 hash of the Dart executable used to run this script.
+///
+/// This is used when running within the Dart repo to ensure that the snapshot
+/// is invalidated when the executable changes.
+String _hashExecutable() {
+ var hash = new SHA1();
+ hash.add(new File(Platform.executable).readAsBytesSync());
+ return CryptoUtils.bytesToHex(hash.close());
+}
+
/// A subclass of [ScheduledProcess] that parses pub's verbose logging output
/// and makes [stdout] and [stderr] work as though pub weren't running in
/// verbose mode.
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698