[CFE] Strong test can have linked dependencies
Change-Id: Ia95789b658147f7e2676a9c92b6ba4a1c419395b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132642 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
163fcf6d46
commit
241d2c6cf5
@@ -161,6 +161,14 @@ class TestOptions {
|
||||
}
|
||||
}
|
||||
|
||||
class LinkDependenciesOptions {
|
||||
final Set<Uri> content;
|
||||
Component component;
|
||||
String errors;
|
||||
|
||||
LinkDependenciesOptions(this.content) : assert(content != null);
|
||||
}
|
||||
|
||||
class FastaContext extends ChainContext with MatchContext {
|
||||
final UriTranslator uriTranslator;
|
||||
final List<Step> steps;
|
||||
@@ -176,6 +184,7 @@ class FastaContext extends ChainContext with MatchContext {
|
||||
<Component, StringBuffer>{};
|
||||
final Uri platformBinaries;
|
||||
final Map<Uri, TestOptions> _testOptions = {};
|
||||
final Map<Uri, LinkDependenciesOptions> _linkDependencies = {};
|
||||
|
||||
@override
|
||||
final bool updateExpectations;
|
||||
@@ -296,6 +305,33 @@ class FastaContext extends ChainContext with MatchContext {
|
||||
return testOptions;
|
||||
}
|
||||
|
||||
/// Computes the link dependencies for [description].
|
||||
LinkDependenciesOptions computeLinkDependenciesOptions(
|
||||
TestDescription description) {
|
||||
Directory directory = new File.fromUri(description.uri).parent;
|
||||
LinkDependenciesOptions linkDependenciesOptions =
|
||||
_linkDependencies[directory.uri];
|
||||
if (linkDependenciesOptions == null) {
|
||||
File optionsFile =
|
||||
new File.fromUri(directory.uri.resolve('link.options'));
|
||||
Set<Uri> content = new Set<Uri>();
|
||||
if (optionsFile.existsSync()) {
|
||||
for (String line in optionsFile.readAsStringSync().split('\n')) {
|
||||
line = line.trim();
|
||||
if (line.isEmpty) continue;
|
||||
File f = new File.fromUri(description.uri.resolve(line));
|
||||
if (!f.existsSync()) {
|
||||
throw new UnsupportedError("No file found: $f ($line)");
|
||||
}
|
||||
content.add(f.uri);
|
||||
}
|
||||
}
|
||||
linkDependenciesOptions = new LinkDependenciesOptions(content);
|
||||
_linkDependencies[directory.uri] = linkDependenciesOptions;
|
||||
}
|
||||
return linkDependenciesOptions;
|
||||
}
|
||||
|
||||
Expectation get verificationError => expectationSet["VerificationError"];
|
||||
|
||||
Future ensurePlatformUris() async {
|
||||
@@ -439,6 +475,8 @@ class Outline extends Step<TestDescription, Component, FastaContext> {
|
||||
Future<Result<Component>> run(
|
||||
TestDescription description, FastaContext context) async {
|
||||
StringBuffer errors = new StringBuffer();
|
||||
LinkDependenciesOptions linkDependenciesOptions =
|
||||
context.computeLinkDependenciesOptions(description);
|
||||
TestOptions testOptions = context.computeTestOptions(description);
|
||||
ProcessedOptions options = new ProcessedOptions(
|
||||
options: new CompilerOptions()
|
||||
@@ -454,31 +492,44 @@ class Outline extends Step<TestDescription, Component, FastaContext> {
|
||||
..performNnbdChecks = testOptions.forceNnbdChecks
|
||||
..nnbdStrongMode = !context.weak,
|
||||
inputs: <Uri>[description.uri]);
|
||||
return await CompilerContext.runWithOptions(options, (_) async {
|
||||
// Disable colors to ensure that expectation files are the same across
|
||||
// platforms and independent of stdin/stderr.
|
||||
colors.enableColors = false;
|
||||
Component platform = await context.loadPlatform();
|
||||
Ticker ticker = new Ticker();
|
||||
DillTarget dillTarget = new DillTarget(
|
||||
ticker,
|
||||
context.uriTranslator,
|
||||
new TestVmTarget(new TargetFlags(
|
||||
forceLateLoweringForTesting: testOptions.forceLateLowering)),
|
||||
);
|
||||
dillTarget.loader.appendLibraries(platform);
|
||||
// We create a new URI translator to avoid reading platform libraries from
|
||||
// file system.
|
||||
UriTranslator uriTranslator = new UriTranslator(
|
||||
const TargetLibrariesSpecification('vm'),
|
||||
context.uriTranslator.packages);
|
||||
KernelTarget sourceTarget = new KernelTarget(
|
||||
StandardFileSystem.instance, false, dillTarget, uriTranslator);
|
||||
|
||||
sourceTarget.setEntryPoints(<Uri>[description.uri]);
|
||||
await dillTarget.buildOutlines();
|
||||
ValidatingInstrumentation instrumentation;
|
||||
instrumentation = new ValidatingInstrumentation();
|
||||
// Disable colors to ensure that expectation files are the same across
|
||||
// platforms and independent of stdin/stderr.
|
||||
colors.enableColors = false;
|
||||
|
||||
if (linkDependenciesOptions.content.isNotEmpty &&
|
||||
linkDependenciesOptions.component == null) {
|
||||
// Compile linked dependency.
|
||||
await CompilerContext.runWithOptions(options, (_) async {
|
||||
KernelTarget sourceTarget = await outlineInitialization(
|
||||
context, testOptions, linkDependenciesOptions.content.toList());
|
||||
if (linkDependenciesOptions.errors != null) {
|
||||
errors.write(linkDependenciesOptions.errors);
|
||||
}
|
||||
Component p = await sourceTarget.buildOutlines();
|
||||
if (fullCompile) {
|
||||
p = await sourceTarget.buildComponent(verify: context.verify);
|
||||
}
|
||||
linkDependenciesOptions.component = p;
|
||||
List<Library> keepLibraries = new List<Library>();
|
||||
for (Library lib in p.libraries) {
|
||||
if (linkDependenciesOptions.content.contains(lib.fileUri)) {
|
||||
keepLibraries.add(lib);
|
||||
}
|
||||
}
|
||||
p.libraries.clear();
|
||||
p.libraries.addAll(keepLibraries);
|
||||
linkDependenciesOptions.errors = errors.toString();
|
||||
errors.clear();
|
||||
});
|
||||
}
|
||||
|
||||
return await CompilerContext.runWithOptions(options, (_) async {
|
||||
KernelTarget sourceTarget = await outlineInitialization(
|
||||
context, testOptions, <Uri>[description.uri],
|
||||
alsoAppend: linkDependenciesOptions.component);
|
||||
ValidatingInstrumentation instrumentation =
|
||||
new ValidatingInstrumentation();
|
||||
await instrumentation.loadExpectations(description.uri);
|
||||
sourceTarget.loader.instrumentation = instrumentation;
|
||||
Component p = await sourceTarget.buildOutlines();
|
||||
@@ -488,8 +539,8 @@ class Outline extends Step<TestDescription, Component, FastaContext> {
|
||||
context.componentToDiagnostics[p] = errors;
|
||||
if (fullCompile) {
|
||||
p = await sourceTarget.buildComponent(verify: context.verify);
|
||||
instrumentation?.finish();
|
||||
if (instrumentation != null && instrumentation.hasProblems) {
|
||||
instrumentation.finish();
|
||||
if (instrumentation.hasProblems) {
|
||||
if (updateComments) {
|
||||
await instrumentation.fixSource(description.uri, false);
|
||||
} else {
|
||||
@@ -504,6 +555,34 @@ class Outline extends Step<TestDescription, Component, FastaContext> {
|
||||
return pass(p);
|
||||
});
|
||||
}
|
||||
|
||||
Future<KernelTarget> outlineInitialization(
|
||||
FastaContext context, TestOptions testOptions, List<Uri> entryPoints,
|
||||
{Component alsoAppend}) async {
|
||||
Component platform = await context.loadPlatform();
|
||||
Ticker ticker = new Ticker();
|
||||
DillTarget dillTarget = new DillTarget(
|
||||
ticker,
|
||||
context.uriTranslator,
|
||||
new TestVmTarget(new TargetFlags(
|
||||
forceLateLoweringForTesting: testOptions.forceLateLowering)),
|
||||
);
|
||||
dillTarget.loader.appendLibraries(platform);
|
||||
if (alsoAppend != null) {
|
||||
dillTarget.loader.appendLibraries(alsoAppend);
|
||||
}
|
||||
// We create a new URI translator to avoid reading platform libraries
|
||||
// from file system.
|
||||
UriTranslator uriTranslator = new UriTranslator(
|
||||
const TargetLibrariesSpecification('vm'),
|
||||
context.uriTranslator.packages);
|
||||
KernelTarget sourceTarget = new KernelTarget(
|
||||
StandardFileSystem.instance, false, dillTarget, uriTranslator);
|
||||
|
||||
sourceTarget.setEntryPoints(entryPoints);
|
||||
await dillTarget.buildOutlines();
|
||||
return sourceTarget;
|
||||
}
|
||||
}
|
||||
|
||||
class Transform extends Step<Component, Component, FastaContext> {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
variance_from_dill_lib.dart
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import "variance_from_dill_lib.dart";
|
||||
typedef G<T> = Function(F<T>);
|
||||
|
||||
main() {
|
||||
print(G);
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
typedef F<T> = Function();
|
||||
@@ -14,6 +14,7 @@ general/override_check_after_inference: TypeCheckError
|
||||
general/override_check_basic: TypeCheckError
|
||||
general/override_check_with_covariant_modifier: TypeCheckError
|
||||
general/override_setter_with_field: TypeCheckError
|
||||
general/with_dependencies/variance_from_dill/variance_from_dill: Crash
|
||||
|
||||
general_nnbd_opt_out/abstract_members: TypeCheckError
|
||||
general_nnbd_opt_out/bug30695: TypeCheckError
|
||||
|
||||
@@ -65,6 +65,7 @@ general/type_variable_bound_access: TypeCheckError
|
||||
general/unsound_promotion: TypeCheckError
|
||||
general/void_methods: RuntimeError
|
||||
general/warn_unresolved_sends: InstrumentationMismatch # Test assumes Dart 1.0 semantics
|
||||
general/with_dependencies/variance_from_dill/variance_from_dill: Crash
|
||||
general_nnbd_opt_out/abstract_members: TypeCheckError
|
||||
general_nnbd_opt_out/accessors: RuntimeError
|
||||
general_nnbd_opt_out/ambiguous_exports: RuntimeError # Expected, this file exports two main methods.
|
||||
|
||||
@@ -336,6 +336,7 @@ general/unused_methods: TextSerializationFailure # Was: Pass
|
||||
general/var_as_type_name: TextSerializationFailure # Was: Pass
|
||||
general/void_methods: TextSerializationFailure
|
||||
general/warn_unresolved_sends: InstrumentationMismatch # Test assumes Dart 1.0 semantics
|
||||
general/with_dependencies/variance_from_dill/variance_from_dill: Crash
|
||||
general_nnbd_opt_out/DeltaBlue: TextSerializationFailure # Was: Pass
|
||||
general_nnbd_opt_out/abstract_members: TypeCheckError
|
||||
general_nnbd_opt_out/abstract_overrides_concrete_with_no_such_method: TextSerializationFailure
|
||||
|
||||
Reference in New Issue
Block a user