Migration: make --ignore-errors affect the "rerun" button.

Fixes #45665.

Bug: https://github.com/dart-lang/sdk/issues/45665
Change-Id: I8d238f5117fdaf8b7ffbe31dc8b1dfcb7a52a58d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195183
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
Paul Berry 2021-04-15 18:26:47 +00:00 committed by commit-bot@chromium.org
parent 4dc165f7fd
commit 1e68c47e68
2 changed files with 27 additions and 1 deletions

View file

@ -950,7 +950,7 @@ get erroneous migration suggestions.
_dartFixListener.reset();
_fixCodeProcessor.prepareToRerun();
var analysisResult = await _fixCodeProcessor.runFirstPhase();
if (analysisResult.hasErrors) {
if (analysisResult.hasErrors && !options.ignoreErrors) {
_logErrors(analysisResult);
return MigrationState(
_fixCodeProcessor._task.migration,

View file

@ -1272,6 +1272,32 @@ int f() => null;
});
}
test_lifecycle_preview_rerun_with_ignore_errors() async {
var origSourceText = 'void f(int i) {}';
var projectContents = simpleProject(sourceText: origSourceText);
var projectDir = createProjectDir(projectContents);
var cli = _createCli();
await runWithPreviewServer(cli, ['--ignore-errors', projectDir],
(url) async {
await assertPreviewServerResponsive(url);
var uri = Uri.parse(url);
var testPath =
resourceProvider.pathContext.join(projectDir, 'lib', 'test.dart');
resourceProvider.getFile(testPath).writeAsStringSync('void f(int? i) {}');
// We haven't rerun, so getting the file details from the server should
// still yield the original source text, with informational space.
expect(await getSourceFromServer(uri, testPath), 'void f(int i) {}');
var response = await httpPost(uri.replace(path: 'rerun-migration'),
headers: {'Content-Type': 'application/json; charset=UTF-8'});
assertHttpSuccess(response);
var body = jsonDecode(response.body);
expect(body['success'], isTrue);
expect(body['errors'], isNull);
// Now that we've rerun, the server should yield the new source text
expect(await getSourceFromServer(uri, testPath), 'void f(int? i) {}');
});
}
test_lifecycle_preview_rerun_with_new_analysis_errors() async {
var origSourceText = 'void f(int i) {}';
var projectContents = simpleProject(sourceText: origSourceText);