From c739cbfd7b0cebb14be43d34d1b8bd99cd5bb5f1 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Sun, 4 Jun 2023 19:18:51 +0000 Subject: [PATCH] [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 Commit-Queue: Brian Wilkerson --- pkg/analysis_server/test/test_all.dart | 4 ++-- pkg/analyzer_utilities/lib/tools.dart | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/analysis_server/test/test_all.dart b/pkg/analysis_server/test/test_all.dart index 155d6142d13..418e9f26af9 100644 --- a/pkg/analysis_server/test/test_all.dart +++ b/pkg/analysis_server/test/test_all.dart @@ -68,7 +68,7 @@ void main() { @reflectiveTest class SpecTest { - void test_specHasBeenGenerated() { - check_spec.main(); + void test_specHasBeenGenerated() async { + await check_spec.main(); } } diff --git a/pkg/analyzer_utilities/lib/tools.dart b/pkg/analyzer_utilities/lib/tools.dart index 6499a3c7c5b..613e60dca51 100644 --- a/pkg/analyzer_utilities/lib/tools.dart +++ b/pkg/analyzer_utilities/lib/tools.dart @@ -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