[cfe] Skip running tests with no/empty main

+ always serialize to dill, but only to disk when running the test.

Change-Id: If1500931ea951229fb2502defe9d0315ea5f1883
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245006
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
Johnni Winther
2022-05-18 12:55:07 +00:00
committed by Commit Bot
parent 9a49527240
commit 548bff1d53
4 changed files with 66 additions and 120 deletions
+6 -3
View File
@@ -421,9 +421,7 @@ class FastaContext extends ChainContext with MatchContext {
}
}
steps.add(const EnsureNoErrors());
if (!skipVm) {
steps.add(const WriteDill());
}
steps.add(new WriteDill(skipVm: skipVm));
if (semiFuzz) {
steps.add(const FuzzCompiles());
}
@@ -826,6 +824,11 @@ class Run extends Step<ComponentResult, ComponentResult, FastaContext> {
@override
Future<Result<ComponentResult>> run(
ComponentResult result, FastaContext context) async {
Uri? outputUri = result.outputUri;
if (outputUri == null) {
return pass(result);
}
FolderOptions folderOptions =
context.computeFolderOptions(result.description);
Map<ExperimentalFlag, bool> experimentalFlags = folderOptions
+60 -15
View File
@@ -4,6 +4,7 @@
library fasta.testing.kernel_chain;
import 'dart:async';
import 'dart:io' show Directory, File, IOSink, Platform;
import 'dart:typed_data' show Uint8List;
@@ -32,7 +33,16 @@ import 'package:front_end/src/fasta/kernel/utils.dart' show ByteSink;
import 'package:front_end/src/fasta/messages.dart'
show DiagnosticMessageFromJson, LocatedMessage, Message;
import 'package:kernel/ast.dart' show Component, Library, Reference, Source;
import 'package:kernel/ast.dart'
show
Block,
Component,
Library,
Procedure,
Reference,
ReturnStatement,
Source,
Statement;
import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder;
@@ -423,7 +433,9 @@ class KernelTextSerialization
}
class WriteDill extends Step<ComponentResult, ComponentResult, ChainContext> {
const WriteDill();
final bool skipVm;
const WriteDill({required this.skipVm});
@override
String get name => "write .dill";
@@ -431,29 +443,62 @@ class WriteDill extends Step<ComponentResult, ComponentResult, ChainContext> {
@override
Future<Result<ComponentResult>> run(ComponentResult result, _) async {
Component component = result.component;
Directory tmp = await Directory.systemTemp.createTemp();
Uri uri = tmp.uri.resolve("generated.dill");
File generated = new File.fromUri(uri);
IOSink sink = generated.openWrite();
result = new ComponentResult(
result.description,
result.component,
result.userLibraries,
result.compilationSetup,
result.sourceTarget,
uri);
Procedure? mainMethod = component.mainMethod;
bool writeToFile = true;
if (mainMethod == null) {
writeToFile = false;
} else {
Statement? mainBody = mainMethod.function.body;
if (mainBody is Block && mainBody.statements.isEmpty ||
mainBody is ReturnStatement && mainBody.expression == null) {
writeToFile = false;
}
}
Sink<List<int>> sink;
String writeMessage;
if (writeToFile && !skipVm) {
Directory tmp = await Directory.systemTemp.createTemp();
Uri uri = tmp.uri.resolve("generated.dill");
File generated = new File.fromUri(uri);
sink = generated.openWrite();
result = new ComponentResult(
result.description,
result.component,
result.userLibraries,
result.compilationSetup,
result.sourceTarget,
uri);
writeMessage = "Wrote component to `${generated.path}`";
} else {
sink = new DevNullSink();
writeMessage = "Wrote component to /dev/null";
}
try {
// TODO(johnniwinther,jensj): Avoid serializing the sdk.
new BinaryPrinter(sink).writeComponentFile(component);
} catch (e, s) {
return fail(result, e, s);
} finally {
print("Wrote `${generated.path}`");
await sink.close();
print(writeMessage);
if (sink is IOSink) {
await sink.close();
} else {
sink.close();
}
}
return pass(result);
}
}
class DevNullSink<T> extends Sink<T> {
@override
void add(T data) {}
@override
void close() {}
}
class ReadDill extends Step<Uri, Uri, ChainContext> {
const ReadDill();
@@ -31,12 +31,10 @@ extensions/invalid_explicit_access: RuntimeError
extensions/static_access_of_instance: RuntimeError
general/abstract_members: TypeCheckError
general/accessors: RuntimeError
general/ambiguous_exports: RuntimeError
general/await_in_non_async: RuntimeError
general/bounded_implicit_instantiation: TypeCheckError
general/bounds_instances: TypeCheckError
general/bug30695: TypeCheckError
general/bug31124: RuntimeError
general/call: RuntimeError
general/cascade: RuntimeError
general/constructor_initializer_invalid: RuntimeError
@@ -50,50 +48,19 @@ general/duplicated_field_initializer: RuntimeError
general/error_locations/error_location_01: RuntimeError
general/error_locations/error_location_02: RuntimeError
general/error_locations/error_location_03: RuntimeError
general/error_locations/error_location_05: RuntimeError
general/error_locations/error_location_06: RuntimeError
general/error_recovery/await_not_in_async: RuntimeError
general/error_recovery/constructor_recovery_bad_name_general.crash: RuntimeError
general/error_recovery/constructor_recovery_bad_name_get.crash: RuntimeError
general/error_recovery/constructor_recovery_bad_name_return_type.crash: RuntimeError
general/error_recovery/constructor_recovery_bad_name_set.crash: RuntimeError
general/error_recovery/constructor_recovery_get: RuntimeError
general/error_recovery/constructor_recovery_ok: RuntimeError
general/error_recovery/constructor_recovery_operator.crash: RuntimeError
general/error_recovery/constructor_recovery_return_type: RuntimeError
general/error_recovery/constructor_recovery_set: RuntimeError
general/error_recovery/empty_await_for: RuntimeError
general/error_recovery/empty_for: RuntimeError
general/error_recovery/issue_38415.crash: RuntimeError
general/error_recovery/issue_39024.crash: RuntimeError
general/error_recovery/issue_39026.crash: RuntimeError
general/error_recovery/issue_39026_prime.crash: RuntimeError
general/error_recovery/issue_39033.crash: RuntimeError
general/error_recovery/issue_39033b.crash: RuntimeError
general/error_recovery/issue_39058.crash: RuntimeError
general/error_recovery/issue_39058_prime.crash: RuntimeError
general/error_recovery/issue_39202.crash: RuntimeError
general/error_recovery/issue_39230.crash: RuntimeError
general/error_recovery/issue_39958_01: RuntimeError
general/error_recovery/issue_39958_02: RuntimeError
general/error_recovery/issue_39958_03: RuntimeError
general/error_recovery/issue_39958_04: RuntimeError
general/error_recovery/weekly_bot_91_failure: Crash
general/error_recovery/yield_not_in_generator: RuntimeError
general/expressions: RuntimeError
general/getter_vs_setter_type: TypeCheckError
general/implement_semi_stub: TypeCheckError
general/implicit_super_call: TypeCheckError
general/incomplete_field_formal_parameter: RuntimeError
general/infer_field_from_multiple2: TypeCheckError
general/infer_field_from_multiple: TypeCheckError
general/invalid_operator: TypeCheckError
general/invalid_operator_override: TypeCheckError
general/invocations: TypeCheckError
general/issue37776: RuntimeError
general/issue38938: RuntimeError
general/issue38944: RuntimeError
general/issue38961: RuntimeError
general/issue41210a: TypeCheckError
general/issue41210b/issue41210.no_link: TypeCheckError
general/issue41210b/issue41210: TypeCheckError
@@ -117,7 +84,6 @@ general/redirecting_factory: RuntimeError
general/redirecting_factory_invocation_in_invalid: TypeCheckError
general/spread_collection: RuntimeError # Should be fixed as part of implementing spread collection support
general/super_semi_stub: TypeCheckError
general/type_parameter_type_named_int: RuntimeError
general/type_variable_as_super: RuntimeError
general/unsound_promotion: TypeCheckError
general/void_methods: RuntimeError
@@ -176,32 +142,23 @@ rasta/bad_redirection: RuntimeError
rasta/bad_setter_initializer: RuntimeError
rasta/breaking_bad: RuntimeError
rasta/class_hierarchy: RuntimeError
rasta/class_member: RuntimeError
rasta/constant_get_and_invoke: RuntimeError
rasta/duplicated_mixin: RuntimeError
rasta/export: RuntimeError
rasta/foo: RuntimeError
rasta/generic_factory: RuntimeError
rasta/issue_000001: RuntimeError
rasta/issue_000031: RuntimeError
rasta/issue_000032: RuntimeError
rasta/issue_000034: RuntimeError
rasta/issue_000036: RuntimeError
rasta/issue_000039: RuntimeError
rasta/issue_000041: RuntimeError
rasta/issue_000042: RuntimeError
rasta/issue_000043: RuntimeError
rasta/issue_000044: RuntimeError
rasta/issue_000046: RuntimeError
rasta/issue_000081: RuntimeError
rasta/malformed_const_constructor: RuntimeError
rasta/malformed_function: RuntimeError
rasta/mixin_library: TypeCheckError
rasta/native_is_illegal: RuntimeError
rasta/parser_error: RuntimeError
rasta/static: RuntimeError
rasta/super: TypeCheckError
rasta/super_initializer: RuntimeError
rasta/super_mixin: TypeCheckError
rasta/super_operator: TypeCheckError
rasta/type_literals: RuntimeError
@@ -212,7 +169,6 @@ rasta/unresolved_for_in: RuntimeError
rasta/unresolved_recovery: TypeCheckError
regress/issue_29976: RuntimeError
regress/issue_29982: RuntimeError
regress/issue_30836: RuntimeError
regress/issue_31180: TypeCheckError
regress/issue_32972: RuntimeError
regress/issue_33452: RuntimeError
@@ -223,15 +179,8 @@ regress/issue_35258: RuntimeError
regress/issue_35259: RuntimeError
regress/issue_35260: RuntimeError
regress/issue_35266: RuntimeError
regress/issue_36400: RuntimeError
regress/issue_36647: RuntimeError
regress/issue_36647_2: RuntimeError
regress/issue_36669: RuntimeError
regress/issue_37285: RuntimeError
regress/issue_39035.crash: RuntimeError
regress/issue_39091_1: RuntimeError
regress/issue_39091_2: RuntimeError
regress/utf_16_le_content.crash: RuntimeError
runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast: RuntimeError
set_literals/disambiguation_rule: RuntimeError
value_class/copy_with_call_sites: RuntimeError # Expected
-51
View File
@@ -121,12 +121,10 @@ extensions/invalid_explicit_access: RuntimeError
extensions/static_access_of_instance: RuntimeError
general/abstract_members: TypeCheckError
general/accessors: RuntimeError
general/ambiguous_exports: RuntimeError # Expected, this file exports two main methods.
general/await_in_non_async: RuntimeError # Expected.
general/bounded_implicit_instantiation: TypeCheckError
general/bounds_instances: TypeCheckError
general/bug30695: TypeCheckError
general/bug31124: RuntimeError # Test has no main method (and we shouldn't add one).
general/call: RuntimeError
general/cascade: RuntimeError
general/constructor_initializer_invalid: RuntimeError # Fails execution after recovery
@@ -140,50 +138,19 @@ general/duplicated_field_initializer: RuntimeError
general/error_locations/error_location_01: RuntimeError
general/error_locations/error_location_02: RuntimeError
general/error_locations/error_location_03: RuntimeError
general/error_locations/error_location_05: RuntimeError
general/error_locations/error_location_06: RuntimeError
general/error_recovery/await_not_in_async: RuntimeError
general/error_recovery/constructor_recovery_bad_name_general.crash: RuntimeError
general/error_recovery/constructor_recovery_bad_name_get.crash: RuntimeError
general/error_recovery/constructor_recovery_bad_name_return_type.crash: RuntimeError
general/error_recovery/constructor_recovery_bad_name_set.crash: RuntimeError
general/error_recovery/constructor_recovery_get: RuntimeError
general/error_recovery/constructor_recovery_ok: RuntimeError
general/error_recovery/constructor_recovery_operator.crash: RuntimeError
general/error_recovery/constructor_recovery_return_type: RuntimeError
general/error_recovery/constructor_recovery_set: RuntimeError
general/error_recovery/empty_await_for: RuntimeError
general/error_recovery/empty_for: RuntimeError
general/error_recovery/issue_38415.crash: RuntimeError
general/error_recovery/issue_39024.crash: RuntimeError
general/error_recovery/issue_39026.crash: RuntimeError
general/error_recovery/issue_39026_prime.crash: RuntimeError
general/error_recovery/issue_39033.crash: RuntimeError
general/error_recovery/issue_39033b.crash: RuntimeError
general/error_recovery/issue_39058.crash: RuntimeError
general/error_recovery/issue_39058_prime.crash: RuntimeError
general/error_recovery/issue_39202.crash: RuntimeError
general/error_recovery/issue_39230.crash: RuntimeError
general/error_recovery/issue_39958_01: RuntimeError
general/error_recovery/issue_39958_02: RuntimeError
general/error_recovery/issue_39958_03: RuntimeError
general/error_recovery/issue_39958_04: RuntimeError
general/error_recovery/weekly_bot_91_failure: Crash
general/error_recovery/yield_not_in_generator: RuntimeError
general/expressions: RuntimeError
general/getter_vs_setter_type: TypeCheckError
general/implement_semi_stub: TypeCheckError
general/implicit_super_call: TypeCheckError
general/incomplete_field_formal_parameter: RuntimeError
general/infer_field_from_multiple2: TypeCheckError
general/infer_field_from_multiple: TypeCheckError
general/invalid_operator: TypeCheckError
general/invalid_operator_override: TypeCheckError
general/invocations: TypeCheckError
general/issue37776: RuntimeError
general/issue38938: RuntimeError # no main and compile time errors.
general/issue38944: RuntimeError # no main and compile time errors.
general/issue38961: RuntimeError # no main and compile time errors.
general/issue41210a: TypeCheckError
general/issue41210b/issue41210.no_link: TypeCheckError
general/issue41210b/issue41210: TypeCheckError
@@ -208,7 +175,6 @@ general/redirecting_factory: RuntimeError
general/redirecting_factory_invocation_in_invalid: TypeCheckError
general/spread_collection: RuntimeError
general/super_semi_stub: TypeCheckError
general/type_parameter_type_named_int: RuntimeError # Expected
general/type_variable_as_super: RuntimeError
general/unsound_promotion: TypeCheckError
general/void_methods: RuntimeError
@@ -266,32 +232,23 @@ rasta/bad_redirection: RuntimeError
rasta/bad_setter_initializer: RuntimeError
rasta/breaking_bad: RuntimeError
rasta/class_hierarchy: RuntimeError
rasta/class_member: RuntimeError
rasta/constant_get_and_invoke: RuntimeError
rasta/duplicated_mixin: RuntimeError # Expected, this file has no main method.
rasta/export: RuntimeError # Expected, this file has no main method.
rasta/foo: RuntimeError # Expected, this file has no main method.
rasta/generic_factory: RuntimeError
rasta/issue_000001: RuntimeError
rasta/issue_000031: RuntimeError
rasta/issue_000032: RuntimeError
rasta/issue_000034: RuntimeError
rasta/issue_000036: RuntimeError
rasta/issue_000039: RuntimeError
rasta/issue_000041: RuntimeError
rasta/issue_000042: RuntimeError
rasta/issue_000043: RuntimeError
rasta/issue_000044: RuntimeError
rasta/issue_000046: RuntimeError
rasta/issue_000081: RuntimeError
rasta/malformed_const_constructor: RuntimeError
rasta/malformed_function: RuntimeError
rasta/mixin_library: TypeCheckError
rasta/native_is_illegal: RuntimeError
rasta/parser_error: RuntimeError
rasta/static: RuntimeError
rasta/super: TypeCheckError
rasta/super_initializer: RuntimeError
rasta/super_mixin: TypeCheckError
rasta/super_operator: TypeCheckError
rasta/type_literals: RuntimeError
@@ -302,7 +259,6 @@ rasta/unresolved_for_in: RuntimeError
rasta/unresolved_recovery: TypeCheckError
regress/issue_29976: RuntimeError # Tests runtime behavior of error recovery.
regress/issue_29982: RuntimeError # Tests runtime behavior of error recovery.
regress/issue_30836: RuntimeError # Issue 30836.
regress/issue_31180: TypeCheckError
regress/issue_32972: RuntimeError
regress/issue_33452: RuntimeError # Test has an intentional error
@@ -313,15 +269,8 @@ regress/issue_35258: RuntimeError # Expected
regress/issue_35259: RuntimeError # Expected
regress/issue_35260: RuntimeError # Expected
regress/issue_35266: RuntimeError # Expected
regress/issue_36400: RuntimeError
regress/issue_36647: RuntimeError # Expected
regress/issue_36647_2: RuntimeError # Expected
regress/issue_36669: RuntimeError
regress/issue_37285: RuntimeError
regress/issue_39035.crash: RuntimeError
regress/issue_39091_1: RuntimeError
regress/issue_39091_2: RuntimeError
regress/utf_16_le_content.crash: RuntimeError
runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast: RuntimeError
runtime_checks_new/mixin_forwarding_stub_getter: TypeCheckError
set_literals/disambiguation_rule: RuntimeError