@@ -203,7 +203,7 @@ class FastaContext extends ChainContext with MatchContext {
203
203
final Map <Component , List <Iterable <String >>> componentToDiagnostics =
204
204
< Component , List <Iterable <String >>> {};
205
205
final Uri platformBinaries;
206
- final Map <Uri , UriTranslator > _uriTranslators = {};
206
+ final Map <UriConfiguration , UriTranslator > _uriTranslators = {};
207
207
final Map <Uri , TestOptions > _testOptions = {};
208
208
final Map <Uri , LinkDependenciesOptions > _linkDependencies = {};
209
209
final Map <Uri , Uri > _librariesJson = {};
@@ -364,9 +364,8 @@ class FastaContext extends ChainContext with MatchContext {
364
364
365
365
Future <UriTranslator > computeUriTranslator (
366
366
TestDescription description) async {
367
- Uri librariesSpecificationUri =
368
- computeLibrariesSpecificationUri (description);
369
- UriTranslator uriTranslator = _uriTranslators[librariesSpecificationUri];
367
+ UriConfiguration uriConfiguration = computeUriConfiguration (description);
368
+ UriTranslator uriTranslator = _uriTranslators[uriConfiguration];
370
369
if (uriTranslator == null ) {
371
370
Uri sdk = Uri .base .resolve ("sdk/" );
372
371
Uri packages = Uri .base .resolve (".packages" );
@@ -376,7 +375,7 @@ class FastaContext extends ChainContext with MatchContext {
376
375
throw message.plainTextFormatted.join ("\n " );
377
376
}
378
377
..sdkRoot = sdk
379
- ..packagesFileUri = packages
378
+ ..packagesFileUri = uriConfiguration.packageConfigUri ?? packages
380
379
..environmentDefines = {}
381
380
..experimentalFlags =
382
381
testOptions.computeExperimentalFlags (experimentalFlags)
@@ -385,14 +384,15 @@ class FastaContext extends ChainContext with MatchContext {
385
384
: (testOptions.nnbdAgnosticMode
386
385
? NnbdMode .Agnostic
387
386
: NnbdMode .Strong )
388
- ..librariesSpecificationUri = librariesSpecificationUri;
387
+ ..librariesSpecificationUri =
388
+ uriConfiguration.librariesSpecificationUri;
389
389
if (testOptions.overwriteCurrentSdkVersion != null ) {
390
390
compilerOptions.currentSdkVersion =
391
391
testOptions.overwriteCurrentSdkVersion;
392
392
}
393
393
ProcessedOptions options = new ProcessedOptions (options: compilerOptions);
394
394
uriTranslator = await options.getUriTranslator ();
395
- _uriTranslators[librariesSpecificationUri ] = uriTranslator;
395
+ _uriTranslators[uriConfiguration ] = uriTranslator;
396
396
}
397
397
return uriTranslator;
398
398
}
@@ -431,11 +431,15 @@ class FastaContext extends ChainContext with MatchContext {
431
431
}
432
432
nnbdMode = NnbdMode .Weak ;
433
433
} else {
434
- File f = new File .fromUri (description.uri.resolve (line));
435
- if (! f.existsSync ()) {
436
- throw new UnsupportedError ("No file found: $f ($line )" );
434
+ Uri uri = description.uri.resolve (line);
435
+ if (uri.scheme != 'package' ) {
436
+ File f = new File .fromUri (uri);
437
+ if (! f.existsSync ()) {
438
+ throw new UnsupportedError ("No file found: $f ($line )" );
439
+ }
440
+ uri = f.uri;
437
441
}
438
- content.add (f. uri);
442
+ content.add (uri);
439
443
}
440
444
}
441
445
}
@@ -461,6 +465,20 @@ class FastaContext extends ChainContext with MatchContext {
461
465
}
462
466
}
463
467
468
+ /// Custom package config used for [description] .
469
+ Uri computePackageConfigUri (TestDescription description) {
470
+ Uri packageConfig =
471
+ description.uri.resolve (".dart_tool/package_config.json" );
472
+ return new File .fromUri (packageConfig).existsSync () ? packageConfig : null ;
473
+ }
474
+
475
+ UriConfiguration computeUriConfiguration (TestDescription description) {
476
+ Uri librariesSpecificationUri =
477
+ computeLibrariesSpecificationUri (description);
478
+ Uri packageConfigUri = computePackageConfigUri (description);
479
+ return new UriConfiguration (librariesSpecificationUri, packageConfigUri);
480
+ }
481
+
464
482
Expectation get verificationError => expectationSet["VerificationError" ];
465
483
466
484
Future ensurePlatformUris () async {
@@ -666,7 +684,7 @@ class Outline extends Step<TestDescription, ComponentResult, FastaContext> {
666
684
linkDependenciesOptions.component = p;
667
685
List <Library > keepLibraries = new List <Library >();
668
686
for (Library lib in p.libraries) {
669
- if (linkDependenciesOptions.content.contains (lib.fileUri )) {
687
+ if (linkDependenciesOptions.content.contains (lib.importUri )) {
670
688
keepLibraries.add (lib);
671
689
}
672
690
}
@@ -896,3 +914,22 @@ class MatchHierarchy
896
914
".hierarchy.expect" , "$sb " , uri, result);
897
915
}
898
916
}
917
+
918
+ class UriConfiguration {
919
+ final Uri librariesSpecificationUri;
920
+ final Uri packageConfigUri;
921
+
922
+ UriConfiguration (this .librariesSpecificationUri, this .packageConfigUri);
923
+
924
+ @override
925
+ int get hashCode =>
926
+ librariesSpecificationUri.hashCode * 13 + packageConfigUri.hashCode * 17 ;
927
+
928
+ @override
929
+ bool operator == (Object other) {
930
+ if (identical (this , other)) return true ;
931
+ return other is UriConfiguration &&
932
+ librariesSpecificationUri == other.librariesSpecificationUri &&
933
+ packageConfigUri == other.packageConfigUri;
934
+ }
935
+ }
0 commit comments