[test_runner] Fix expectations on Windows when there are import loops.

The checking for loops did not normalize the first entry, causing the
expectation to be read twice in case of a loop, and the test to fail.

Simplify a little by checking when adding to the "already seen" set.

R=brianwilkerson@google.com

Change-Id: I1862f98051fc5e4f867fdf0d9b1b0884b99610ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353681
Reviewed-by: William Hesse <whesse@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
Commit-Queue: William Hesse <whesse@google.com>
This commit is contained in:
David Morgan 2024-02-23 12:10:18 +00:00 committed by Commit Queue
parent 449d73697c
commit dd828b4be5

View file

@ -325,8 +325,10 @@ class TestFile extends _TestFileBase {
// Missing files set no expectations.
if (!file.existsSync()) return [];
// Catch import loops.
if (!alreadyParsed.add(Uri.parse(path).toString())) return [];
// Parse one file.
alreadyParsed.add(path);
var contents = File(path).readAsStringSync();
var result = StaticError.parseExpectations(path: path, source: contents);
@ -337,7 +339,6 @@ class TestFile extends _TestFileBase {
// Broken import paths set no expectations.
if (localPath == null) continue;
var uriString = Uri.parse(path).resolve(localPath.path).toString();
if (alreadyParsed.contains(uriString)) continue;
result
.addAll(_parseExpectations(uriString, alreadyParsed: alreadyParsed));
}