Chromium Code Reviews| Index: tools/migration/bin/migrate_batch.dart |
| diff --git a/tools/migration/bin/migrate_batch.dart b/tools/migration/bin/migrate_batch.dart |
| index b0ae2b1f2722a5cf9940da0314a11dc39df77ed4..ca5ad7800fe2462ec60377c25c8b2bb478a3ddeb 100644 |
| --- a/tools/migration/bin/migrate_batch.dart |
| +++ b/tools/migration/bin/migrate_batch.dart |
| @@ -13,6 +13,7 @@ import 'dart:io'; |
| import 'package:path/path.dart' as p; |
| import 'package:migration/src/log.dart'; |
| +import 'package:status_file/status_file.dart'; |
| const simpleDirs = const ["corelib", "language", "lib"]; |
| @@ -62,15 +63,21 @@ void main(List<String> arguments) { |
| } |
| } |
| + if ((endIndex - startIndex) == 0) { |
| + print(bold("No tests to migrate.")); |
| + return; |
| + } |
| + |
| print("Migrating ${bold(endIndex - startIndex)} tests from ${bold(first)} " |
| "to ${bold(last)}..."); |
| print(""); |
| + tests = tests.getRange(startIndex, endIndex); |
| var todos = <String>[]; |
| var migratedTests = 0; |
| var unmigratedTests = 0; |
| - for (var i = startIndex; i < endIndex; i++) { |
| - if (tests[i].migrate(todos)) { |
| + for (var test in tests) { |
| + if (test.migrate(todos)) { |
| migratedTests++; |
| } else { |
| unmigratedTests++; |
| @@ -93,6 +100,50 @@ void main(List<String> arguments) { |
| print(summary); |
| todos.forEach(todo); |
| + |
| + // Print status file entries. |
| + var statusFileEntries = new StringBuffer(); |
| + var statusFiles = loadStatusFiles(); |
| + for (var statusFile in statusFiles) { |
| + statusFileEntries.write(printStatusFileEntries(tests, statusFile)); |
| + } |
| + |
| + new File("statuses.migration") |
| + .writeAsStringSync(statusFileEntries.toString()); |
| + print( |
| + bold("Wrote relevant test status file entries to 'statuses.migration'")); |
| +} |
| + |
| +/// Returns a [String] of the relevant status file entries associated with the |
| +/// tests in [tests] found in [statusFile]. |
| +String printStatusFileEntries(List<Fork> tests, StatusFile statusFile) { |
| + var statusFileEntries = new StringBuffer(); |
|
Bob Nystrom
2017/07/25 23:48:21
Instead of creating a new StringBuffer in each cal
bkonyi
2017/07/26 00:27:12
Done.
|
| + var filteredStatusFile = new StatusFile(statusFile.path); |
| + var testNames = <String>[]; |
| + for (var test in tests) { |
| + testNames.add(test.twoPath.split("/").last.split(".")[0]); |
| + } |
| + for (var section in statusFile.sections) { |
| + StatusSection currentSection = null; |
|
Bob Nystrom
2017/07/25 23:48:21
"= null" isn't needed.
https://www.dartlang.org/g
bkonyi
2017/07/26 00:27:12
Done.
|
| + for (var entry in section.entries) { |
| + for (var testName in testNames) { |
| + if (entry.path.contains(testName)) { |
| + if (currentSection == null) { |
| + currentSection = new StatusSection(section.condition); |
| + } |
| + currentSection.entries.add(entry); |
| + } |
| + } |
| + } |
| + if (currentSection != null) { |
| + filteredStatusFile.sections.add(currentSection); |
| + } |
| + } |
| + if (!filteredStatusFile.isEmpty) { |
| + statusFileEntries.writeln("Entries for status file ${statusFile.path}:"); |
| + statusFileEntries.writeln(filteredStatusFile.toString()); |
|
Bob Nystrom
2017/07/25 23:48:21
".toString()" isn't needed. StringBuffer.writeln()
bkonyi
2017/07/26 00:27:12
Done.
|
| + } |
| + return statusFileEntries.toString(); |
| } |
| String toTwoPath(String path) { |
| @@ -137,7 +188,6 @@ List<Fork> scanTests() { |
| var fromPath = p.relative(entry.path, from: testRoot); |
| var twoPath = p.join(twoDir, p.relative(fromPath, from: fromDir)); |
| - |
| var fork = tests.putIfAbsent(twoPath, () => new Fork(twoPath)); |
| if (fromDir.contains("_strong")) { |
| fork.strongPath = fromPath; |
| @@ -161,6 +211,34 @@ List<Fork> scanTests() { |
| return sorted; |
| } |
| +List<StatusFile> loadStatusFiles() { |
| + var statusFiles = <String, List<StatusFile>>{}; |
|
Bob Nystrom
2017/07/25 23:48:21
Looks like my suggestion was wrong and you don't a
bkonyi
2017/07/26 00:27:12
Done.
|
| + |
| + addStatusFile(String fromDir) { |
| + var statusFileList = statusFiles.putIfAbsent(fromDir, () => <StatusFile>[]); |
| + for (var entry |
| + in new Directory(p.join(testRoot, fromDir)).listSync(recursive: true)) { |
| + if (!entry.path.endsWith(".status")) continue; |
| + |
| + statusFileList.add(new StatusFile.read(entry.path)); |
| + } |
| + } |
| + |
| + addStatusFile("corelib"); |
| + addStatusFile("corelib_strong"); |
| + addStatusFile("html"); |
| + addStatusFile("isolate"); |
| + addStatusFile("language"); |
| + addStatusFile("language_strong"); |
| + addStatusFile("lib"); |
| + addStatusFile("lib_strong"); |
| + var statusFilesList = <StatusFile>[]; |
| + for (var list in statusFiles.values) { |
| + statusFilesList.addAll(list); |
| + } |
| + return statusFilesList; |
| +} |
| + |
| /// Moves the file from [from] to [to], which are both assumed to be relative |
| /// paths inside "tests". |
| void moveFile(String from, String to) { |