Skip to content

Commit

Permalink
Require analyzer 2.7.0, use createMockSdk() (#3043)
Browse files Browse the repository at this point in the history
  • Loading branch information
scheglov authored Oct 25, 2021
1 parent 548cbd4 commit 04aa930
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
11 changes: 9 additions & 2 deletions lib/src/test_utilities/test_resource_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ DartLinter buildDriver(LintRule? rule, File file, {String? analysisOptions}) {
packageConfigPath = null;
}

var sdkRoot = memoryResourceProvider.getFolder(
memoryResourceProvider.convertPath('/sdk'),
);
createMockSdk(
resourceProvider: memoryResourceProvider,
root: sdkRoot,
);

var options = LinterOptions([rule!], analysisOptions)
..dartSdkPath = sdkRoot
..mockSdk = MockSdk(resourceProvider: memoryResourceProvider)
..dartSdkPath = sdkRoot.path
..resourceProvider = resourceProvider
..packageConfigPath = packageConfigPath;

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
analyzer: '>=2.5.0 <3.0.0'
analyzer: '>=2.7.0 <3.0.0'
args: ^2.0.0
collection: ^1.15.0
glob: ^2.0.0
Expand Down
10 changes: 5 additions & 5 deletions test/rule_test_support.dart
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,13 @@ abstract class _ContextResolutionTest with ResourceProviderMixin {

late ResolvedUnitResult result;

List<MockSdkLibrary> get additionalMockSdkLibraries => [];

List<String> get collectionIncludedPaths;

/// The analysis errors that were computed during analysis.
List<AnalysisError> get errors => result.errors;

Folder get sdkRoot => newFolder('/sdk');

String get testFilePath => '/test/lib/test.dart';

void addTestFile(String content) {
Expand Down Expand Up @@ -405,9 +405,9 @@ abstract class _ContextResolutionTest with ResourceProviderMixin {
_lintRulesAreRegistered = true;
}

MockSdk(
createMockSdk(
resourceProvider: resourceProvider,
additionalLibraries: additionalMockSdkLibraries,
root: sdkRoot,
);
}

Expand All @@ -430,7 +430,7 @@ abstract class _ContextResolutionTest with ResourceProviderMixin {
enableIndex: true,
includedPaths: collectionIncludedPaths.map(convertPath).toList(),
resourceProvider: resourceProvider,
sdkPath: convertPath('/sdk'),
sdkPath: sdkRoot.path,
);
}

Expand Down

0 comments on commit 04aa930

Please sign in to comment.