Skip to content

Commit

Permalink
Version 3.4.0-209.0.dev
Browse files Browse the repository at this point in the history
Merge 170e014 into dev
  • Loading branch information
Dart CI committed Mar 7, 2024
2 parents 3538739 + 170e014 commit bf028d0
Show file tree
Hide file tree
Showing 4 changed files with 301 additions and 21 deletions.
25 changes: 13 additions & 12 deletions pkg/analyzer/lib/src/dart/analysis/context_locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class ContextLocatorImpl implements ContextLocator {
root.optionsFileMap[rootFolder] = optionsFile;
}

root.excludedGlobs = _getExcludedGlobs(root);
root.excludedGlobs = _getExcludedGlobs(optionsFile, workspace);
roots.add(root);
return root;
}
Expand Down Expand Up @@ -315,6 +315,10 @@ class ContextLocatorImpl implements ContextLocator {
if (localOptionsFile != null) {
(containingRoot as ContextRootImpl).optionsFileMap[folder] =
localOptionsFile;
// Add excluded globs.
var excludes =
_getExcludedGlobs(localOptionsFile, containingRoot.workspace);
containingRoot.excludedGlobs.addAll(excludes);
}

//
Expand Down Expand Up @@ -343,7 +347,7 @@ class ContextLocatorImpl implements ContextLocator {
containingRoot.excluded.add(folder);
roots.add(root);
containingRoot = root;
excludedGlobs = _getExcludedGlobs(root);
excludedGlobs = _getExcludedGlobs(root.optionsFile, workspace);
root.excludedGlobs = excludedGlobs;
}
_createContextRootsIn(roots, visited, folder, excludedFolders,
Expand Down Expand Up @@ -481,19 +485,16 @@ class ContextLocatorImpl implements ContextLocator {
return null;
}

/// Return a list containing the glob patterns used to exclude files from the
/// given context [root]. The patterns are extracted from the analysis options
/// file associated with the context root. The list will be empty if there are
/// no exclusion patterns in the options file, or if there is no options file
/// associated with the context root.
List<LocatedGlob> _getExcludedGlobs(ContextRootImpl root) {
/// Return a list containing the glob patterns used to exclude files from
/// analysis by the given [optionsFile]. The list will be empty if there is no
/// options file or if there are no exclusion patterns in the options file.
List<LocatedGlob> _getExcludedGlobs(File? optionsFile, Workspace workspace) {
List<LocatedGlob> patterns = [];
File? optionsFile = root.optionsFile;
if (optionsFile != null) {
try {
var doc = AnalysisOptionsProvider(
root.workspace.createSourceFactory(null, null))
.getOptionsFromFile(optionsFile);
var doc =
AnalysisOptionsProvider(workspace.createSourceFactory(null, null))
.getOptionsFromFile(optionsFile);

var analyzerOptions = doc.valueAt(AnalyzerOptions.analyzer);
if (analyzerOptions is YamlMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,110 @@ workspaces
''');
}

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/b.dart
uri: package:test/nested/b.dart
analysisOptions_1
workspacePackage_0_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
''');
}

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/b.dart
uri: package:test/nested/b.dart
analysisOptions_1
workspacePackage_0_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
''');
}

test_packageConfigWorkspace_multipleAnalysisOptions_overridingOptions() async {
final workspaceRootPath = '/home';
final testPackageRootPath = '$workspaceRootPath/test';
Expand Down Expand Up @@ -717,6 +821,49 @@ workspaces
''');
}

test_packageConfigWorkspace_singleAnalysisOptions_exclude() 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:
- lib/nested/**
''');

newFile('$testPackageLibPath/a.dart', '');
final nestedPath = '$testPackageLibPath/nested';
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
analysisOptions
analysisOptions_0: /home/test/analysis_options.yaml
workspaces
workspace_0: PackageConfigWorkspace
root: /home/test
pubPackages
workspacePackage_0_0: PubPackage
root: /home/test
''');
}

test_packageConfigWorkspace_singleAnalysisOptions_multipleContexts() async {
final workspaceRootPath = '/home';
final testPackageRootPath = '$workspaceRootPath/test';
Expand Down Expand Up @@ -897,6 +1044,130 @@ workspaces
''');
}

@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_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';
Expand Down
24 changes: 16 additions & 8 deletions sdk_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ declare_args() {
# into a VM which was built with a different SDK.
verify_sdk_hash = true

# When verify_sdk_hash is true, this string is used as the verification hash
# instead of calculating one from the contents of the tree using the
# make_version.py script.
dart_sdk_verification_hash = ""

# The location in the build output directory of the built Dart SDK.
dart_sdk_output = "dart-sdk"
}
Expand All @@ -41,14 +46,17 @@ if (default_git_folder == "") {
# The SDK hash to build into VM and kernels.
# The value 0000000000 signifies no hash is set, which will disable the check.
if (verify_sdk_hash) {
sdk_hash = exec_script("$_dart_root/tools/make_version.py",
[ "--format={{GIT_HASH}}" ],
"trim string",
[
"$_dart_root/tools/VERSION",
"$_dart_root/tools/utils.py",
"$default_git_folder/logs/HEAD",
])
sdk_hash = dart_sdk_verification_hash
if (sdk_hash == "") {
sdk_hash = exec_script("$_dart_root/tools/make_version.py",
[ "--format={{GIT_HASH}}" ],
"trim string",
[
"$_dart_root/tools/VERSION",
"$_dart_root/tools/utils.py",
"$default_git_folder/logs/HEAD",
])
}
} else {
sdk_hash = "0000000000"
}
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 3
MINOR 4
PATCH 0
PRERELEASE 208
PRERELEASE 209
PRERELEASE_PATCH 0

0 comments on commit bf028d0

Please sign in to comment.