Skip to content

dotnet test net8.0 fails on Linux (newline/culture differences) #2375

@fuguiKz

Description

@fuguiKz

Repro

On Debian 12 (bookworm) with .NET SDK 10.0.101 (runtimes include Microsoft.NETCore.App 8.0.20) and LANG=en_US.UTF-8, running:

dotnet test tests/CsvHelper.Tests/CsvHelper.Tests.csproj -c Release -f net8.0

on master (33970e5183383bdac1fbce3b3fbcdf46b318ca52) consistently fails with 4 tests.

Failing tests

  1. CsvHelper.Tests.TypeConversion.TypeConverterFactoryTests.WriteTypeConverterGenericInt
  2. CsvHelper.Tests.TypeConversion.TypeConverterFactoryTests.WriteTypeConverterFactory
    • expected string contains \n, but actual output contains \r\n
  3. CsvHelper.Tests.Mappings.ConstructorParameter.CultureInfoAttributeTests.CsvConfiguration_FromType_InvalidAttribute_ThrowsCultureNotFoundException
    • CsvConfiguration.FromAttributes<InvalidAttribute>() does not throw on this environment (seems CultureInfo.GetCultureInfo("invalid") resolves instead of throwing)
  4. CsvHelper.Tests.Writing.MultipleFieldsFromOnePropertyTests.WriteMultipleFieldsFromSinglePropertyTest
    • expected 12:00:00 AM (normal space), but actual contains a narrow no-break space before AM (12:00:00\u202FAM)

Notes / hypotheses

  • The newline failures look like the test expected is built from a raw string literal whose line endings depend on checkout, while CsvWriter seems to default to CRLF. Maybe build expected via csv.Configuration.NewLine / cw.Configuration.NewLine instead (like other tests).
  • The DateTime formatting difference looks like ICU vs Windows NLS culture-data differences for en-US; building expected from DateTime.ToString(culture) or normalizing whitespace could make it platform-neutral.
  • The invalid-culture test may need to account for ICU behavior (or use a different invalid culture name that fails consistently).

Happy to open a PR if you'd like any of these adjusted; wanted to check first whether Linux net8.0 test runs are expected to pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions