Skip to content

Commit 4a4bb55

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Make "ID" tests insensitive to what directory they're run from.
Previously, they needed to be run from the root of the SDK repo, which made testing under IntelliJ a pain, since by default IntelliJ runs executables from the root of the local package. Change-Id: I89d9bbbca38307016fcea4717010c19b9720b463 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154285 Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Joshua Litt <joshualitt@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
1 parent 2a11b9b commit 4a4bb55

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pkg/_fe_analyzer_shared/lib/src/testing/id_testing.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,20 @@ typedef Future<Map<String, TestResult<T>>> RunTestFunction<T>(TestData testData,
643643
Map<String, List<String>> skipMap,
644644
Uri nullUri});
645645

646+
/// Compute the file: URI of the file located at `path`, where `path` is
647+
/// relative to the root of the SDK repository.
648+
///
649+
/// We find the root of the SDK repository by looking for the parent of the
650+
/// directory named `pkg`.
651+
Uri _fileUriFromSdkRoot(String path) {
652+
Uri uri = Platform.script;
653+
List<String> pathSegments = uri.pathSegments;
654+
return uri.replace(pathSegments: [
655+
...pathSegments.sublist(0, pathSegments.lastIndexOf('pkg')),
656+
...path.split('/')
657+
]);
658+
}
659+
646660
class MarkerOptions {
647661
final Map<String, Uri> markers;
648662

@@ -669,7 +683,7 @@ class MarkerOptions {
669683
}
670684
String marker = line.substring(0, eqPos);
671685
String tester = line.substring(eqPos + 1);
672-
File testerFile = new File(tester);
686+
File testerFile = new File.fromUri(_fileUriFromSdkRoot(tester));
673687
if (!testerFile.existsSync()) {
674688
throw new ArgumentError(
675689
"Tester '$tester' does not exist for marker '$marker' in "

0 commit comments

Comments
 (0)