move shared test logic into mixins
Previously I had shared logic in a base reflective test class. This made marking tests (in the base class) as failing difficult.
This just migrates the shared logic to mixins. No test logic is changed.
Do note that the mixins are temporary. When we enable multi-option contexts they will be deleted.
Change-Id: I22f6651a79b6ccc125fb97dc2a0dbc2efa86fe6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358327
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart b/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart
index 2ebdbd4..7b32b48 100644
--- a/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart
@@ -43,7 +43,50 @@
final _singleOptionsContextsDefault = ContextLocatorImpl.singleOptionContexts;
@reflectiveTest
-class AnalysisContextCollectionLowTest with ResourceProviderMixin {
+class AnalysisContextCollectionLowTest
+ with ResourceProviderMixin, AnalysisContextCollectionLowTestMixin {}
+
+/// To be removed when `singleOptionContexts` defaults to false.
+@reflectiveTest
+class AnalysisContextCollectionLowTest_SingleOptionsPerContext
+ with ResourceProviderMixin, AnalysisContextCollectionLowTestMixin {
+ @override
+ bool get enableSingleOptionContexts => true;
+
+ @override
+ test_new_outer_inner() {
+ var outerFolder = newFolder('/test/outer');
+ newFile('/test/outer/lib/outer.dart', '');
+
+ var innerFolder = newFolder('/test/outer/inner');
+ newAnalysisOptionsYamlFile('/test/outer/inner', '');
+ newFile('/test/outer/inner/inner.dart', '');
+
+ var collection = _newCollection(includedPaths: [outerFolder.path]);
+
+ expect(collection.contexts, hasLength(2));
+
+ var outerContext = collection.contexts
+ .singleWhere((c) => c.contextRoot.root == outerFolder);
+ var innerContext = collection.contexts
+ .singleWhere((c) => c.contextRoot.root == innerFolder);
+ expect(innerContext, isNot(same(outerContext)));
+
+ // Outer and inner contexts own corresponding files.
+ expect(collection.contextFor(convertPath('/test/outer/lib/outer.dart')),
+ same(outerContext));
+ expect(collection.contextFor(convertPath('/test/outer/inner/inner.dart')),
+ same(innerContext));
+
+ // The file does not have to exist, during creation, or at all.
+ expect(collection.contextFor(convertPath('/test/outer/lib/outer2.dart')),
+ same(outerContext));
+ expect(collection.contextFor(convertPath('/test/outer/inner/inner2.dart')),
+ same(innerContext));
+ }
+}
+
+mixin AnalysisContextCollectionLowTestMixin on ResourceProviderMixin {
bool get enableSingleOptionContexts => false;
Folder get sdkRoot => newFolder('/sdk');
@@ -193,48 +236,402 @@
}
}
+@reflectiveTest
+class AnalysisContextCollectionTest
+ with ResourceProviderMixin, AnalysisContextCollectionTestMixin {}
+
/// To be removed when `singleOptionContexts` defaults to false.
@reflectiveTest
-class AnalysisContextCollectionLowTest_SingleOptionsPerContext
- extends AnalysisContextCollectionLowTest {
+class AnalysisContextCollectionTest_SingleOptionsPerContext
+ with ResourceProviderMixin, AnalysisContextCollectionTestMixin {
@override
bool get enableSingleOptionContexts => true;
@override
- test_new_outer_inner() {
- var outerFolder = newFolder('/test/outer');
- newFile('/test/outer/lib/outer.dart', '');
+ test_packageConfigWorkspace_multipleAnalysisOptions() async {
+ final workspaceRootPath = '/home';
+ final testPackageRootPath = '$workspaceRootPath/test';
+ final testPackageLibPath = '$testPackageRootPath/lib';
- var innerFolder = newFolder('/test/outer/inner');
- newAnalysisOptionsYamlFile('/test/outer/inner', '');
- newFile('/test/outer/inner/inner.dart', '');
+ newPubspecYamlFile(testPackageRootPath, r'''
+name: test
+''');
- var collection = _newCollection(includedPaths: [outerFolder.path]);
+ newSinglePackageConfigJsonFile(
+ packagePath: testPackageRootPath,
+ name: 'test',
+ );
- expect(collection.contexts, hasLength(2));
+ newAnalysisOptionsYamlFile(testPackageRootPath, '');
+ newFile('$testPackageLibPath/a.dart', '');
- var outerContext = collection.contexts
- .singleWhere((c) => c.contextRoot.root == outerFolder);
- var innerContext = collection.contexts
- .singleWhere((c) => c.contextRoot.root == innerFolder);
- expect(innerContext, isNot(same(outerContext)));
+ final nestedPath = '$testPackageLibPath/nested';
+ newAnalysisOptionsYamlFile(nestedPath, '');
+ newFile('$nestedPath/b.dart', '');
- // Outer and inner contexts own corresponding files.
- expect(collection.contextFor(convertPath('/test/outer/lib/outer.dart')),
- same(outerContext));
- expect(collection.contextFor(convertPath('/test/outer/inner/inner.dart')),
- same(innerContext));
+ _assertWorkspaceCollectionText(workspaceRootPath, r'''
+contexts
+ /home/test
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_0
+ analyzedFiles
+ /home/test/lib/a.dart
+ uri: package:test/a.dart
+ analysisOptions_0
+ workspacePackage_0_0
+ /home/test/lib/nested
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_1
+ analyzedFiles
+ /home/test/lib/nested/b.dart
+ uri: package:test/nested/b.dart
+ analysisOptions_1
+ workspacePackage_1_0
+analysisOptions
+ analysisOptions_0: /home/test/analysis_options.yaml
+ analysisOptions_1: /home/test/lib/nested/analysis_options.yaml
+workspaces
+ workspace_0: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_0_0: PubPackage
+ root: /home/test
+ workspace_1: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_1_0: PubPackage
+ root: /home/test
+''');
+ }
- // The file does not have to exist, during creation, or at all.
- expect(collection.contextFor(convertPath('/test/outer/lib/outer2.dart')),
- same(outerContext));
- expect(collection.contextFor(convertPath('/test/outer/inner/inner2.dart')),
- same(innerContext));
+ @override
+ test_packageConfigWorkspace_multipleAnalysisOptions_nestedExclude() async {
+ final workspaceRootPath = '/home';
+ final testPackageRootPath = '$workspaceRootPath/test';
+ final testPackageLibPath = '$testPackageRootPath/lib';
+
+ newPubspecYamlFile(testPackageRootPath, r'''
+name: test
+''');
+
+ newSinglePackageConfigJsonFile(
+ packagePath: testPackageRootPath,
+ name: 'test',
+ );
+
+ newAnalysisOptionsYamlFile(testPackageRootPath, '');
+ newFile('$testPackageLibPath/a.dart', '');
+
+ final nestedPath = '$testPackageLibPath/nested';
+ newAnalysisOptionsYamlFile(nestedPath, r'''
+analyzer:
+ exclude:
+ - excluded/**
+''');
+ newFile('$nestedPath/b.dart', '');
+ newFile('$nestedPath/excluded/b.dart', '');
+
+ _assertWorkspaceCollectionText(workspaceRootPath, r'''
+contexts
+ /home/test
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_0
+ analyzedFiles
+ /home/test/lib/a.dart
+ uri: package:test/a.dart
+ analysisOptions_0
+ workspacePackage_0_0
+ /home/test/lib/nested
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_1
+ analyzedFiles
+ /home/test/lib/nested/b.dart
+ uri: package:test/nested/b.dart
+ analysisOptions_1
+ workspacePackage_1_0
+analysisOptions
+ analysisOptions_0: /home/test/analysis_options.yaml
+ analysisOptions_1: /home/test/lib/nested/analysis_options.yaml
+workspaces
+ workspace_0: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_0_0: PubPackage
+ root: /home/test
+ workspace_1: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_1_0: PubPackage
+ root: /home/test
+''');
+ }
+
+ @override
+ test_packageConfigWorkspace_multipleAnalysisOptions_nestedNestedExclude() async {
+ final workspaceRootPath = '/home';
+ final testPackageRootPath = '$workspaceRootPath/test';
+ final testPackageLibPath = '$testPackageRootPath/lib';
+
+ newPubspecYamlFile(testPackageRootPath, r'''
+name: test
+''');
+
+ newSinglePackageConfigJsonFile(
+ packagePath: testPackageRootPath,
+ name: 'test',
+ );
+
+ newAnalysisOptionsYamlFile(testPackageRootPath, '');
+ newFile('$testPackageLibPath/a.dart', '');
+
+ final nestedPath = '$testPackageLibPath/nested';
+ newAnalysisOptionsYamlFile(nestedPath, r'''
+analyzer:
+ exclude:
+ - excluded/**
+''');
+ newFile('$nestedPath/b.dart', '');
+ newFile('$nestedPath/excluded/b.dart', '');
+
+ final nestedNestedPath = '$nestedPath/nested';
+ newAnalysisOptionsYamlFile(nestedNestedPath, r'''
+analyzer:
+ exclude:
+ - excluded/**
+''');
+ newFile('$nestedNestedPath/c.dart', '');
+ newFile('$nestedNestedPath/excluded/d.dart', '');
+
+ _assertWorkspaceCollectionText(workspaceRootPath, r'''
+contexts
+ /home/test
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_0
+ analyzedFiles
+ /home/test/lib/a.dart
+ uri: package:test/a.dart
+ analysisOptions_0
+ workspacePackage_0_0
+ /home/test/lib/nested
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_1
+ analyzedFiles
+ /home/test/lib/nested/b.dart
+ uri: package:test/nested/b.dart
+ analysisOptions_1
+ workspacePackage_1_0
+ /home/test/lib/nested/nested
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_2
+ analyzedFiles
+ /home/test/lib/nested/nested/c.dart
+ uri: package:test/nested/nested/c.dart
+ analysisOptions_2
+ workspacePackage_2_0
+analysisOptions
+ analysisOptions_0: /home/test/analysis_options.yaml
+ analysisOptions_1: /home/test/lib/nested/analysis_options.yaml
+ analysisOptions_2: /home/test/lib/nested/nested/analysis_options.yaml
+workspaces
+ workspace_0: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_0_0: PubPackage
+ root: /home/test
+ workspace_1: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_1_0: PubPackage
+ root: /home/test
+ workspace_2: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_2_0: PubPackage
+ root: /home/test
+''');
+ }
+
+ @override
+ test_packageConfigWorkspace_multipleAnalysisOptions_outerExclude() async {
+ final workspaceRootPath = '/home';
+ final testPackageRootPath = '$workspaceRootPath/test';
+ final testPackageLibPath = '$testPackageRootPath/lib';
+
+ newPubspecYamlFile(testPackageRootPath, r'''
+name: test
+''');
+
+ newSinglePackageConfigJsonFile(
+ packagePath: testPackageRootPath,
+ name: 'test',
+ );
+
+ newAnalysisOptionsYamlFile(testPackageRootPath, r'''
+analyzer:
+ exclude:
+ - excluded/**
+''');
+ newFile('$testPackageLibPath/a.dart', '');
+ newFile('$testPackageRootPath/excluded/b.dart', '');
+
+ final nestedPath = '$testPackageLibPath/nested';
+ newAnalysisOptionsYamlFile(nestedPath, '');
+ newFile('$nestedPath/b.dart', '');
+
+ _assertWorkspaceCollectionText(workspaceRootPath, r'''
+contexts
+ /home/test
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_0
+ analyzedFiles
+ /home/test/lib/a.dart
+ uri: package:test/a.dart
+ analysisOptions_0
+ workspacePackage_0_0
+ /home/test/lib/nested
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_1
+ analyzedFiles
+ /home/test/lib/nested/b.dart
+ uri: package:test/nested/b.dart
+ analysisOptions_1
+ workspacePackage_1_0
+analysisOptions
+ analysisOptions_0: /home/test/analysis_options.yaml
+ analysisOptions_1: /home/test/lib/nested/analysis_options.yaml
+workspaces
+ workspace_0: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_0_0: PubPackage
+ root: /home/test
+ workspace_1: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_1_0: PubPackage
+ root: /home/test
+''');
+ }
+
+ @override
+ test_packageConfigWorkspace_multipleAnalysisOptions_overridingOptions() async {
+ final workspaceRootPath = '/home';
+ final testPackageRootPath = '$workspaceRootPath/test';
+ final testPackageLibPath = '$testPackageRootPath/lib';
+
+ newPubspecYamlFile(testPackageRootPath, r'''
+name: test
+''');
+
+ newSinglePackageConfigJsonFile(
+ packagePath: testPackageRootPath,
+ name: 'test',
+ );
+
+ var rootOptionsFile = newAnalysisOptionsYamlFile(testPackageRootPath, '');
+ newFile('$testPackageLibPath/a.dart', '');
+
+ final nestedPath = '$testPackageLibPath/nested';
+ newAnalysisOptionsYamlFile(nestedPath, '');
+ newFile('$nestedPath/b.dart', '');
+
+ // Verify that despite the nested options file
+ // (/home/test/nested/analysis_options.yaml), the nested file gets analyzed
+ // with the outer one (/home/test/analysis_options.yaml) as passed into
+ // the AnalysisContextCollection.
+ _assertWorkspaceCollectionText(
+ workspaceRootPath, optionsFile: rootOptionsFile, r'''
+contexts
+ /home/test
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_0
+ analyzedFiles
+ /home/test/lib/a.dart
+ uri: package:test/a.dart
+ analysisOptions_0
+ workspacePackage_0_0
+ /home/test/lib/nested/b.dart
+ uri: package:test/nested/b.dart
+ analysisOptions_0
+ workspacePackage_0_0
+analysisOptions
+ analysisOptions_0: /home/test/analysis_options.yaml
+workspaces
+ workspace_0: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_0_0: PubPackage
+ root: /home/test
+''');
+ }
+
+ @override
+ test_packageConfigWorkspace_singleAnalysisOptions_multipleContexts() async {
+ final workspaceRootPath = '/home';
+ final testPackageRootPath = '$workspaceRootPath/test';
+ final testPackageLibPath = '$testPackageRootPath/lib';
+
+ newAnalysisOptionsYamlFile(testPackageRootPath, '');
+
+ newPubspecYamlFile(testPackageRootPath, r'''
+name: test
+''');
+
+ newSinglePackageConfigJsonFile(
+ packagePath: testPackageRootPath,
+ name: 'test',
+ );
+
+ newFile('$testPackageLibPath/a.dart', '');
+
+ final nestedPackageRootPath = '$testPackageRootPath/nested';
+ newPubspecYamlFile(nestedPackageRootPath, r'''
+name: nested
+''');
+ newSinglePackageConfigJsonFile(
+ packagePath: nestedPackageRootPath,
+ name: 'nested',
+ );
+ newFile('$nestedPackageRootPath/lib/b.dart', '');
+
+ // TODO(pq): there should only be one shared options instance
+ _assertWorkspaceCollectionText(workspaceRootPath, r'''
+contexts
+ /home/test
+ packagesFile: /home/test/.dart_tool/package_config.json
+ workspace: workspace_0
+ analyzedFiles
+ /home/test/lib/a.dart
+ uri: package:test/a.dart
+ analysisOptions_0
+ workspacePackage_0_0
+ /home/test/nested
+ packagesFile: /home/test/nested/.dart_tool/package_config.json
+ workspace: workspace_1
+ analyzedFiles
+ /home/test/nested/lib/b.dart
+ uri: package:nested/b.dart
+ analysisOptions_1
+ workspacePackage_1_0
+analysisOptions
+ analysisOptions_0: /home/test/analysis_options.yaml
+ analysisOptions_1: /home/test/analysis_options.yaml
+workspaces
+ workspace_0: PackageConfigWorkspace
+ root: /home/test
+ pubPackages
+ workspacePackage_0_0: PubPackage
+ root: /home/test
+ workspace_1: PackageConfigWorkspace
+ root: /home/test/nested
+ pubPackages
+ workspacePackage_1_0: PubPackage
+ root: /home/test/nested
+''');
}
}
-@reflectiveTest
-class AnalysisContextCollectionTest with ResourceProviderMixin {
+mixin AnalysisContextCollectionTestMixin on ResourceProviderMixin {
final _AnalysisContextCollectionPrinterConfiguration configuration =
_AnalysisContextCollectionPrinterConfiguration();
@@ -1031,397 +1428,6 @@
}
}
-/// To be removed when `singleOptionContexts` defaults to false.
-@reflectiveTest
-class AnalysisContextCollectionTest_SingleOptionsPerContext
- extends AnalysisContextCollectionTest {
- @override
- bool get enableSingleOptionContexts => true;
-
- @override
- test_packageConfigWorkspace_multipleAnalysisOptions() async {
- final workspaceRootPath = '/home';
- final testPackageRootPath = '$workspaceRootPath/test';
- final testPackageLibPath = '$testPackageRootPath/lib';
-
- newPubspecYamlFile(testPackageRootPath, r'''
-name: test
-''');
-
- newSinglePackageConfigJsonFile(
- packagePath: testPackageRootPath,
- name: 'test',
- );
-
- newAnalysisOptionsYamlFile(testPackageRootPath, '');
- newFile('$testPackageLibPath/a.dart', '');
-
- final nestedPath = '$testPackageLibPath/nested';
- newAnalysisOptionsYamlFile(nestedPath, '');
- newFile('$nestedPath/b.dart', '');
-
- _assertWorkspaceCollectionText(workspaceRootPath, r'''
-contexts
- /home/test
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_0
- analyzedFiles
- /home/test/lib/a.dart
- uri: package:test/a.dart
- analysisOptions_0
- workspacePackage_0_0
- /home/test/lib/nested
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_1
- analyzedFiles
- /home/test/lib/nested/b.dart
- uri: package:test/nested/b.dart
- analysisOptions_1
- workspacePackage_1_0
-analysisOptions
- analysisOptions_0: /home/test/analysis_options.yaml
- analysisOptions_1: /home/test/lib/nested/analysis_options.yaml
-workspaces
- workspace_0: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_0_0: PubPackage
- root: /home/test
- workspace_1: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_1_0: PubPackage
- root: /home/test
-''');
- }
-
- @override
- test_packageConfigWorkspace_multipleAnalysisOptions_nestedExclude() async {
- final workspaceRootPath = '/home';
- final testPackageRootPath = '$workspaceRootPath/test';
- final testPackageLibPath = '$testPackageRootPath/lib';
-
- newPubspecYamlFile(testPackageRootPath, r'''
-name: test
-''');
-
- newSinglePackageConfigJsonFile(
- packagePath: testPackageRootPath,
- name: 'test',
- );
-
- newAnalysisOptionsYamlFile(testPackageRootPath, '');
- newFile('$testPackageLibPath/a.dart', '');
-
- final nestedPath = '$testPackageLibPath/nested';
- newAnalysisOptionsYamlFile(nestedPath, r'''
-analyzer:
- exclude:
- - excluded/**
-''');
- newFile('$nestedPath/b.dart', '');
- newFile('$nestedPath/excluded/b.dart', '');
-
- _assertWorkspaceCollectionText(workspaceRootPath, r'''
-contexts
- /home/test
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_0
- analyzedFiles
- /home/test/lib/a.dart
- uri: package:test/a.dart
- analysisOptions_0
- workspacePackage_0_0
- /home/test/lib/nested
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_1
- analyzedFiles
- /home/test/lib/nested/b.dart
- uri: package:test/nested/b.dart
- analysisOptions_1
- workspacePackage_1_0
-analysisOptions
- analysisOptions_0: /home/test/analysis_options.yaml
- analysisOptions_1: /home/test/lib/nested/analysis_options.yaml
-workspaces
- workspace_0: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_0_0: PubPackage
- root: /home/test
- workspace_1: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_1_0: PubPackage
- root: /home/test
-''');
- }
-
- @override
- test_packageConfigWorkspace_multipleAnalysisOptions_nestedNestedExclude() async {
- final workspaceRootPath = '/home';
- final testPackageRootPath = '$workspaceRootPath/test';
- final testPackageLibPath = '$testPackageRootPath/lib';
-
- newPubspecYamlFile(testPackageRootPath, r'''
-name: test
-''');
-
- newSinglePackageConfigJsonFile(
- packagePath: testPackageRootPath,
- name: 'test',
- );
-
- newAnalysisOptionsYamlFile(testPackageRootPath, '');
- newFile('$testPackageLibPath/a.dart', '');
-
- final nestedPath = '$testPackageLibPath/nested';
- newAnalysisOptionsYamlFile(nestedPath, r'''
-analyzer:
- exclude:
- - excluded/**
-''');
- newFile('$nestedPath/b.dart', '');
- newFile('$nestedPath/excluded/b.dart', '');
-
- final nestedNestedPath = '$nestedPath/nested';
- newAnalysisOptionsYamlFile(nestedNestedPath, r'''
-analyzer:
- exclude:
- - excluded/**
-''');
- newFile('$nestedNestedPath/c.dart', '');
- newFile('$nestedNestedPath/excluded/d.dart', '');
-
- _assertWorkspaceCollectionText(workspaceRootPath, r'''
-contexts
- /home/test
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_0
- analyzedFiles
- /home/test/lib/a.dart
- uri: package:test/a.dart
- analysisOptions_0
- workspacePackage_0_0
- /home/test/lib/nested
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_1
- analyzedFiles
- /home/test/lib/nested/b.dart
- uri: package:test/nested/b.dart
- analysisOptions_1
- workspacePackage_1_0
- /home/test/lib/nested/nested
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_2
- analyzedFiles
- /home/test/lib/nested/nested/c.dart
- uri: package:test/nested/nested/c.dart
- analysisOptions_2
- workspacePackage_2_0
-analysisOptions
- analysisOptions_0: /home/test/analysis_options.yaml
- analysisOptions_1: /home/test/lib/nested/analysis_options.yaml
- analysisOptions_2: /home/test/lib/nested/nested/analysis_options.yaml
-workspaces
- workspace_0: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_0_0: PubPackage
- root: /home/test
- workspace_1: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_1_0: PubPackage
- root: /home/test
- workspace_2: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_2_0: PubPackage
- root: /home/test
-''');
- }
-
- @override
- test_packageConfigWorkspace_multipleAnalysisOptions_outerExclude() async {
- final workspaceRootPath = '/home';
- final testPackageRootPath = '$workspaceRootPath/test';
- final testPackageLibPath = '$testPackageRootPath/lib';
-
- newPubspecYamlFile(testPackageRootPath, r'''
-name: test
-''');
-
- newSinglePackageConfigJsonFile(
- packagePath: testPackageRootPath,
- name: 'test',
- );
-
- newAnalysisOptionsYamlFile(testPackageRootPath, r'''
-analyzer:
- exclude:
- - excluded/**
-''');
- newFile('$testPackageLibPath/a.dart', '');
- newFile('$testPackageRootPath/excluded/b.dart', '');
-
- final nestedPath = '$testPackageLibPath/nested';
- newAnalysisOptionsYamlFile(nestedPath, '');
- newFile('$nestedPath/b.dart', '');
-
- _assertWorkspaceCollectionText(workspaceRootPath, r'''
-contexts
- /home/test
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_0
- analyzedFiles
- /home/test/lib/a.dart
- uri: package:test/a.dart
- analysisOptions_0
- workspacePackage_0_0
- /home/test/lib/nested
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_1
- analyzedFiles
- /home/test/lib/nested/b.dart
- uri: package:test/nested/b.dart
- analysisOptions_1
- workspacePackage_1_0
-analysisOptions
- analysisOptions_0: /home/test/analysis_options.yaml
- analysisOptions_1: /home/test/lib/nested/analysis_options.yaml
-workspaces
- workspace_0: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_0_0: PubPackage
- root: /home/test
- workspace_1: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_1_0: PubPackage
- root: /home/test
-''');
- }
-
- @override
- test_packageConfigWorkspace_multipleAnalysisOptions_overridingOptions() async {
- final workspaceRootPath = '/home';
- final testPackageRootPath = '$workspaceRootPath/test';
- final testPackageLibPath = '$testPackageRootPath/lib';
-
- newPubspecYamlFile(testPackageRootPath, r'''
-name: test
-''');
-
- newSinglePackageConfigJsonFile(
- packagePath: testPackageRootPath,
- name: 'test',
- );
-
- var rootOptionsFile = newAnalysisOptionsYamlFile(testPackageRootPath, '');
- newFile('$testPackageLibPath/a.dart', '');
-
- final nestedPath = '$testPackageLibPath/nested';
- newAnalysisOptionsYamlFile(nestedPath, '');
- newFile('$nestedPath/b.dart', '');
-
- // Verify that despite the nested options file
- // (/home/test/nested/analysis_options.yaml), the nested file gets analyzed
- // with the outer one (/home/test/analysis_options.yaml) as passed into
- // the AnalysisContextCollection.
- _assertWorkspaceCollectionText(
- workspaceRootPath, optionsFile: rootOptionsFile, r'''
-contexts
- /home/test
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_0
- analyzedFiles
- /home/test/lib/a.dart
- uri: package:test/a.dart
- analysisOptions_0
- workspacePackage_0_0
- /home/test/lib/nested/b.dart
- uri: package:test/nested/b.dart
- analysisOptions_0
- workspacePackage_0_0
-analysisOptions
- analysisOptions_0: /home/test/analysis_options.yaml
-workspaces
- workspace_0: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_0_0: PubPackage
- root: /home/test
-''');
- }
-
- @override
- test_packageConfigWorkspace_singleAnalysisOptions_multipleContexts() async {
- final workspaceRootPath = '/home';
- final testPackageRootPath = '$workspaceRootPath/test';
- final testPackageLibPath = '$testPackageRootPath/lib';
-
- newAnalysisOptionsYamlFile(testPackageRootPath, '');
-
- newPubspecYamlFile(testPackageRootPath, r'''
-name: test
-''');
-
- newSinglePackageConfigJsonFile(
- packagePath: testPackageRootPath,
- name: 'test',
- );
-
- newFile('$testPackageLibPath/a.dart', '');
-
- final nestedPackageRootPath = '$testPackageRootPath/nested';
- newPubspecYamlFile(nestedPackageRootPath, r'''
-name: nested
-''');
- newSinglePackageConfigJsonFile(
- packagePath: nestedPackageRootPath,
- name: 'nested',
- );
- newFile('$nestedPackageRootPath/lib/b.dart', '');
-
- // TODO(pq): there should only be one shared options instance
- _assertWorkspaceCollectionText(workspaceRootPath, r'''
-contexts
- /home/test
- packagesFile: /home/test/.dart_tool/package_config.json
- workspace: workspace_0
- analyzedFiles
- /home/test/lib/a.dart
- uri: package:test/a.dart
- analysisOptions_0
- workspacePackage_0_0
- /home/test/nested
- packagesFile: /home/test/nested/.dart_tool/package_config.json
- workspace: workspace_1
- analyzedFiles
- /home/test/nested/lib/b.dart
- uri: package:nested/b.dart
- analysisOptions_1
- workspacePackage_1_0
-analysisOptions
- analysisOptions_0: /home/test/analysis_options.yaml
- analysisOptions_1: /home/test/analysis_options.yaml
-workspaces
- workspace_0: PackageConfigWorkspace
- root: /home/test
- pubPackages
- workspacePackage_0_0: PubPackage
- root: /home/test
- workspace_1: PackageConfigWorkspace
- root: /home/test/nested
- pubPackages
- workspacePackage_1_0: PubPackage
- root: /home/test/nested
-''');
- }
-}
-
class _AnalysisContextCollectionPrinter {
final _AnalysisContextCollectionPrinterConfiguration configuration;
final ResourceProvider resourceProvider;