| 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/,
|
|
|