Skip to content

Commit f1a4d4b

Browse files
authored
[go_router_builder] Fixes text golden test to ignore platform specific newline (flutter#12652)
fixes flutter#191892 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent bd3cbc1 commit f1a4d4b

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎packages/go_router_builder/tool/run_tests.dart‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,23 @@ Future<void> main() async {
5353
try {
5454
generator.generateForAnnotation(reader, results, <String>{});
5555
} on InvalidGenerationSourceError catch (e) {
56-
expect(expectResult, e.message.trim());
56+
_expectWithNormalizedNewlines(e.message.trim(), expectResult);
5757
return;
5858
}
5959

6060
// Apply consistent formatting to both generated and expected code for comparison.
6161
final String generated = formatter.format(results.join('\n\n').trim());
62-
final String expected = formatter.format(expectResult.trim());
63-
expect(generated, equals(expected));
62+
final String expected = formatter.format(expectResult);
63+
_expectWithNormalizedNewlines(generated, expected);
6464
}, timeout: const Timeout(Duration(seconds: 100)));
6565
}
6666
}
6767

68+
/// Compares two strings after normalizing CRLF line endings to LF.
69+
void _expectWithNormalizedNewlines(String actual, String expected) {
70+
expect(actual.replaceAll('\r\n', '\n'), equals(expected.replaceAll('\r\n', '\n')));
71+
}
72+
6873
Future<Version> _packageVersion() async {
6974
final PackageConfig packageConfig = await loadPackageConfigUri(Isolate.packageConfigSync!);
7075
final Uri pkgUri = Platform.script.resolve('../pubspec.yaml');

0 commit comments

Comments
 (0)