[analysis_server] Fix generation tests on Windows

The check normalises newlines from "actualContents", but "expectedContents" could also contain \r\n on Windows (at least it does for me), so this just normalises both.

The additional await/async is to prevent "Test failed after it already completed" warnings because this code is inside the call to test() (and not wrapping it, like the other .main() calls in the file).

Change-Id: Iac034efaf1a8a6dad4a21dc67a2dfdb74092dd22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307301
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Danny Tuppeny 2023-06-04 19:18:51 +00:00 committed by Commit Queue
parent f984411eac
commit c739cbfd7b
2 changed files with 4 additions and 3 deletions

View file

@ -68,7 +68,7 @@ void main() {
@reflectiveTest
class SpecTest {
void test_specHasBeenGenerated() {
check_spec.main();
void test_specHasBeenGenerated() async {
await check_spec.main();
}
}

View file

@ -285,7 +285,7 @@ abstract class GeneratedContent {
var executable = Platform.executable;
var generateScript = normalize(joinAll(posix.split(generatorPath)));
print(' $executable $generateScript ${args.join(" ")}');
fail('Error codes need to be generated');
fail('Generated content needs to be regenerated');
}
}
@ -409,6 +409,7 @@ class GeneratedFile extends GeneratedContent {
// Normalize Windows line endings to Unix line endings so that the
// comparison doesn't fail on Windows.
actualContents = actualContents.replaceAll('\r\n', '\n');
expectedContents = expectedContents.replaceAll('\r\n', '\n');
return expectedContents == actualContents;
} catch (e) {
// There was a problem reading the file (most likely because it didn't