@@ -8,11 +8,6 @@ import 'dart:io' show Directory, File;
88
99import 'package:expect/expect.dart' show Expect;
1010
11- import 'package:front_end/src/base/processed_options.dart'
12- show ProcessedOptions;
13-
14- import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext;
15-
1611import 'package:front_end/src/api_prototype/compiler_options.dart'
1712 show CompilerOptions;
1813
@@ -22,9 +17,17 @@ import 'package:front_end/src/api_prototype/diagnostic_message.dart'
2217import "package:front_end/src/api_prototype/memory_file_system.dart"
2318 show MemoryFileSystem;
2419
20+ import 'package:front_end/src/base/processed_options.dart'
21+ show ProcessedOptions;
22+
2523import 'package:front_end/src/compute_platform_binaries_location.dart'
2624 show computePlatformBinariesLocation;
2725
26+ import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext;
27+
28+ import 'package:front_end/src/fasta/fasta_codes.dart'
29+ show DiagnosticMessageFromJson, FormattedMessage;
30+
2831import 'package:front_end/src/fasta/incremental_compiler.dart'
2932 show IncrementalCompiler;
3033
@@ -59,9 +62,6 @@ import 'binary_md_dill_reader.dart' show DillComparer;
5962
6063import "incremental_utils.dart" as util;
6164
62- import 'package:front_end/src/fasta/fasta_codes.dart'
63- show DiagnosticMessageFromJson, FormattedMessage;
64-
6565import 'utils/io_utils.dart' show computeRepoDir;
6666
6767main ([List <String > arguments = const []]) =>
@@ -335,6 +335,7 @@ Future<Null> newWorldTest(
335335 }
336336 }
337337 }
338+
338339 bool brandNewWorld = true ;
339340 if (world["worldType" ] == "updated" ) {
340341 brandNewWorld = false ;
@@ -428,10 +429,18 @@ Future<Null> newWorldTest(
428429 if (brandNewWorld) {
429430 if (world["fromComponent" ] == true ) {
430431 compiler = new TestIncrementalCompiler .fromComponent (
431- options, entries.first, newestWholeComponent, outlineOnly);
432+ options,
433+ entries.first,
434+ (modulesToUse != null ) ? sdk : newestWholeComponent,
435+ outlineOnly);
432436 } else {
433437 compiler = new TestIncrementalCompiler (
434438 options, entries.first, initializeFrom, outlineOnly);
439+
440+ if (modulesToUse != null ) {
441+ throw "You probably shouldn't do this! "
442+ "Any modules will have another sdk loaded!" ;
443+ }
435444 }
436445 }
437446
@@ -559,6 +568,7 @@ Future<Null> newWorldTest(
559568 throw "Expected that initializedFromDill would be "
560569 "$expectInitializeFromDill but was ${compiler .initializedFromDill }" ;
561570 }
571+
562572 if (world["checkInvalidatedFiles" ] != false ) {
563573 Set <Uri > filteredInvalidated =
564574 compiler.getFilteredInvalidatedImportUrisForTesting (invalidated);
@@ -576,13 +586,18 @@ Future<Null> newWorldTest(
576586 }
577587 }
578588
579- if (! noFullComponent) {
580- Set <String > prevFormattedErrors = formattedErrors.toSet ();
581- Set <String > prevFormattedWarnings = formattedWarnings.toSet ();
589+ Set <String > prevFormattedErrors = formattedErrors.toSet ();
590+ Set <String > prevFormattedWarnings = formattedWarnings.toSet ();
591+
592+ clearPrevErrorsEtc () {
582593 gotError = false ;
583594 formattedErrors.clear ();
584595 gotWarning = false ;
585596 formattedWarnings.clear ();
597+ }
598+
599+ if (! noFullComponent) {
600+ clearPrevErrorsEtc ();
586601 Component component2 = await compiler.computeDelta (
587602 entryPoints: entries,
588603 fullComponent: true ,
@@ -593,29 +608,8 @@ Future<Null> newWorldTest(
593608 print ("*****\n\n component2:\n "
594609 "${componentToStringSdkFiltered (component2 )}\n\n\n " );
595610 checkIsEqual (newestWholeComponentData, thisWholeComponent);
596- if (prevFormattedErrors.length != formattedErrors.length) {
597- Expect .fail ("Previously had ${prevFormattedErrors .length } errors, "
598- "now had ${formattedErrors .length }.\n\n "
599- "Before:\n "
600- "${prevFormattedErrors .join ("\n " )}"
601- "\n\n "
602- "Now:\n "
603- "${formattedErrors .join ("\n " )}" );
604- }
605- if ((prevFormattedErrors.toSet ()..removeAll (formattedErrors))
606- .isNotEmpty) {
607- Expect .fail ("Previously got error messages $prevFormattedErrors , "
608- "now had ${formattedErrors }." );
609- }
610- if (prevFormattedWarnings.length != formattedWarnings.length) {
611- Expect .fail ("Previously had ${prevFormattedWarnings .length } errors, "
612- "now had ${formattedWarnings .length }." );
613- }
614- if ((prevFormattedWarnings.toSet ()..removeAll (formattedWarnings))
615- .isNotEmpty) {
616- Expect .fail ("Previously got error messages $prevFormattedWarnings , "
617- "now had ${formattedWarnings }." );
618- }
611+ checkErrorsAndWarnings (prevFormattedErrors, formattedErrors,
612+ prevFormattedWarnings, formattedWarnings);
619613 }
620614
621615 if (world["expressionCompilation" ] != null ) {
@@ -626,6 +620,35 @@ Future<Null> newWorldTest(
626620 }
627621}
628622
623+ void checkErrorsAndWarnings (
624+ Set <String > prevFormattedErrors,
625+ Set <String > formattedErrors,
626+ Set <String > prevFormattedWarnings,
627+ Set <String > formattedWarnings) {
628+ if (prevFormattedErrors.length != formattedErrors.length) {
629+ Expect .fail ("Previously had ${prevFormattedErrors .length } errors, "
630+ "now had ${formattedErrors .length }.\n\n "
631+ "Before:\n "
632+ "${prevFormattedErrors .join ("\n " )}"
633+ "\n\n "
634+ "Now:\n "
635+ "${formattedErrors .join ("\n " )}" );
636+ }
637+ if ((prevFormattedErrors.toSet ()..removeAll (formattedErrors)).isNotEmpty) {
638+ Expect .fail ("Previously got error messages $prevFormattedErrors , "
639+ "now had ${formattedErrors }." );
640+ }
641+ if (prevFormattedWarnings.length != formattedWarnings.length) {
642+ Expect .fail ("Previously had ${prevFormattedWarnings .length } errors, "
643+ "now had ${formattedWarnings .length }." );
644+ }
645+ if ((prevFormattedWarnings.toSet ()..removeAll (formattedWarnings))
646+ .isNotEmpty) {
647+ Expect .fail ("Previously got error messages $prevFormattedWarnings , "
648+ "now had ${formattedWarnings }." );
649+ }
650+ }
651+
629652void computeAllReachableLibrariesFor (Library lib, Set <Library > allLibraries) {
630653 Set <Library > libraries = new Set <Library >();
631654 List <Library > workList = < Library > [];
@@ -635,6 +658,7 @@ void computeAllReachableLibrariesFor(Library lib, Set<Library> allLibraries) {
635658 while (workList.isNotEmpty) {
636659 Library library = workList.removeLast ();
637660 for (LibraryDependency dependency in library.dependencies) {
661+ if (dependency.targetLibrary.importUri.scheme == "dart" ) continue ;
638662 if (libraries.add (dependency.targetLibrary)) {
639663 workList.add (dependency.targetLibrary);
640664 allLibraries.add (dependency.targetLibrary);
@@ -645,41 +669,49 @@ void computeAllReachableLibrariesFor(Library lib, Set<Library> allLibraries) {
645669
646670void checkExpectedContent (YamlMap world, Component component) {
647671 if (world["expectedContent" ] != null ) {
648- Map <String , Set <String >> actualContent = new Map <String , Set <String >>();
649- for (Library lib in component.libraries) {
650- Set <String > libContent =
651- actualContent[lib.importUri.toString ()] = new Set <String >();
652- for (Class c in lib.classes) {
653- libContent.add ("Class ${c .name }" );
654- }
655- for (Procedure p in lib.procedures) {
656- libContent.add ("Procedure ${p .name }" );
657- }
658- for (Field f in lib.fields) {
659- libContent.add ("Field ${f .name }" );
660- }
661- }
662-
672+ Map <String , Set <String >> actualContent = buildMapOfContent (component);
663673 Map expectedContent = world["expectedContent" ];
674+ checkExpectedContentData (actualContent, expectedContent);
675+ }
676+ }
664677
665- doThrow () {
666- throw "Expected and actual content not the same.\n "
667- "Expected $expectedContent .\n "
668- "Got $actualContent " ;
669- }
678+ void checkExpectedContentData (
679+ Map <String , Set <String >> actualContent, Map expectedContent) {
680+ doThrow () {
681+ throw "Expected and actual content not the same.\n "
682+ "Expected $expectedContent .\n "
683+ "Got $actualContent " ;
684+ }
670685
671- if (actualContent.length != expectedContent.length) doThrow ();
672- Set <String > missingKeys = actualContent.keys.toSet ()
673- ..removeAll (expectedContent.keys);
674- if (missingKeys.isNotEmpty) doThrow ();
675- for (String key in expectedContent.keys) {
676- Set <String > expected = new Set <String >.from (expectedContent[key]);
677- Set <String > actual = actualContent[key].toSet ();
678- if (expected.length != actual.length) doThrow ();
679- actual.removeAll (expected);
680- if (actual.isNotEmpty) doThrow ();
686+ if (actualContent.length != expectedContent.length) doThrow ();
687+ Set <String > missingKeys = actualContent.keys.toSet ()
688+ ..removeAll (expectedContent.keys);
689+ if (missingKeys.isNotEmpty) doThrow ();
690+ for (String key in expectedContent.keys) {
691+ Set <String > expected = new Set <String >.from (expectedContent[key]);
692+ Set <String > actual = actualContent[key].toSet ();
693+ if (expected.length != actual.length) doThrow ();
694+ actual.removeAll (expected);
695+ if (actual.isNotEmpty) doThrow ();
696+ }
697+ }
698+
699+ Map <String , Set <String >> buildMapOfContent (Component component) {
700+ Map <String , Set <String >> actualContent = new Map <String , Set <String >>();
701+ for (Library lib in component.libraries) {
702+ Set <String > libContent =
703+ actualContent[lib.importUri.toString ()] = new Set <String >();
704+ for (Class c in lib.classes) {
705+ libContent.add ("Class ${c .name }" );
706+ }
707+ for (Procedure p in lib.procedures) {
708+ libContent.add ("Procedure ${p .name }" );
709+ }
710+ for (Field f in lib.fields) {
711+ libContent.add ("Field ${f .name }" );
681712 }
682713 }
714+ return actualContent;
683715}
684716
685717void checkNeededDillLibraries (
0 commit comments