mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:09:49 +00:00
Analyze both nnbd and non-nnbd concurrently when migrating tests.
Only write out the tests if the source files changed, so editors don't reload files that didn't actually change. Change-Id: Ifd8621e36aab88b6f0740881a6289bc392a0f52f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134841 Reviewed-by: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
parent
13ce2a8de4
commit
a739002cfa
|
@ -85,9 +85,9 @@ void _copyFiles(String testDir) {
|
|||
_showNextStep("Then use analyzer to migrate the files", "analyze", testDir);
|
||||
}
|
||||
|
||||
void _analyzeFiles(String testDir) {
|
||||
Future _analyzeFiles(String testDir) async {
|
||||
var toDir = p.join(testRoot, toNnbdPath(testDir));
|
||||
if (analyzeTests(toDir)) {
|
||||
if (await analyzeTests(toDir)) {
|
||||
print(
|
||||
"Next, commit the changed files and upload a new patchset with them:");
|
||||
print(bold(" git add ."));
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'package:path/path.dart' as p;
|
|||
import 'io.dart';
|
||||
import 'log.dart';
|
||||
|
||||
bool analyzeTests(String nnbdTestDir) {
|
||||
Future<bool> analyzeTests(String nnbdTestDir) async {
|
||||
var files = <String, _FileInfo>{};
|
||||
|
||||
for (var entry in Directory(nnbdTestDir).listSync(recursive: true)) {
|
||||
|
@ -28,8 +28,11 @@ bool analyzeTests(String nnbdTestDir) {
|
|||
}
|
||||
|
||||
// Analyze the directory both in legacy and NNBD modes.
|
||||
var legacyErrors = _runAnalyzer(nnbdTestDir, nnbd: false);
|
||||
var nnbdErrors = _runAnalyzer(nnbdTestDir, nnbd: true);
|
||||
var legacyErrorsFuture = _runAnalyzer(nnbdTestDir, nnbd: false);
|
||||
var nnbdErrorsFuture = _runAnalyzer(nnbdTestDir, nnbd: true);
|
||||
|
||||
var legacyErrors = await legacyErrorsFuture;
|
||||
var nnbdErrors = await nnbdErrorsFuture;
|
||||
|
||||
legacyErrors.forEach((path, errors) {
|
||||
// Sometimes the analysis reaches out to things like pkg/expect.
|
||||
|
@ -85,10 +88,11 @@ bool analyzeTests(String nnbdTestDir) {
|
|||
return errorCount == 0;
|
||||
}
|
||||
|
||||
Map<String, List<_StaticError>> _runAnalyzer(String inputDir, {bool nnbd}) {
|
||||
Future<Map<String, List<_StaticError>>> _runAnalyzer(String inputDir,
|
||||
{bool nnbd}) async {
|
||||
print("Analyzing ${p.relative(inputDir, from: testRoot)}"
|
||||
"${nnbd ? ' with NNBD' : ''}...");
|
||||
var result = Process.runSync("dartanalyzer", [
|
||||
var result = await Process.run("dartanalyzer", [
|
||||
"--packages=${p.join(sdkRoot, '.packages')}",
|
||||
if (nnbd) ...[
|
||||
"--dart-sdk=$nnbdSdkBuildDir",
|
||||
|
|
|
@ -83,7 +83,10 @@ void writeFile(String path, String contents) {
|
|||
return;
|
||||
}
|
||||
|
||||
File(p.join(testRoot, path)).writeAsStringSync(contents);
|
||||
final oldContents = File(p.join(testRoot, path)).readAsStringSync();
|
||||
if (oldContents != contents) {
|
||||
File(p.join(testRoot, path)).writeAsStringSync(contents);
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the contents of the files at [aPath] and [bPath] are identical.
|
||||
|
|
Loading…
Reference in a new issue