Properly report dart format errors (#160364)

This applied the improvements from
https://github.com/flutter/engine/pull/57206 to the flutter/flutter
version of that script (hopefully, we can deduplicate this soon with the
repo merge).
This commit is contained in:
Michael Goderbauer
2024-12-16 15:35:01 -08:00
committed by GitHub
parent 4a6ae1ebab
commit 06dd9a3525
2 changed files with 49 additions and 3 deletions

View File

@@ -91,4 +91,22 @@ void main() {
fixture.gitRemove();
}
});
test('Prints error if dart formatter fails', () {
final TestFileFixture fixture = TestFileFixture(<FileContentPair>[], flutterRoot);
final io.File dartFile = io.File('${flutterRoot.path}/format_test2.dart');
dartFile.writeAsStringSync('P\n');
fixture.files.add(dartFile);
try {
fixture.gitAdd();
final io.ProcessResult result = io.Process.runSync(formatterPath, <String>[
'--fix',
], workingDirectory: flutterRoot.path);
expect(result.stdout, contains('format_test2.dart produced the following error'));
expect(result.exitCode, isNot(0));
} finally {
fixture.gitRemove();
}
});
}