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

Unified Diff: tools/migration/lib/src/fork.dart

Issue 2987223002: Add a script to run the tests in a migration block. (Closed)
Patch Set: Merge branch 'master' into run-tests Created 3 years, 5 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 | « tools/migration/bin/run_tests.dart ('k') | tools/migration/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/migration/lib/src/fork.dart
diff --git a/tools/migration/lib/src/fork.dart b/tools/migration/lib/src/fork.dart
index 4f2697e38d9df88c4a7b296b9b0b9a67c467e8aa..84a276b595e3a7f9e320bb161dddfaa6f6f30d54 100644
--- a/tools/migration/lib/src/fork.dart
+++ b/tools/migration/lib/src/fork.dart
@@ -11,6 +11,60 @@ import 'log.dart';
import 'test_directories.dart';
import 'validate.dart';
+int findFork(List<Fork> forks, String description) {
+ var matches = <int>[];
+
+ for (var i = 0; i < forks.length; i++) {
+ if (forks[i].twoPath.contains(description)) matches.add(i);
+ }
+
+ if (matches.isEmpty) {
+ print('Could not find a test matching "${bold(description)}".');
+ return null;
+ } else if (matches.length == 1) {
+ return matches.first;
+ } else {
+ print('Description "${bold(description)}" is ambiguous. Could be any of:');
+ for (var i in matches) {
+ print("- ${forks[i].twoPath.replaceAll(description, bold(description))}");
+ }
+
+ print("Please use a more precise description.");
+ return null;
+ }
+}
+
+/// Loads all of the unforked test files.
+///
+/// Creates an list of [Fork]s, ordered by their destination paths. Handles
+/// tests that only appear in one fork or the other, or both.
+List<Fork> scanTests() {
+ var tests = <String, Fork>{};
+
+ for (var fromDir in fromRootDirs) {
+ var twoDir = toTwoDirectory(fromDir);
+ for (var path in listFiles(fromDir)) {
+ var fromPath = p.relative(path, from: testRoot);
+ var twoPath = p.join(twoDir, p.relative(fromPath, from: fromDir));
+
+ tests.putIfAbsent(twoPath, () => new Fork(twoPath));
+ }
+ }
+
+ // Include tests that have already been migrated too so we can show what
+ // works remains to be done in them.
+ for (var dir in twoRootDirs) {
+ for (var path in listFiles(dir)) {
+ var twoPath = p.relative(path, from: testRoot);
+ tests.putIfAbsent(twoPath, () => new Fork(twoPath));
+ }
+ }
+
+ var sorted = tests.values.toList();
+ sorted.sort((a, b) => a.twoPath.compareTo(b.twoPath));
+ return sorted;
+}
+
/// Tracks one test and the various forked locations where it may appear.
///
/// * "One" refers to the original Dart 1.0 location of the test: language/,
« no previous file with comments | « tools/migration/bin/run_tests.dart ('k') | tools/migration/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698