Skip to content

Commit ed77f14

Browse files
authored
Run test on Linux and Mac (#45642)
* Run test on Linux and Mac * Use `ReplaceLineEndings` * Always use lf * Different approach * Revert * Doc
1 parent cbb4916 commit ed77f14

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Framework/AspNetCoreAnalyzers/test/Http/HeaderDictionaryAddTest.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,25 @@ public static IEnumerable<object[]> FixedWithAppendAddsUsingDirectiveTestData()
147147
};
148148
}
149149

150-
[ConditionalTheory]
151-
[OSSkipCondition(OperatingSystems.Linux)]
152-
[OSSkipCondition(OperatingSystems.MacOSX)]
150+
[Theory]
153151
[MemberData(nameof(FixedWithAppendAddsUsingDirectiveTestData))]
154152
public async Task IHeaderDictionary_WithAdd_FixedWithAppend_AddsUsingDirective(string source, string fixedSource)
155153
{
154+
// Source is cloned on Windows with CRLF line endings, then the test is run by Helix in Windows/Linux/macOS.
155+
// When Roslyn adds a new `using`, it gets added followed by Environment.NewLine.
156+
// For Linux/macOS, the actual result is `\n`, however, the source is cloned on Windows with CRLF expectation.
157+
// We replace all line endings with Environment.NewLine to avoid this.
158+
156159
// Arrange & Act & Assert
157160
await VerifyCS.VerifyCodeFixAsync(
158-
source.TrimStart(),
161+
source.TrimStart().ReplaceLineEndings(),
159162
new[]
160163
{
161164
new DiagnosticResult(DiagnosticDescriptors.DoNotUseIHeaderDictionaryAdd)
162165
.WithLocation(0)
163166
.WithMessage(Resources.Analyzer_HeaderDictionaryAdd_Message)
164167
},
165-
fixedSource.TrimStart(),
168+
fixedSource.TrimStart().ReplaceLineEndings(),
166169
codeActionEquivalenceKey: AppendCodeActionEquivalenceKey);
167170
}
168171

0 commit comments

Comments
 (0)