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

Unified Diff: tools/migration/bin/migrate_batch.dart

Issue 2987773002: Migrated test block 25 to Dart 2.0. (Closed)
Patch Set: 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 | « tests/corelib_strong/set_to_string_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1556d92990c84c08f8d5b01949a2b52cfb871989 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:migration/src/status_file.dart';
jcollins 2017/07/25 15:33:12 This looks like changes from another branch? Shou
const simpleDirs = const ["corelib", "language", "lib"];
@@ -40,8 +41,13 @@ void main(List<String> arguments) {
exit(1);
}
- var first = toTwoPath(arguments[0]);
- var last = toTwoPath(arguments[1]);
+ var first = arguments[0];
+ var last = arguments[1];
+
+ print("Preparing to migrate tests from ${bold(first)} to ${bold(last)}...");
+
+ first = toTwoPath(first);
+ last = toTwoPath(last);
var tests = scanTests();
@@ -62,6 +68,11 @@ 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("");
@@ -93,6 +104,38 @@ void main(List<String> arguments) {
print(summary);
todos.forEach(todo);
+
+ // Print status file entries.
+ var statusFileEntries = "";
+ for (var i = startIndex; i < endIndex; i++) {
+ statusFileEntries += printStatusFileEntries(tests[i]);
+ }
+
+ new File("statuses.migration").writeAsStringSync(statusFileEntries);
+ print(
+ bold("Wrote relevant test status file entries to 'statuses.migration'"));
+}
+
+String printStatusFileEntries(Fork test) {
+ var statusFileEntries = "";
+ if (test.onePath != null && !test.oneStatusFile.isEmpty) {
+ statusFileEntries +=
+ bold("Status file entries for: ${test.onePath}") + "\n";
+ for (var section in test.oneStatusFile.sections) {
+ statusFileEntries += section.toString();
+ }
+ }
+ if (test.strongPath != null && !test.strongStatusFile.isEmpty) {
+ if (statusFileEntries != "") {
+ statusFileEntries += "\n";
+ }
+ statusFileEntries +=
+ bold("Status file entries for: ${test.strongPath}") + "\n";
+ for (var section in test.strongStatusFile.sections) {
+ statusFileEntries += section.toString();
+ }
+ }
+ return statusFileEntries;
}
String toTwoPath(String path) {
@@ -136,13 +179,17 @@ List<Fork> scanTests() {
if (!entry.path.endsWith("_test.dart")) continue;
var fromPath = p.relative(entry.path, from: testRoot);
+ var fromStatus = testRoot + "/$fromDir/${fromDir}.status";
+ var testName = entry.path.split("/").last.split(".")[0];
+ var statusFile = getStatusFileEntries(fromStatus, testName);
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;
+ fork.strongStatusFile = statusFile;
} else {
fork.onePath = fromPath;
+ fork.oneStatusFile = statusFile;
}
}
}
@@ -161,6 +208,26 @@ List<Fork> scanTests() {
return sorted;
}
+StatusFile getStatusFileEntries(String path, String test) {
+ final statusFile = new StatusFile.read(path);
+ final filteredStatusFile = new StatusFile(path);
+ for (var section in statusFile.sections) {
+ StatusSection currentSection = null;
+ for (var entry in section.entries) {
+ if (entry.contains(test)) {
+ if (currentSection == null) {
+ currentSection = new StatusSection(section.condition);
+ }
+ currentSection.entries.add(entry);
+ }
+ }
+ if (currentSection != null) {
+ filteredStatusFile.sections.add(currentSection);
+ }
+ }
+ return filteredStatusFile;
+}
+
/// Moves the file from [from] to [to], which are both assumed to be relative
/// paths inside "tests".
void moveFile(String from, String to) {
@@ -198,7 +265,9 @@ bool checkForUnitTest(String path, String source) {
class Fork {
final String twoPath;
String onePath;
+ StatusFile oneStatusFile;
String strongPath;
+ StatusFile strongStatusFile;
String get twoSource {
if (twoPath == null) return null;
« no previous file with comments | « tests/corelib_strong/set_to_string_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698