Skip to content

Commit a047d02

Browse files
committed
Improve cross-platform line ending normalization
- Apply line ending normalization to all regex patterns in MarkdownFormatterTests - Ensures consistent behavior for headers, tables, code blocks, and HTML tags - More comprehensive fix for Windows CI pipeline compatibility
1 parent 736edaf commit a047d02

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/DotNetApiDiff.Tests/Reporting/MarkdownFormatterTests.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,22 +250,24 @@ public void Format_OutputIsValidMarkdown()
250250
var markdown = formatter.Format(result);
251251

252252
// Assert
253+
// Normalize line endings for cross-platform compatibility
254+
var normalizedMarkdown = markdown.Replace("\r\n", "\n").Replace("\r", "\n");
255+
253256
// Check for valid markdown structure
254257
// Headers should start with #
255-
Assert.Matches(new Regex(@"^# .*$", RegexOptions.Multiline), markdown);
256-
Assert.Matches(new Regex(@"^## .*$", RegexOptions.Multiline), markdown);
258+
Assert.Matches(new Regex(@"^# .*$", RegexOptions.Multiline), normalizedMarkdown);
259+
Assert.Matches(new Regex(@"^## .*$", RegexOptions.Multiline), normalizedMarkdown);
257260

258-
// Tables should have header row and separator row (normalize line endings for cross-platform compatibility)
259-
var normalizedMarkdown = markdown.Replace("\r\n", "\n").Replace("\r", "\n");
261+
// Tables should have header row and separator row
260262
Assert.Matches(new Regex(@"^\| .* \|$", RegexOptions.Multiline), normalizedMarkdown);
261263
Assert.Matches(new Regex(@"^\|\-+\|\-+\|", RegexOptions.Multiline), normalizedMarkdown);
262264

263265
// Code blocks should be properly formatted
264-
Assert.Matches(new Regex(@"```csharp\s.*\s```", RegexOptions.Singleline), markdown);
266+
Assert.Matches(new Regex(@"```csharp\s.*\s```", RegexOptions.Singleline), normalizedMarkdown);
265267

266268
// Details tags should be properly closed
267-
var detailsOpenCount = Regex.Matches(markdown, @"<details>").Count;
268-
var detailsCloseCount = Regex.Matches(markdown, @"</details>").Count;
269+
var detailsOpenCount = Regex.Matches(normalizedMarkdown, @"<details>").Count;
270+
var detailsCloseCount = Regex.Matches(normalizedMarkdown, @"</details>").Count;
269271
Assert.Equal(detailsOpenCount, detailsCloseCount);
270272
}
271273
}

0 commit comments

Comments
 (0)