From 20cfdeffe5d691432b7b98b4e28e20af8276fe10 Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Fri, 19 Mar 2021 13:34:17 +0000 Subject: [PATCH] [CFE] Include .crash_dart in weak tests; better handling of erroneous -D parameters and expectationFileMismatchSerialized on -DupdateExpectations=true Change-Id: I00da3e4cf8859c65a8d93600804c7dbc56ec0bca Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192180 Reviewed-by: Johnni Winther Commit-Queue: Jens Johansen --- pkg/front_end/test/fasta/testing/suite.dart | 31 ++++++++++++++++----- pkg/front_end/test/testing_utils.dart | 6 ++-- pkg/front_end/test/utils/kernel_chain.dart | 7 +++-- pkg/front_end/testing.json | 3 +- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/pkg/front_end/test/fasta/testing/suite.dart b/pkg/front_end/test/fasta/testing/suite.dart index d4cc1648da4..8702311a422 100644 --- a/pkg/front_end/test/fasta/testing/suite.dart +++ b/pkg/front_end/test/fasta/testing/suite.dart @@ -162,6 +162,8 @@ import 'package:vm/target/vm.dart' show VmTarget; import 'package:vm/transformations/type_flow/transformer.dart' as type_flow; import 'package:vm/transformations/pragma.dart' as type_flow; +import '../../testing_utils.dart' show checkEnvironment; + import '../../utils/kernel_chain.dart' show ComponentResult, @@ -376,13 +378,11 @@ class FastaContext extends ChainContext with MatchContext { steps.add(new MatchExpectation( fullCompile ? "$fullPrefix.expect" : "$outlinePrefix.expect", serializeFirst: false, - isLastMatchStep: updateExpectations)); - if (!updateExpectations) { - steps.add(new MatchExpectation( - fullCompile ? "$fullPrefix.expect" : "$outlinePrefix.expect", - serializeFirst: true, - isLastMatchStep: true)); - } + isLastMatchStep: false)); + steps.add(new MatchExpectation( + fullCompile ? "$fullPrefix.expect" : "$outlinePrefix.expect", + serializeFirst: true, + isLastMatchStep: true)); } steps.add(const TypeCheck()); steps.add(const EnsureNoErrors()); @@ -723,6 +723,23 @@ class FastaContext extends ChainContext with MatchContext { static Future create( Chain suite, Map environment) async { + const Set knownEnvironmentKeys = { + "enableExtensionMethods", + "enableNonNullable", + "soundNullSafety", + "onlyCrashes", + "ignoreExpectations", + UPDATE_EXPECTATIONS, + UPDATE_COMMENTS, + "skipVm", + "semiFuzz", + "verify", + KERNEL_TEXT_SERIALIZATION, + "platformBinaries", + ENABLE_FULL_COMPILE, + }; + checkEnvironment(environment, knownEnvironmentKeys); + String resolvedExecutable = Platform.environment['resolvedExecutable'] ?? Platform.resolvedExecutable; Uri vm = Uri.base.resolveUri(new Uri.file(resolvedExecutable)); diff --git a/pkg/front_end/test/testing_utils.dart b/pkg/front_end/test/testing_utils.dart index 6781673c2f4..502ac99c354 100644 --- a/pkg/front_end/test/testing_utils.dart +++ b/pkg/front_end/test/testing_utils.dart @@ -43,7 +43,9 @@ void checkEnvironment( Set environmentKeys = environment.keys.toSet(); environmentKeys.removeAll(knownEnvironmentKeys); if (environmentKeys.isNotEmpty) { - throw "Unknown environment(s) given: ${environmentKeys.toList()}.\n" - "Knows about ${knownEnvironmentKeys.toList()}"; + throw "Unknown environment(s) given:" + "\n - ${environmentKeys.join("\n- ")}\n" + "Knows about these environment(s):" + "\n - ${knownEnvironmentKeys.join("\n - ")}"; } } diff --git a/pkg/front_end/test/utils/kernel_chain.dart b/pkg/front_end/test/utils/kernel_chain.dart index f7b52fc82d4..f3d539ca672 100644 --- a/pkg/front_end/test/utils/kernel_chain.dart +++ b/pkg/front_end/test/utils/kernel_chain.dart @@ -84,7 +84,9 @@ abstract class MatchContext implements ChainContext { expectationSet["ExpectationFileMissing"]; Future> match(String suffix, String actual, Uri uri, O output, - {Expectation onMismatch}) async { + {Expectation onMismatch, bool overwriteUpdateExpectationsWith}) async { + bool updateExpectations = + overwriteUpdateExpectationsWith ?? this.updateExpectations; actual = actual.trim(); if (actual.isNotEmpty) { actual += "\n"; @@ -338,7 +340,8 @@ class MatchExpectation return context.match(suffix, actual, uri, result, onMismatch: serializeFirst ? context.expectationFileMismatchSerialized - : context.expectationFileMismatch); + : context.expectationFileMismatch, + overwriteUpdateExpectationsWith: serializeFirst ? false : null); } } diff --git a/pkg/front_end/testing.json b/pkg/front_end/testing.json index 5ccfe4845bb..ef564941c33 100644 --- a/pkg/front_end/testing.json +++ b/pkg/front_end/testing.json @@ -134,7 +134,8 @@ "path": "testcases/", "status": "testcases/weak.status", "pattern": [ - "\\.dart$" + "\\.dart$", + "\\.crash_dart$" ], "exclude": [ "/testcases/.*_part[0-9]*\\.dart$",