From 711da04fb4973ae05cd6018a4c5f4e1cfd7fda98 Mon Sep 17 00:00:00 2001 From: Johnni Winther Date: Wed, 24 Jun 2020 14:33:31 +0000 Subject: [PATCH] [cfe] Associate package uris with bin/test files in packages This CL adds a package uri to SourceLibraryBuilder based on the package information computated by package:package_config. This uri is used to determine whether experimental flags are enabled and thus using allowed_experiments.json in bin/test folders as well as the lib folder. Change-Id: I60e6e97139a4a24b8d4d27d314cfc0f7d7bfc816 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152151 Reviewed-by: Jens Johansen Commit-Queue: Johnni Winther --- .../src/api_prototype/experimental_flags.dart | 7 ++- .../src/fasta/dill/dill_library_builder.dart | 2 + .../lib/src/fasta/dill/dill_target.dart | 1 + .../lib/src/fasta/incremental_compiler.dart | 1 + .../lib/src/fasta/kernel/kernel_target.dart | 3 +- pkg/front_end/lib/src/fasta/loader.dart | 29 ++++++++---- .../fasta/source/source_library_builder.dart | 45 +++++++++++++----- .../lib/src/fasta/target_implementation.dart | 14 ++++++ .../test/fasta/generator_to_string_test.dart | 1 + .../language_version_in_packages/.packages | 2 +- .../language_version_in_packages/main.dart | 5 +- .../data/library_with_bad_version.dart | 2 +- ..._with_bad_version_before_good_version.dart | 2 +- .../package_default_version/lib/foo4.dart | 2 +- .../.dart_tool/package_config.json | 2 +- .../lib/foo.dart | 2 +- .../lib/foo2.dart | 2 +- .../.dart_tool/package_config.json | 2 +- .../lib/foo.dart | 2 +- .../lib/foo2.dart | 2 +- .../.dart_tool/package_config.json | 2 +- .../lib/foo.dart | 2 +- .../lib/foo2.dart | 2 +- .../.dart_tool/package_config.json | 2 +- .../lib/foo.dart | 2 +- .../lib/foo2.dart | 2 +- .../main.dart | 5 +- .../lib/foo.dart | 2 +- .../lib/foo2.dart | 4 +- .../lib/foo3.dart | 2 +- .../.dart_tool/package_config.json | 10 ++++ .../foo/bin/bin_file.dart | 10 ++++ .../package_with_test_json/foo/lib/foo.dart | 7 +++ .../foo/test/test_file.dart | 10 ++++ .../data/package_with_test_json/main.dart | 18 +++++++ .../data/package_with_test_packages/.packages | 1 + .../foo/bin/bin_file.dart | 10 ++++ .../foo/lib/foo.dart | 7 +++ .../foo/test/test_file.dart | 10 ++++ .../data/package_with_test_packages/main.dart | 11 +++++ .../.dart_tool/package_config.json | 9 ++++ .../foo/bin/bin_file.dart | 7 +++ .../foo/lib/foo.dart | 7 +++ .../foo/test/test_file.dart | 7 +++ .../data/package_without_test_json/main.dart | 18 +++++++ .../data/parts_disagreeing/main.dart | 2 +- .../lib/foo.dart | 2 +- .../lib/foo.dart | 2 +- .../.dart_tool/package_config.json | 2 +- .../data/specified_packages_04/main.dart | 4 +- .../data/specified_packages_04/null | 2 +- .../language_versioning_test.dart | 47 ++++++++++++++----- .../test/spell_checking_list_code.txt | 2 + 53 files changed, 290 insertions(+), 68 deletions(-) create mode 100644 pkg/front_end/test/language_versioning/data/package_with_test_json/.dart_tool/package_config.json create mode 100644 pkg/front_end/test/language_versioning/data/package_with_test_json/foo/bin/bin_file.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_with_test_json/foo/lib/foo.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_with_test_json/foo/test/test_file.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_with_test_json/main.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_with_test_packages/.packages create mode 100644 pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/bin/bin_file.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/lib/foo.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/test/test_file.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_with_test_packages/main.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_without_test_json/.dart_tool/package_config.json create mode 100644 pkg/front_end/test/language_versioning/data/package_without_test_json/foo/bin/bin_file.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_without_test_json/foo/lib/foo.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_without_test_json/foo/test/test_file.dart create mode 100644 pkg/front_end/test/language_versioning/data/package_without_test_json/main.dart diff --git a/pkg/front_end/lib/src/api_prototype/experimental_flags.dart b/pkg/front_end/lib/src/api_prototype/experimental_flags.dart index 9f21e27e62a..c318c3daff2 100644 --- a/pkg/front_end/lib/src/api_prototype/experimental_flags.dart +++ b/pkg/front_end/lib/src/api_prototype/experimental_flags.dart @@ -104,10 +104,13 @@ bool isExperimentEnabledInLibrary(ExperimentalFlag flag, Uri canonicalUri, allowedFlags = allowedExperimentalFlags.forSdkLibrary(canonicalUri.path); } else if (canonicalUri.scheme == 'package') { int index = canonicalUri.path.indexOf('/'); + String packageName; if (index >= 0) { - String packageName = canonicalUri.path.substring(0, index); - allowedFlags = allowedExperimentalFlags.forPackage(packageName); + packageName = canonicalUri.path.substring(0, index); + } else { + packageName = canonicalUri.path; } + allowedFlags = allowedExperimentalFlags.forPackage(packageName); } if (allowedFlags != null) { enabled = allowedFlags.contains(flag); diff --git a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart index e9a2f1d3256..be09ade8713 100644 --- a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart +++ b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart @@ -141,8 +141,10 @@ class DillLibraryBuilder extends LibraryBuilderImpl { void setLanguageVersion(Version version, {int offset: 0, int length, bool explicit}) {} + @override Uri get importUri => library.importUri; + @override Uri get fileUri => library.fileUri; @override diff --git a/pkg/front_end/lib/src/fasta/dill/dill_target.dart b/pkg/front_end/lib/src/fasta/dill/dill_target.dart index 2a6063696df..717c3481b33 100644 --- a/pkg/front_end/lib/src/fasta/dill/dill_target.dart +++ b/pkg/front_end/lib/src/fasta/dill/dill_target.dart @@ -65,6 +65,7 @@ class DillTarget extends TargetImplementation { DillLibraryBuilder createLibraryBuilder( Uri uri, Uri fileUri, + Uri packageUri, LibraryBuilder origin, Library referencesFrom, bool referenceIsPartOwner) { diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart index 8b987cf9df7..03d86c2a5d3 100644 --- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart +++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart @@ -1589,6 +1589,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { SourceLibraryBuilder debugLibrary = new SourceLibraryBuilder( libraryUri, debugExprUri, + /*packageUri*/ null, userCode.loader, null, scope: libraryBuilder.scope.createNestedScope("expression"), diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart index da02e67a268..d3e1c96caeb 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart @@ -245,6 +245,7 @@ class KernelTarget extends TargetImplementation { LibraryBuilder createLibraryBuilder( Uri uri, Uri fileUri, + Uri packageUri, SourceLibraryBuilder origin, Library referencesFrom, bool referenceIsPartOwner) { @@ -260,7 +261,7 @@ class KernelTarget extends TargetImplementation { return builder; } } - return new SourceLibraryBuilder(uri, fileUri, loader, origin, + return new SourceLibraryBuilder(uri, fileUri, packageUri, loader, origin, referencesFrom: referencesFrom, referenceIsPartOwner: referenceIsPartOwner); } diff --git a/pkg/front_end/lib/src/fasta/loader.dart b/pkg/front_end/lib/src/fasta/loader.dart index a7de26a5461..35c50079782 100644 --- a/pkg/front_end/lib/src/fasta/loader.dart +++ b/pkg/front_end/lib/src/fasta/loader.dart @@ -146,22 +146,31 @@ abstract class Loader { } bool hasPackageSpecifiedLanguageVersion = false; Version version; - if (packageForLanguageVersion != null && - packageForLanguageVersion.languageVersion != null) { - hasPackageSpecifiedLanguageVersion = true; - if (packageForLanguageVersion.languageVersion - is! InvalidLanguageVersion) { - version = new Version(packageForLanguageVersion.languageVersion.major, - packageForLanguageVersion.languageVersion.minor); + Uri packageUri; + if (packageForLanguageVersion != null) { + Uri importUri = origin?.importUri ?? uri; + if (importUri.scheme != 'dart' && + importUri.scheme != 'package' && + packageForLanguageVersion.name != null) { + packageUri = + new Uri(scheme: 'package', path: packageForLanguageVersion.name); + } + if (packageForLanguageVersion.languageVersion != null) { + hasPackageSpecifiedLanguageVersion = true; + if (packageForLanguageVersion.languageVersion + is! InvalidLanguageVersion) { + version = new Version( + packageForLanguageVersion.languageVersion.major, + packageForLanguageVersion.languageVersion.minor); + } } } - LibraryBuilder library = target.createLibraryBuilder( - uri, fileUri, origin, referencesFrom, referenceIsPartOwner); + LibraryBuilder library = target.createLibraryBuilder(uri, fileUri, + packageUri, origin, referencesFrom, referenceIsPartOwner); if (library == null) { throw new StateError("createLibraryBuilder for uri $uri, " "fileUri $fileUri returned null."); } - if (hasPackageSpecifiedLanguageVersion) { library.setLanguageVersion(version, explicit: false); } diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart index e6fa5c668fd..ab13bf7d44f 100644 --- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart +++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart @@ -188,6 +188,10 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { final Uri fileUri; + final Uri _packageUri; + + Uri get packageUriForTesting => _packageUri; + final List implementationBuilders = []; @@ -281,6 +285,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { SourceLibraryBuilder.internal( SourceLoader loader, Uri fileUri, + Uri packageUri, Scope scope, SourceLibraryBuilder actualOrigin, Library library, @@ -290,6 +295,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { : this.fromScopes( loader, fileUri, + packageUri, new TypeParameterScopeBuilder.library(), scope ?? new Scope.top(), actualOrigin, @@ -300,6 +306,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { SourceLibraryBuilder.fromScopes( this.loader, this.fileUri, + this._packageUri, this.libraryDeclaration, this.importScope, this.actualOrigin, @@ -312,6 +319,16 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { referencesFrom == null ? null : new IndexedLibrary(referencesFrom), super( fileUri, libraryDeclaration.toScope(importScope), new Scope.top()) { + assert( + _packageUri == null || + importUri.scheme != 'package' || + importUri.path.startsWith(_packageUri.path), + "Foreign package uri '$_packageUri' set on library with import uri " + "'${importUri}'."); + assert( + importUri.scheme != 'dart' || _packageUri == null, + "Package uri '$_packageUri' set on dart: library with import uri " + "'${importUri}'."); updateLibraryNNBDSettings(); } @@ -321,26 +338,27 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { bool _enableTripleShiftInLibrary; bool _enableExtensionMethodsInLibrary; - bool get enableVarianceInLibrary => _enableVarianceInLibrary ??= loader.target - .isExperimentEnabledInLibrary(ExperimentalFlag.variance, importUri); + bool get enableVarianceInLibrary => + _enableVarianceInLibrary ??= loader.target.isExperimentEnabledInLibrary( + ExperimentalFlag.variance, _packageUri ?? importUri); bool get enableNonfunctionTypeAliasesInLibrary => _enableNonfunctionTypeAliasesInLibrary ??= loader.target - .isExperimentEnabledInLibrary( - ExperimentalFlag.nonfunctionTypeAliases, importUri); + .isExperimentEnabledInLibrary(ExperimentalFlag.nonfunctionTypeAliases, + _packageUri ?? importUri); - bool get enableNonNullableInLibrary => _enableNonNullableInLibrary ??= loader - .target - .isExperimentEnabledInLibrary(ExperimentalFlag.nonNullable, importUri); + bool get enableNonNullableInLibrary => _enableNonNullableInLibrary ??= + loader.target.isExperimentEnabledInLibrary( + ExperimentalFlag.nonNullable, _packageUri ?? importUri); - bool get enableTripleShiftInLibrary => _enableTripleShiftInLibrary ??= loader - .target - .isExperimentEnabledInLibrary(ExperimentalFlag.tripleShift, importUri); + bool get enableTripleShiftInLibrary => _enableTripleShiftInLibrary ??= + loader.target.isExperimentEnabledInLibrary( + ExperimentalFlag.tripleShift, _packageUri ?? importUri); bool get enableExtensionMethodsInLibrary => _enableExtensionMethodsInLibrary ??= loader.target .isExperimentEnabledInLibrary( - ExperimentalFlag.extensionMethods, importUri); + ExperimentalFlag.extensionMethods, _packageUri ?? importUri); void updateLibraryNNBDSettings() { library.isNonNullableByDefault = isNonNullableByDefault; @@ -365,8 +383,8 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { } } - SourceLibraryBuilder( - Uri uri, Uri fileUri, Loader loader, SourceLibraryBuilder actualOrigin, + SourceLibraryBuilder(Uri uri, Uri fileUri, Uri packageUri, Loader loader, + SourceLibraryBuilder actualOrigin, {Scope scope, Library target, Library nameOrigin, @@ -375,6 +393,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { : this.internal( loader, fileUri, + packageUri, scope, actualOrigin, target ?? diff --git a/pkg/front_end/lib/src/fasta/target_implementation.dart b/pkg/front_end/lib/src/fasta/target_implementation.dart index e9f8d6cd49f..c3666ec205f 100644 --- a/pkg/front_end/lib/src/fasta/target_implementation.dart +++ b/pkg/front_end/lib/src/fasta/target_implementation.dart @@ -72,9 +72,23 @@ abstract class TargetImplementation extends Target { /// to locate the corresponding file. /// /// [origin] is non-null if the created library is a patch to [origin]. + /// + /// [packageUri] is the base uri for the package which the library belongs to. + /// For instance 'package:foo'. + /// + /// This is used to associate libraries in for instance the 'bin' and 'test' + /// folders of a package source with the package uri of the 'lib' folder. + /// + /// If the [packageUri] is `null` the package association of this library is + /// based on its [importUri]. + /// + /// For libraries with a 'package:' [importUri], the package path must match + /// the path in the [importUri]. For libraries with a 'dart:' [importUri] the + /// [packageUri] must be `null`. LibraryBuilder createLibraryBuilder( Uri uri, Uri fileUri, + Uri packageUri, covariant LibraryBuilder origin, Library referencesFrom, bool referenceIsPartOwner); diff --git a/pkg/front_end/test/fasta/generator_to_string_test.dart b/pkg/front_end/test/fasta/generator_to_string_test.dart index 356924f1258..84c4f144106 100644 --- a/pkg/front_end/test/fasta/generator_to_string_test.dart +++ b/pkg/front_end/test/fasta/generator_to_string_test.dart @@ -72,6 +72,7 @@ main() async { SourceLibraryBuilder libraryBuilder = new SourceLibraryBuilder( uri, uri, + /*packageUri*/ null, new KernelTarget( null, false, diff --git a/pkg/front_end/test/language_versioning/data/language_version_in_packages/.packages b/pkg/front_end/test/language_versioning/data/language_version_in_packages/.packages index 587cb99a223..6bfeac3584d 100644 --- a/pkg/front_end/test/language_versioning/data/language_version_in_packages/.packages +++ b/pkg/front_end/test/language_versioning/data/language_version_in_packages/.packages @@ -1 +1 @@ -foo:lib//*error: PackagesFileFormat*/#dart=2.6 \ No newline at end of file +foo:lib//*error: errors=PackagesFileFormat*/#dart=2.6 \ No newline at end of file diff --git a/pkg/front_end/test/language_versioning/data/language_version_in_packages/main.dart b/pkg/front_end/test/language_versioning/data/language_version_in_packages/main.dart index f5a4c345e14..13b612708f4 100644 --- a/pkg/front_end/test/language_versioning/data/language_version_in_packages/main.dart +++ b/pkg/front_end/test/language_versioning/data/language_version_in_packages/main.dart @@ -9,7 +9,10 @@ import 'package:foo/foo.dart'; -/*library: languageVersion=2.4*/ +/*library: + languageVersion=2.4, + packageUri=package:foo +*/ main() { var result = foo(); diff --git a/pkg/front_end/test/language_versioning/data/library_with_bad_version.dart b/pkg/front_end/test/language_versioning/data/library_with_bad_version.dart index 46a64edbf71..832417fe037 100644 --- a/pkg/front_end/test/language_versioning/data/library_with_bad_version.dart +++ b/pkg/front_end/test/language_versioning/data/library_with_bad_version.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*error: LanguageVersionTooHigh*/ +/*error: errors=LanguageVersionTooHigh*/ // @dart = 3.5 // If no valid language version is specified, we default to the most reason one. diff --git a/pkg/front_end/test/language_versioning/data/library_with_bad_version_before_good_version.dart b/pkg/front_end/test/language_versioning/data/library_with_bad_version_before_good_version.dart index 310f2ef2f48..838f46e8b9f 100644 --- a/pkg/front_end/test/language_versioning/data/library_with_bad_version_before_good_version.dart +++ b/pkg/front_end/test/language_versioning/data/library_with_bad_version_before_good_version.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*error: LanguageVersionTooHigh*/ +/*error: errors=LanguageVersionTooHigh*/ // @dart = 3.5 // @dart = 2.5 diff --git a/pkg/front_end/test/language_versioning/data/package_default_version/lib/foo4.dart b/pkg/front_end/test/language_versioning/data/package_default_version/lib/foo4.dart index 9591a55eac9..3d3297ce835 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version/lib/foo4.dart +++ b/pkg/front_end/test/language_versioning/data/package_default_version/lib/foo4.dart @@ -6,7 +6,7 @@ // except it still has to be within the range of the sdk. The library stays on // the .packages specified one (2.5) and an error is issued. -/*error: LanguageVersionTooHigh*/ +/*error: errors=LanguageVersionTooHigh*/ // @dart = 2.9 /*library: languageVersion=2.5*/ diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/.dart_tool/package_config.json b/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/.dart_tool/package_config.json index 6646f336f39..682473f577b 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/.dart_tool/package_config.json +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/.dart_tool/package_config.json @@ -1,4 +1,4 @@ -/*error: PackagesFileFormat*/ +/*error: errors=PackagesFileFormat*/ { "configVersion": 2, "packages": [ diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/lib/foo.dart b/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/lib/foo.dart index c669c2349f9..521797bf646 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/lib/foo.dart +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/lib/foo.dart @@ -1,4 +1,4 @@ -/*error: LanguageVersionInvalidInDotPackages*/ +/*error: errors=LanguageVersionInvalidInDotPackages*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/lib/foo2.dart b/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/lib/foo2.dart index 0e388370784..8542c2a4356 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/lib/foo2.dart +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_empty/lib/foo2.dart @@ -1,4 +1,4 @@ -/*error: LanguageVersionInvalidInDotPackages*/ +/*error: errors=LanguageVersionInvalidInDotPackages*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/.dart_tool/package_config.json b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/.dart_tool/package_config.json index 3b36ed48f4a..c818138928f 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/.dart_tool/package_config.json +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/.dart_tool/package_config.json @@ -1,4 +1,4 @@ -/*error: PackagesFileFormat*/ +/*error: errors=PackagesFileFormat*/ { "configVersion": 2, "packages": [ diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/lib/foo.dart b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/lib/foo.dart index c669c2349f9..521797bf646 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/lib/foo.dart +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/lib/foo.dart @@ -1,4 +1,4 @@ -/*error: LanguageVersionInvalidInDotPackages*/ +/*error: errors=LanguageVersionInvalidInDotPackages*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/lib/foo2.dart b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/lib/foo2.dart index 0e388370784..8542c2a4356 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/lib/foo2.dart +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong/lib/foo2.dart @@ -1,4 +1,4 @@ -/*error: LanguageVersionInvalidInDotPackages*/ +/*error: errors=LanguageVersionInvalidInDotPackages*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/.dart_tool/package_config.json b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/.dart_tool/package_config.json index 24d6c83ca0d..fcb75f5b882 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/.dart_tool/package_config.json +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/.dart_tool/package_config.json @@ -1,4 +1,4 @@ -/*error: PackagesFileFormat*/ +/*error: errors=PackagesFileFormat*/ { "configVersion": 2, "packages": [ diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/lib/foo.dart b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/lib/foo.dart index c669c2349f9..521797bf646 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/lib/foo.dart +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/lib/foo.dart @@ -1,4 +1,4 @@ -/*error: LanguageVersionInvalidInDotPackages*/ +/*error: errors=LanguageVersionInvalidInDotPackages*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/lib/foo2.dart b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/lib/foo2.dart index 0e388370784..8542c2a4356 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/lib/foo2.dart +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_3/lib/foo2.dart @@ -1,4 +1,4 @@ -/*error: LanguageVersionInvalidInDotPackages*/ +/*error: errors=LanguageVersionInvalidInDotPackages*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/.dart_tool/package_config.json b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/.dart_tool/package_config.json index d18e5863026..4b3591656b4 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/.dart_tool/package_config.json +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/.dart_tool/package_config.json @@ -1,4 +1,4 @@ -/*error: PackagesFileFormat*/ +/*error: errors=PackagesFileFormat*/ { "configVersion": 2, "packages": [ diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/lib/foo.dart b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/lib/foo.dart index c669c2349f9..521797bf646 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/lib/foo.dart +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/lib/foo.dart @@ -1,4 +1,4 @@ -/*error: LanguageVersionInvalidInDotPackages*/ +/*error: errors=LanguageVersionInvalidInDotPackages*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/lib/foo2.dart b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/lib/foo2.dart index 0e388370784..8542c2a4356 100644 --- a/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/lib/foo2.dart +++ b/pkg/front_end/test/language_versioning/data/package_default_version_is_wrong_4/lib/foo2.dart @@ -1,4 +1,4 @@ -/*error: LanguageVersionInvalidInDotPackages*/ +/*error: errors=LanguageVersionInvalidInDotPackages*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pkg/front_end/test/language_versioning/data/package_non_package_default_version/main.dart b/pkg/front_end/test/language_versioning/data/package_non_package_default_version/main.dart index e0c0c8b0a5d..59bf56aa470 100644 --- a/pkg/front_end/test/language_versioning/data/package_non_package_default_version/main.dart +++ b/pkg/front_end/test/language_versioning/data/package_non_package_default_version/main.dart @@ -6,7 +6,10 @@ import 'package:foo/foo.dart'; // Version comes from the package foo having this file in it's root uri. -/*library: languageVersion=2.5*/ +/*library: + languageVersion=2.5, + packageUri=package:foo +*/ main() { foo(); diff --git a/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo.dart b/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo.dart index 55d8f606446..a5a2002662d 100644 --- a/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo.dart +++ b/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo.dart @@ -1,4 +1,4 @@ -/*error: LanguageVersionTooHigh*/ +/*error: errors=LanguageVersionTooHigh*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo2.dart b/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo2.dart index e657fb0a75c..ef19f1d7d78 100644 --- a/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo2.dart +++ b/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo2.dart @@ -1,9 +1,9 @@ -/*error: LanguageVersionTooHigh*/ +/*error: errors=LanguageVersionTooHigh*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*error: LanguageVersionTooHigh*/ +/*error: errors=LanguageVersionTooHigh*/ // @dart = 2.9 /*library: languageVersion=2.8*/ diff --git a/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo3.dart b/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo3.dart index e3de4525fe8..09e1abf5500 100644 --- a/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo3.dart +++ b/pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo3.dart @@ -1,4 +1,4 @@ -/*error: LanguageVersionTooHigh*/ +/*error: errors=LanguageVersionTooHigh*/ // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pkg/front_end/test/language_versioning/data/package_with_test_json/.dart_tool/package_config.json b/pkg/front_end/test/language_versioning/data/package_with_test_json/.dart_tool/package_config.json new file mode 100644 index 00000000000..ffdb3738960 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_with_test_json/.dart_tool/package_config.json @@ -0,0 +1,10 @@ +{ + "configVersion": 2, + "packages": [ + { + "name": "foo", + "rootUri": "../foo/", + "packageUri": "lib/" + } + ] +} \ No newline at end of file diff --git a/pkg/front_end/test/language_versioning/data/package_with_test_json/foo/bin/bin_file.dart b/pkg/front_end/test/language_versioning/data/package_with_test_json/foo/bin/bin_file.dart new file mode 100644 index 00000000000..54bfce160b1 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_with_test_json/foo/bin/bin_file.dart @@ -0,0 +1,10 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: + languageVersion=2.8, + packageUri=package:foo +*/ + +method1() {} diff --git a/pkg/front_end/test/language_versioning/data/package_with_test_json/foo/lib/foo.dart b/pkg/front_end/test/language_versioning/data/package_with_test_json/foo/lib/foo.dart new file mode 100644 index 00000000000..68a5188c710 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_with_test_json/foo/lib/foo.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: languageVersion=2.8*/ + +method2() {} diff --git a/pkg/front_end/test/language_versioning/data/package_with_test_json/foo/test/test_file.dart b/pkg/front_end/test/language_versioning/data/package_with_test_json/foo/test/test_file.dart new file mode 100644 index 00000000000..9f74e213d75 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_with_test_json/foo/test/test_file.dart @@ -0,0 +1,10 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: + languageVersion=2.8, + packageUri=package:foo +*/ + +method3() {} diff --git a/pkg/front_end/test/language_versioning/data/package_with_test_json/main.dart b/pkg/front_end/test/language_versioning/data/package_with_test_json/main.dart new file mode 100644 index 00000000000..27a559dcbff --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_with_test_json/main.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: languageVersion=2.8*/ + +// Test that bin and test files within the root folder of a package are +// associated with the package. + +import 'foo/bin/bin_file.dart'; +import 'foo/test/test_file.dart'; +import 'package:foo/foo.dart'; + +main() { + method1(); + method2(); + method3(); +} diff --git a/pkg/front_end/test/language_versioning/data/package_with_test_packages/.packages b/pkg/front_end/test/language_versioning/data/package_with_test_packages/.packages new file mode 100644 index 00000000000..91fa8dd4313 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_with_test_packages/.packages @@ -0,0 +1 @@ +foo:foo/lib/ \ No newline at end of file diff --git a/pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/bin/bin_file.dart b/pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/bin/bin_file.dart new file mode 100644 index 00000000000..8f4889a5f84 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/bin/bin_file.dart @@ -0,0 +1,10 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: + languageVersion=2.7, + packageUri=package:foo +*/ + +method1() {} diff --git a/pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/lib/foo.dart b/pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/lib/foo.dart new file mode 100644 index 00000000000..e72d3b05537 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/lib/foo.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: languageVersion=2.7*/ + +method2() {} diff --git a/pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/test/test_file.dart b/pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/test/test_file.dart new file mode 100644 index 00000000000..f58d00c81c8 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_with_test_packages/foo/test/test_file.dart @@ -0,0 +1,10 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: + languageVersion=2.7, + packageUri=package:foo +*/ + +method3() {} diff --git a/pkg/front_end/test/language_versioning/data/package_with_test_packages/main.dart b/pkg/front_end/test/language_versioning/data/package_with_test_packages/main.dart new file mode 100644 index 00000000000..b29bc24e0a5 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_with_test_packages/main.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: languageVersion=2.8*/ + +import 'foo/bin/bin_file.dart'; +import 'foo/test/test_file.dart'; +import 'package:foo/foo.dart'; + +main() {} diff --git a/pkg/front_end/test/language_versioning/data/package_without_test_json/.dart_tool/package_config.json b/pkg/front_end/test/language_versioning/data/package_without_test_json/.dart_tool/package_config.json new file mode 100644 index 00000000000..597bf4555c7 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_without_test_json/.dart_tool/package_config.json @@ -0,0 +1,9 @@ +{ + "configVersion": 2, + "packages": [ + { + "name": "foo", + "rootUri": "../foo/lib/" + } + ] +} \ No newline at end of file diff --git a/pkg/front_end/test/language_versioning/data/package_without_test_json/foo/bin/bin_file.dart b/pkg/front_end/test/language_versioning/data/package_without_test_json/foo/bin/bin_file.dart new file mode 100644 index 00000000000..bd95be3fd42 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_without_test_json/foo/bin/bin_file.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: languageVersion=2.8*/ + +method1() {} diff --git a/pkg/front_end/test/language_versioning/data/package_without_test_json/foo/lib/foo.dart b/pkg/front_end/test/language_versioning/data/package_without_test_json/foo/lib/foo.dart new file mode 100644 index 00000000000..68a5188c710 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_without_test_json/foo/lib/foo.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: languageVersion=2.8*/ + +method2() {} diff --git a/pkg/front_end/test/language_versioning/data/package_without_test_json/foo/test/test_file.dart b/pkg/front_end/test/language_versioning/data/package_without_test_json/foo/test/test_file.dart new file mode 100644 index 00000000000..8943ce5c721 --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_without_test_json/foo/test/test_file.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: languageVersion=2.8*/ + +method3() {} diff --git a/pkg/front_end/test/language_versioning/data/package_without_test_json/main.dart b/pkg/front_end/test/language_versioning/data/package_without_test_json/main.dart new file mode 100644 index 00000000000..27a559dcbff --- /dev/null +++ b/pkg/front_end/test/language_versioning/data/package_without_test_json/main.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*library: languageVersion=2.8*/ + +// Test that bin and test files within the root folder of a package are +// associated with the package. + +import 'foo/bin/bin_file.dart'; +import 'foo/test/test_file.dart'; +import 'package:foo/foo.dart'; + +main() { + method1(); + method2(); + method3(); +} diff --git a/pkg/front_end/test/language_versioning/data/parts_disagreeing/main.dart b/pkg/front_end/test/language_versioning/data/parts_disagreeing/main.dart index e2e4fc43d34..fd22b71ce0d 100644 --- a/pkg/front_end/test/language_versioning/data/parts_disagreeing/main.dart +++ b/pkg/front_end/test/language_versioning/data/parts_disagreeing/main.dart @@ -4,7 +4,7 @@ // @dart = 2.5 -part /*error: LanguageVersionMismatchInPart*/ 'part.dart'; +part /*error: errors=LanguageVersionMismatchInPart*/ 'part.dart'; /*library: languageVersion=2.5*/ diff --git a/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package/lib/foo.dart b/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package/lib/foo.dart index 622a9e76ad5..aecb3c77cdd 100644 --- a/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package/lib/foo.dart +++ b/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package/lib/foo.dart @@ -7,7 +7,7 @@ // @dart = 2.5 -part /*error: LanguageVersionMismatchInPart*/ 'part.dart'; +part /*error: errors=LanguageVersionMismatchInPart*/ 'part.dart'; /*library: languageVersion=2.5*/ diff --git a/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package_2/lib/foo.dart b/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package_2/lib/foo.dart index 7c0e67cbfb5..e3e82810798 100644 --- a/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package_2/lib/foo.dart +++ b/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package_2/lib/foo.dart @@ -5,7 +5,7 @@ // The library and its part is both technically at language version 2.5, // but one is explicitly set, the other is not. That's an error. -part /*error: LanguageVersionMismatchInPart*/ 'part.dart'; +part /*error: errors=LanguageVersionMismatchInPart*/ 'part.dart'; /*library: languageVersion=2.5*/ diff --git a/pkg/front_end/test/language_versioning/data/specified_packages_04/.dart_tool/package_config.json b/pkg/front_end/test/language_versioning/data/specified_packages_04/.dart_tool/package_config.json index c4b490f5dfe..f138a4c3232 100644 --- a/pkg/front_end/test/language_versioning/data/specified_packages_04/.dart_tool/package_config.json +++ b/pkg/front_end/test/language_versioning/data/specified_packages_04/.dart_tool/package_config.json @@ -1 +1 @@ -/*error: PackagesFileFormat*/foo:foo2/ +/*error: errors=PackagesFileFormat*/foo:foo2/ diff --git a/pkg/front_end/test/language_versioning/data/specified_packages_04/main.dart b/pkg/front_end/test/language_versioning/data/specified_packages_04/main.dart index e625dcdeae7..b36e8ea3413 100644 --- a/pkg/front_end/test/language_versioning/data/specified_packages_04/main.dart +++ b/pkg/front_end/test/language_versioning/data/specified_packages_04/main.dart @@ -7,11 +7,11 @@ // @dart = 2.4 -import /*error: UntranslatableUri*/ 'package:foo/foo.dart'; +import /*error: errors=UntranslatableUri*/ 'package:foo/foo.dart'; /*library: languageVersion=2.4*/ main() { - var result = /*error: MethodNotFound*/ notNamedFoo(); + var result = /*error: errors=MethodNotFound*/ notNamedFoo(); print(result); } diff --git a/pkg/front_end/test/language_versioning/data/specified_packages_04/null b/pkg/front_end/test/language_versioning/data/specified_packages_04/null index 508fd9c27c5..5b039db04eb 100644 --- a/pkg/front_end/test/language_versioning/data/specified_packages_04/null +++ b/pkg/front_end/test/language_versioning/data/specified_packages_04/null @@ -1 +1 @@ -/*error: PackageNotFound*/ \ No newline at end of file +/*error: errors=PackageNotFound*/ \ No newline at end of file diff --git a/pkg/front_end/test/language_versioning/language_versioning_test.dart b/pkg/front_end/test/language_versioning/language_versioning_test.dart index 08631e7ed91..4146239d0f2 100644 --- a/pkg/front_end/test/language_versioning/language_versioning_test.dart +++ b/pkg/front_end/test/language_versioning/language_versioning_test.dart @@ -4,12 +4,15 @@ import 'dart:io' show Directory, File, Platform; import 'package:_fe_analyzer_shared/src/testing/id.dart' show ActualData, Id; +import 'package:_fe_analyzer_shared/src/testing/features.dart'; import 'package:_fe_analyzer_shared/src/testing/id_testing.dart' - show DataInterpreter, StringDataInterpreter, runTests; + show DataInterpreter, runTests; import 'package:_fe_analyzer_shared/src/testing/id_testing.dart'; import 'package:front_end/src/api_prototype/compiler_options.dart'; import 'package:front_end/src/api_prototype/language_version.dart' as lv; import 'package:front_end/src/fasta/messages.dart' show FormattedMessage; +import 'package:front_end/src/fasta/builder/library_builder.dart'; +import 'package:front_end/src/fasta/source/source_library_builder.dart'; import 'package:front_end/src/testing/id_testing_helper.dart' show CfeDataExtractor, @@ -19,6 +22,7 @@ import 'package:front_end/src/testing/id_testing_helper.dart' createUriForFileName, onFailure, runTestFor; +import 'package:front_end/src/testing/id_testing_utils.dart'; import 'package:kernel/ast.dart' show Component, Library, Version; @@ -29,7 +33,7 @@ main(List args) async { new TestConfigWithLanguageVersion(cfeMarker, "cfe"); Directory dataDir = new Directory.fromUri(Platform.script.resolve('data')); - await runTests(dataDir, + await runTests(dataDir, args: args, createUriForFileName: createUriForFileName, onFailure: onFailure, @@ -70,7 +74,13 @@ class TestConfigWithLanguageVersion extends TestConfig { } } -class LanguageVersioningDataComputer extends DataComputer { +class Tags { + static const String languageVersion = 'languageVersion'; + static const String packageUri = 'packageUri'; + static const String errors = 'errors'; +} + +class LanguageVersioningDataComputer extends DataComputer { const LanguageVersioningDataComputer(); Future inspectComponent(Component component) async { @@ -95,7 +105,7 @@ Language version API (import URI): ${lvImportUri} TestConfig config, InternalCompilerResult compilerResult, Library library, - Map> actualMap, + Map> actualMap, {bool verbose}) { new LanguageVersioningDataExtractor(compilerResult, actualMap) .computeForLibrary(library); @@ -104,24 +114,35 @@ Language version API (import URI): ${lvImportUri} @override bool get supportsErrors => true; - String computeErrorData(TestConfig config, InternalCompilerResult compiler, + Features computeErrorData(TestConfig config, InternalCompilerResult compiler, Id id, List errors) { - return errors.map((m) => m.code.name).join(','); + Features features = new Features(); + features[Tags.errors] = errors.map((m) => m.code.name).join(','); + return features; } @override - DataInterpreter get dataValidator => const StringDataInterpreter(); + DataInterpreter get dataValidator => + const FeaturesDataInterpreter(); } -class LanguageVersioningDataExtractor extends CfeDataExtractor { +class LanguageVersioningDataExtractor extends CfeDataExtractor { LanguageVersioningDataExtractor(InternalCompilerResult compilerResult, - Map> actualMap) + Map> actualMap) : super(compilerResult, actualMap); @override - String computeLibraryValue(Id id, Library library) { - return "languageVersion=${library.languageVersion.major}" - "." - "${library.languageVersion.minor}"; + Features computeLibraryValue(Id id, Library library) { + Features features = new Features(); + features[Tags.languageVersion] = + "${library.languageVersion.major}.${library.languageVersion.minor}"; + LibraryBuilder libraryBuilder = + lookupLibraryBuilder(compilerResult, library); + if (libraryBuilder is SourceLibraryBuilder && + libraryBuilder.packageUriForTesting != null) { + features[Tags.packageUri] = + libraryBuilder.packageUriForTesting.toString(); + } + return features; } } diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt index 649154f099b..37304707bb0 100644 --- a/pkg/front_end/test/spell_checking_list_code.txt +++ b/pkg/front_end/test/spell_checking_list_code.txt @@ -59,6 +59,7 @@ askesc aspx assigning assigns +association ast asy async @@ -412,6 +413,7 @@ fn fo foo foobar +foreign formed former fortunately