-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run the Dart CLI tests from app snapshots on CI (#383)
This substantially speeds up the test time, and once we re-enable Dart 2 support is should work around dart-lang/sdk#33257.
- Loading branch information
Showing
13 changed files
with
122 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2018 Google Inc. Use of this source code is governed by an | ||
// MIT-style license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:path/path.dart' as p; | ||
|
||
/// Ensures that [path] (usually a compilation artifact) has been modified more | ||
/// recently than all this package's source files. | ||
/// | ||
/// If [path] isn't up-to-date, this throws an error encouraging the user to run | ||
/// [commandToRun]. | ||
void ensureUpToDate(String path, String commandToRun) { | ||
// Ensure path is relative so the error messages are more readable. | ||
path = p.relative(path); | ||
if (!new File(path).existsSync()) { | ||
throw "$path does not exist. Run $commandToRun."; | ||
} | ||
|
||
var lastModified = new File(path).lastModifiedSync(); | ||
var entriesToCheck = new Directory("lib").listSync(recursive: true).toList(); | ||
|
||
// If we have a dependency override, "pub run" will touch the lockfile to mark | ||
// it as newer than the pubspec, which makes it unsuitable to use for | ||
// freshness checking. | ||
if (new File("pubspec.yaml") | ||
.readAsStringSync() | ||
.contains("dependency_overrides")) { | ||
entriesToCheck.add(new File("pubspec.yaml")); | ||
} else { | ||
entriesToCheck.add(new File("pubspec.lock")); | ||
} | ||
|
||
for (var entry in entriesToCheck) { | ||
if (entry is File) { | ||
var entryLastModified = entry.lastModifiedSync(); | ||
if (lastModified.isBefore(entryLastModified)) { | ||
throw "${entry.path} was modified after ${p.prettyUri(p.toUri(path))} " | ||
"was generated.\n" | ||
"Run pub run grinder before_test."; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters