diff --git a/tools/analyzer_plugin/pubspec.yaml b/tools/analyzer_plugin/pubspec.yaml index 52a6219733..e3cccda7b3 100644 --- a/tools/analyzer_plugin/pubspec.yaml +++ b/tools/analyzer_plugin/pubspec.yaml @@ -30,10 +30,10 @@ dev_dependencies: io: ^1.0.0 logging: ^1.0.1 markdown: ^4.0.0 - package_config: ^2.0.0 pub_semver: ^2.0.0 test: ^1.14.0 test_reflective_loader: ^0.2.0 + uuid: '>3.0.0 <4.0.0' workiva_analysis_options: ^1.1.0 dependency_validator: diff --git a/tools/analyzer_plugin/test/integration/test_bases/analysis_driver_test_base.dart b/tools/analyzer_plugin/test/integration/test_bases/analysis_driver_test_base.dart index b58886060d..977addc49a 100644 --- a/tools/analyzer_plugin/test/integration/test_bases/analysis_driver_test_base.dart +++ b/tools/analyzer_plugin/test/integration/test_bases/analysis_driver_test_base.dart @@ -35,9 +35,7 @@ abstract class AnalysisDriverTestBase { if (path != null && p.isAbsolute(path)) { throw ArgumentError.value(path, 'path', 'must be a relative path'); } - final fileContext = sharedContext.fileContextForTest(contents, filename: path, - // TODO could we enable this in some cases? - includeTestDescription: false); + final fileContext = sharedContext.fileContextForTest(contents, filename: path); return resourceProvider.getFile(fileContext.path).createSource(); } diff --git a/tools/analyzer_plugin/test/util/shared_analysis_context.dart b/tools/analyzer_plugin/test/util/shared_analysis_context.dart index 28756cdfc8..390fdead1e 100644 --- a/tools/analyzer_plugin/test/util/shared_analysis_context.dart +++ b/tools/analyzer_plugin/test/util/shared_analysis_context.dart @@ -29,11 +29,6 @@ import 'package:io/io.dart'; import 'package:path/path.dart' as p; import 'package:source_span/source_span.dart'; -// This isn't strictly required for anything, so if the import becomes invalid, -// just comment it and related code out. -import 'package:test_api/src/backend/invoker.dart' show Invoker; -import 'package:uuid/uuid.dart'; - import 'package_util.dart'; import 'util.dart'; @@ -193,13 +188,11 @@ class SharedAnalysisContext { Future resolvedFileContextForTest( String sourceText, { String? filename, - bool includeTestDescription = true, bool preResolveLibrary = true, bool throwOnAnalysisErrors = true, IsExpectedError? isExpectedError, }) async { - final fileContext = - fileContextForTest(sourceText, filename: filename, includeTestDescription: includeTestDescription); + final fileContext = fileContextForTest(sourceText, filename: filename); final context = collection.contexts.singleWhere((c) => c.contextRoot.root.path == contextRootPath); @@ -223,24 +216,8 @@ class SharedAnalysisContext { return fileContext; } - FileContext fileContextForTest( - String sourceText, { - String? filename, - bool includeTestDescription = true, - }) { + FileContext fileContextForTest(String sourceText, {String? filename}) { filename ??= nextFilename(); - - if (includeTestDescription) { - // For convenience, include the current test description in the file as - // a comment, so that: - // - you can tell you're looking at the right file for a given test - // - you can search for the test description to easily find the right file - try { - final testName = Invoker.current!.liveTest.test.name; - sourceText = lineComment('Created within test with name:\n> $testName') + '\n' + sourceText; - } catch (_) {} - } - final path = p.join(contextRootPath, _testFileSubpath, filename); final file = File(path); if (file.existsSync()) {