From a4ba58451091b02f980654f26c934a63b58d44d4 Mon Sep 17 00:00:00 2001 From: Ahmed Ashour Date: Fri, 7 Oct 2022 15:05:43 +0000 Subject: [PATCH] [analyzer] enable `VerifyDiagnosticsTest` on Windows Fixes #50155 Change-Id: I48fcf7adbdd822f8640a9c2650c61392f9227d5a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263121 Commit-Queue: Brian Wilkerson Reviewed-by: Brian Wilkerson --- .../test/verify_diagnostics_test.dart | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pkg/analyzer/test/verify_diagnostics_test.dart b/pkg/analyzer/test/verify_diagnostics_test.dart index 1e6507b49a3..324d76bb630 100644 --- a/pkg/analyzer/test/verify_diagnostics_test.dart +++ b/pkg/analyzer/test/verify_diagnostics_test.dart @@ -4,7 +4,6 @@ import 'package:analyzer/error/error.dart'; import 'package:analyzer/file_system/physical_file_system.dart'; -import 'package:path/path.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; @@ -327,7 +326,6 @@ class DocumentationValidator { class VerifyDiagnosticsTest { @TestTimeout(Timeout.factor(4)) test_diagnostics() async { - Context pathContext = PhysicalResourceProvider.INSTANCE.pathContext; // // Validate that the input to the generator is correct. // @@ -336,20 +334,21 @@ class VerifyDiagnosticsTest { // // Validate that the generator has been run. // - if (pathContext.style != Style.windows) { - String actualContent = PhysicalResourceProvider.INSTANCE - .getFile(computeOutputPath()) - .readAsStringSync(); + String actualContent = PhysicalResourceProvider.INSTANCE + .getFile(computeOutputPath()) + .readAsStringSync(); + // Normalize Windows line endings to Unix line endings so that the + // comparison doesn't fail on Windows. + actualContent = actualContent.replaceAll('\r\n', '\n'); - StringBuffer sink = StringBuffer(); - DocumentationGenerator generator = DocumentationGenerator(); - generator.writeDocumentation(sink); - String expectedContent = sink.toString(); + StringBuffer sink = StringBuffer(); + DocumentationGenerator generator = DocumentationGenerator(); + generator.writeDocumentation(sink); + String expectedContent = sink.toString(); - if (actualContent != expectedContent) { - fail('The diagnostic documentation needs to be regenerated.\n' - 'Please run tool/diagnostics/generate.dart.'); - } + if (actualContent != expectedContent) { + fail('The diagnostic documentation needs to be regenerated.\n' + 'Please run tool/diagnostics/generate.dart.'); } }