From e6683f0638a96617a51de004d7903cb95c8271eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20von=20der=20Ahe=CC=81?= Date: Tue, 16 Jan 2018 09:57:33 +0000 Subject: [PATCH] Don't crash when the delta is empty Change-Id: I322261faad1431b7b597094048a9f904d70c33ff Reviewed-on: https://dart-review.googlesource.com/34740 Reviewed-by: Vyacheslav Egorov Reviewed-by: Jens Johansen --- .../lib/src/fasta/incremental_compiler.dart | 2 +- .../test/fasta/incremental_hello_test.dart | 3 +++ pkg/front_end/test/fasta/incremental_test.dart | 15 ++++++++++++--- pkg/front_end/testcases/incremental.status | 9 ++++++++- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart index 5f6895824a3..9975660a4fd 100644 --- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart +++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart @@ -95,7 +95,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { return new Program( libraries: new List.from(userCode.loader.libraries), uriToSource: new Map.from(userCode.uriToSource)) - ..mainMethod = programWithDill.mainMethod; + ..mainMethod = programWithDill?.mainMethod; }); } diff --git a/pkg/front_end/test/fasta/incremental_hello_test.dart b/pkg/front_end/test/fasta/incremental_hello_test.dart index be5dca2c577..1b136101a3c 100644 --- a/pkg/front_end/test/fasta/incremental_hello_test.dart +++ b/pkg/front_end/test/fasta/incremental_hello_test.dart @@ -74,6 +74,9 @@ test({bool sdkFromSource}) async { // Expect that the new program contains exactly hello.dart Expect.isTrue( program.libraries.length == 1, "${program.libraries.length} != 1"); + + program = await compiler.computeDelta(entryPoint: helloDart); + Expect.isTrue(program.libraries.isEmpty); } void main() { diff --git a/pkg/front_end/test/fasta/incremental_test.dart b/pkg/front_end/test/fasta/incremental_test.dart index b864704a420..d89f3a321ba 100644 --- a/pkg/front_end/test/fasta/incremental_test.dart +++ b/pkg/front_end/test/fasta/incremental_test.dart @@ -10,6 +10,8 @@ import "dart:convert" show JsonEncoder; import "dart:io" show File; +import "package:kernel/ast.dart" show Program; + import "package:testing/testing.dart" show Chain, ChainContext, Result, Step, TestDescription, runMe; @@ -144,10 +146,17 @@ class RunCompilations extends Step { return edits == 0 ? fail(test, "No sources found") : pass(test); } var compiler = context.compiler; - await compiler.computeDelta(entryPoint: entryPoint); + Program program = await compiler.computeDelta(entryPoint: entryPoint); List errors = context.takeErrors(); - if (errors.isNotEmpty && !test.expectations[edits].hasCompileTimeError) { - return fail(test, errors.join("\n")); + if (test.expectations[edits].hasCompileTimeError) { + if (errors.isEmpty) { + return fail(test, "Compile-time error expected, but none reported"); + } + } else if (errors.isNotEmpty) { + return fail( + test, "Unexpected compile-time errors:\n ${errors.join('\n ')}"); + } else if (program.libraries.length < 1) { + return fail(test, "The compiler detected no changes"); } } } diff --git a/pkg/front_end/testcases/incremental.status b/pkg/front_end/testcases/incremental.status index c572cda5d0e..824a85cdb28 100644 --- a/pkg/front_end/testcases/incremental.status +++ b/pkg/front_end/testcases/incremental.status @@ -4,4 +4,11 @@ # Status file for the test suite ../test/fasta/incremental_test.dart. -dartino/change_in_part.incremental: Crash # Parts aren't handled correctly +dartino/change_in_part.incremental: Fail # Issue 31908 (parts aren't handled correctly) +dartino/compile_time_error_004.incremental: Fail # Issue 31909 +dartino/compile_time_error_field_becomes_removed_function.incremental: Fail # Issue 31909 +dartino/fix_compile_time_error_in_field.incremental: Fail # Issue 31909 +dartino/override_field_with_method_conflict.incremental: Fail # Issue 31909 +dartino/override_getter_with_method_conflict.incremental: Fail # Issue 31909 +dartino/override_method_with_field_conflict.incremental: Fail # Issue 31909 +dartino/override_method_with_getter_conflict.incremental: Fail # Issue 31909