Skip to content

Commit

Permalink
Fix dependency_validator issues
Browse files Browse the repository at this point in the history
  • Loading branch information
greglittlefield-wf committed Sep 7, 2023
1 parent 2d80fd4 commit 25ab621
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
2 changes: 1 addition & 1 deletion tools/analyzer_plugin/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
27 changes: 2 additions & 25 deletions tools/analyzer_plugin/test/util/shared_analysis_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -193,13 +188,11 @@ class SharedAnalysisContext {
Future<FileContext> 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);

Expand All @@ -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()) {
Expand Down

0 comments on commit 25ab621

Please sign in to comment.