Add an analyzer_testing package
We intend to publish and maintain this as a set of testing-related utilities for the analyzer packages and for analyzer plugins. Work towards https://github.com/dart-lang/sdk/issues/55660 See the doc: https://docs.google.com/document/d/1jRtd8B1ijPAP6Pz89HRnyIZXw2VMjaZx0vRZTpoNO84/edit?tab=t.0#heading=h.2sz41a544qhi Change-Id: I2764b1357a932fa955060b26d78038997eaa9536 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425080 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com> Reviewed-by: Paul Berry <paulberry@google.com>
This commit is contained in:
committed by
Commit Queue
parent
c9d54c12f6
commit
4ef2725654
@@ -11,7 +11,7 @@ import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart';
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:analyzer_utilities/package_root.dart';
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
|
||||
import '../benchmarks.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
@@ -37,6 +37,7 @@ dependencies:
|
||||
|
||||
# Use 'any' constraints here; we get our versions from the DEPS file.
|
||||
dev_dependencies:
|
||||
analyzer_testing: any
|
||||
analyzer_utilities: any
|
||||
cli_util: any
|
||||
lints: any
|
||||
|
||||
@@ -9,7 +9,7 @@ library;
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:analyzer_utilities/package_root.dart';
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:analyzer/dart/ast/visitor.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:analyzer/src/dart/analysis/experiments.dart';
|
||||
import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
|
||||
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:analyzer_utilities/test/mock_packages/mock_packages.dart';
|
||||
|
||||
/// A mixin adding functionality to write `.dart_tool/package_config.json`
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'dart:collection';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
|
||||
import 'package:analyzer_utilities/package_root.dart';
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// TODO(scheglov): Remove it after SDK 3.1 published.
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/dart/analysis/session.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart';
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
/// The purpose of this test is to validate that all elements
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:analyzer_utilities/verify_tests.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart';
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
|
||||
class BulkFixDetails {
|
||||
Future<Map<String, CorrectionDetails>> collectOverrides() async {
|
||||
|
||||
@@ -24,7 +24,7 @@ import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
|
||||
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
|
||||
import 'package:analyzer/src/utilities/extensions/flutter.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:analyzer_utilities/tools.dart';
|
||||
import 'package:args/args.dart';
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/ast/visitor.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart';
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:analyzer_utilities/package_root.dart';
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
import 'package:analyzer_utilities/tools.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:analysis_server_plugin/src/correction/fix_generators.dart';
|
||||
import 'package:analyzer/error/error.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer/src/lint/registry.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:linter/src/rules.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ dependencies:
|
||||
# best practice for packages is to specify their compatible version ranges.
|
||||
# See also https://dart.dev/tools/pub/dependencies.
|
||||
dev_dependencies:
|
||||
analyzer_testing: any
|
||||
analyzer_utilities: any
|
||||
args: any
|
||||
async: any
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'dart:io' as io;
|
||||
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/ast/visitor.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/file_system/overlay_file_system.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer/src/error/codes.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
main() async {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:analyzer_utilities/verify_tests.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ import 'package:analyzer/dart/element/nullability_suffix.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer/src/utilities/extensions/element.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_utilities/package_root.dart';
|
||||
import 'package:analyzer_testing/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
import 'package:analyzer_utilities/tools.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
@@ -15,7 +15,7 @@ import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
|
||||
import 'package:analyzer/src/dart/analysis/byte_store.dart';
|
||||
import 'package:analyzer/src/dart/analysis/file_content_cache.dart';
|
||||
import 'package:analyzer/src/dart/analysis/unlinked_unit_store.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart';
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
import 'package:args/args.dart';
|
||||
import 'package:heap_snapshot/analysis.dart';
|
||||
import 'package:heap_snapshot/format.dart';
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:_fe_analyzer_shared/src/scanner/characters.dart'
|
||||
show $MINUS, $_;
|
||||
import 'package:analyzer_utilities/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_utilities/tools.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:yaml/yaml.dart' show YamlMap, loadYaml;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:analyzer_utilities/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as pkg_root;
|
||||
import 'package:path/path.dart';
|
||||
import 'package:yaml/yaml.dart' show loadYaml;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import 'package:analyzer/error/error.dart';
|
||||
import 'package:analyzer/src/dart/ast/token.dart';
|
||||
import 'package:analyzer/src/dart/error/todo_codes.dart';
|
||||
import 'package:analyzer/src/generated/parser.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as pkg_root;
|
||||
import 'package:path/path.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_utilities/tools.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:path/path.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.
|
||||
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:analyzer_utilities/tools.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:analyzer_utilities/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_utilities/tools.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
@@ -21,6 +21,7 @@ dependencies:
|
||||
# best practice for packages is to specify their compatible version ranges.
|
||||
# See also https://dart.dev/tools/pub/dependencies.
|
||||
dev_dependencies:
|
||||
analyzer_testing: any
|
||||
analyzer_utilities: any
|
||||
lints: any
|
||||
linter: any
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:analyzer_utilities/verify_tests.dart';
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
file:/tools/OWNERS_DEVELOPER_EXPERIENCE
|
||||
file:/tools/OWNERS_MODEL
|
||||
+12
-12
@@ -4,34 +4,34 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as pathos;
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
/// Returns a path to the directory containing source code for packages such as
|
||||
/// kernel, front_end, and analyzer.
|
||||
String get packageRoot {
|
||||
// If the package root directory is specified on the command line using
|
||||
// -DpkgRoot=..., use it.
|
||||
// `-DpkgRoot=...`, use that.
|
||||
const pkgRootVar =
|
||||
bool.hasEnvironment('pkgRoot') ? String.fromEnvironment('pkgRoot') : null;
|
||||
if (pkgRootVar != null) {
|
||||
var path = pathos.join(Directory.current.path, pkgRootVar);
|
||||
if (!path.endsWith(pathos.separator)) path += pathos.separator;
|
||||
return path;
|
||||
var pkgRootPath = path.join(Directory.current.path, pkgRootVar);
|
||||
if (!pkgRootPath.endsWith(path.separator)) pkgRootPath += path.separator;
|
||||
return pkgRootPath;
|
||||
}
|
||||
// Otherwise try to guess based on the script path.
|
||||
var scriptPath = pathos.fromUri(Platform.script);
|
||||
var scriptPath = path.fromUri(Platform.script);
|
||||
var pathFromScript = _tryGetPkgRoot(scriptPath);
|
||||
if (pathFromScript != null) {
|
||||
return pathFromScript;
|
||||
}
|
||||
|
||||
// Try google3 environment. We expect that all packages that will be
|
||||
// Try a Bazel environment. We expect that all packages that will be
|
||||
// accessed via this root are configured in the BUILD file, and located
|
||||
// inside this single root.
|
||||
var runFiles = Platform.environment['TEST_SRCDIR'];
|
||||
var analyzerPackagesRoot = Platform.environment['ANALYZER_PACKAGES_ROOT'];
|
||||
if (runFiles != null && analyzerPackagesRoot != null) {
|
||||
return pathos.join(runFiles, analyzerPackagesRoot);
|
||||
return path.join(runFiles, analyzerPackagesRoot);
|
||||
}
|
||||
|
||||
// Finally, try the current working directory.
|
||||
@@ -43,12 +43,12 @@ String get packageRoot {
|
||||
throw StateError('Unable to find sdk/pkg/ in $scriptPath');
|
||||
}
|
||||
|
||||
/// Try to find the path to the pkg folder from [path].
|
||||
String? _tryGetPkgRoot(String path) {
|
||||
var parts = pathos.split(path);
|
||||
/// Tries to find the path to the 'pkg' folder from [searchPath].
|
||||
String? _tryGetPkgRoot(String searchPath) {
|
||||
var parts = path.split(searchPath);
|
||||
var pkgIndex = parts.indexOf('pkg');
|
||||
if (pkgIndex != -1) {
|
||||
return pathos.joinAll(parts.sublist(0, pkgIndex + 1)) + pathos.separator;
|
||||
return path.joinAll(parts.sublist(0, pkgIndex + 1)) + path.separator;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -4,3 +4,13 @@ environment:
|
||||
sdk: ^3.7.0
|
||||
|
||||
resolution: workspace
|
||||
|
||||
dependencies:
|
||||
path: ^1.9.0
|
||||
|
||||
# We use 'any' version constraints here as we get our package versions from
|
||||
# the dart-lang/sdk repo's DEPS file. Note that this is a special case; the
|
||||
# best practice for packages is to specify their compatible version ranges.
|
||||
# See also https://dart.dev/tools/pub/dependencies.
|
||||
dev_dependencies:
|
||||
lints: any
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:analyzer_testing/package_root.dart' as package_root;
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
void _cacheFiles(Map<String, String> cachedFiles) {
|
||||
|
||||
@@ -9,6 +9,7 @@ resolution: workspace
|
||||
|
||||
# Use 'any' constraints here; we get our versions from the DEPS file.
|
||||
dependencies:
|
||||
analyzer_testing: any
|
||||
analyzer: any
|
||||
dart_style: any
|
||||
package_config: any
|
||||
|
||||
Reference in New Issue
Block a user