Skip to content

Modify misc tests to use Invariant culture instead of current culture #15449

Closed

Description

@steveharter

Also see issue dotnet/corefx#3759 for background

Some tests assume en-us or invariant and on a test machine which is not configured the tests will fail. These tests should not depend on a specific default locale.

Below is a set of tests that fail when LANG variable is not set in Linux. These should be fixed to explicitly use Invariant.

Note that some of these tests fail due to unrelated but known issue with case-insensitive string comparison that happens to fail with the default locale of en-US-POSIX (when LANG is not set) so these tests may have to be disabled temporary for Linux until that issue is fixed

Int32Tests.TestTryParse
UInt32Tests.TestTryParse
UInt16Tests.TestTryParse
UInt64Tests.TestTryParse
StringTests.TestLastIndexOf
StringTests.TestEndsWith
StringTests.TestStartsWith
StringTests.TestIndexOf
Int16Tests.TestTryParse
Int64Tests.TestTryParse
TypeTests.TestGetTypeByName
Tests.Expression_Tests.TestCallInstanceMethodsByName
CaseInsensitiveComparer_ctor.ExecuteCaseInsensitiveComparer_ctor
CaseInsensitiveComparer_Default.ExecuteCaseInsensitiveComparer_Default
CaseInsensitiveComparer_Object.ExecuteCaseInsensitiveComparer_Object
CollectionsUtilTests.ExecuteCollectionsUtilTests
System.Reflection.Tests.ModuleTest.GetTypeTest
System.Reflection.Tests.MethodInfoPropertyTests.TestReturnType2
System.Reflection.Tests.MethodInfoPropertyTests.TestReturnType4
System.Reflection.Tests.GetTypeReflectionTests.GetType1
System.Reflection.Tests.ParameterInfoNameTests.TestMethodParams1

Activity

  1. self-assigned this
    on Oct 14, 2015
  2. karelz commented on Nov 8, 2016

    @karelz
    Member

    Should be simple change of tests to set culture to InvariantCulture first.

  3. Vertygo commented on Apr 5, 2017

    @Vertygo

    Can I take this one?

  4. karelz commented on Apr 6, 2017

    @karelz
    Member

    Sure, assigned to you @Vertygo

  5. karelz commented on Apr 6, 2017

    @karelz
    Member

    If you're in trouble @krwq and @tarekgh should be able to help ...

  6. krwq commented on Apr 11, 2017

    @krwq
    Member

    Hi @Vertygo, what's the status? Are you still working on it?

  7. krwq commented on Apr 11, 2017

    @krwq
    Member

    @Vertygo it's ok if you haven't started yet, I'm just wondering if I can pick this up since it is the last System.Globalization 2.0.0 bug 😉

  8. assigned and unassigned on Apr 12, 2017
  9. krwq commented on Apr 12, 2017

    @krwq
    Member

    @steveharter this does not repro for me on bash for windows or Ubuntu
    Is there some special setup I need for this?

    Here is what I did:

    echo $LANG
      => en_US.UTF-8
    LANG=
    echo $LANG
      => (nothing)
    msbuild.sh src/System.Globalization/tests/System.Globalization.Tests.csproj /t:RebuildAndTest
      => `(...) System.Globalization.Tests  Total: 1647, Errors: 0, Failed: 0, Skipped: 0, Time: 7.295s`
    

    also tried setting LANG=en-US-POSIX - also no repro
    running locale after changing LANG (that sets other environment variables) - no repro

    I also made sure tests are not disabled - doesn't seem to be related

    git grep 3850
       => no results
    
    git grep ActiveIssue
      =>
        DateTimeFormatInfo/DateTimeFormatInfoGetAbbreviatedDayName.cs:            // ActiveIssue(2103)
        DateTimeFormatInfo/DateTimeFormatInfoGetAbbreviatedMonthName.cs:            // ActiveIssue(2103)
        DateTimeFormatInfo/DateTimeFormatInfoGetDayName.cs:            // ActiveIssue(2103)
        DateTimeFormatInfo/DateTimeFormatInfoGetMonthName.cs:            // ActiveIssue(2103)
    
    git grep Skip
       =>
        CultureInfo/CultureInfoAsync.cs: [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
        CultureInfo/CultureInfoAsync.cs: [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
        Invariant/Invariant.Tests.csproj:    <SkipXunitRuntimeConfigCopying>true</SkipXunitRuntimeConfigCopying>
        TextInfo/TextInfoTests.cs: [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Desktop Framework hasn't received the fix for dotnet/corefx#16770 yet.")]
        TextInfo/TextInfoToLower.cs: [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
        TextInfo/TextInfoToLower.cs: [SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp | TargetFrameworkMonikers.Uap)]
        TextInfo/TextInfoToUpper.cs: [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
        TextInfo/TextInfoToUpper.cs: [SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp | TargetFrameworkMonikers.Uap)]
    
  10. krwq commented on Apr 12, 2017

    @krwq
    Member

    I think those tests might not be in the System.Globalization... looking now
    EDIT:
    can't find anything pointing to this issue anywhere in corefx
    I have searched few tests mentioned in the first post (first 3 and last 3) and can't seem to find those tests either

    I'm closing this as no repro - please reopen if I've missed something. Possibly they already got fixed.

  11. tarekgh commented on Apr 12, 2017

    @tarekgh
    Member

    @krwq we had changed the globalization test much since this issue is opened. if you don't see any problem when changing the default language on the system before running the tests then we are ok here.

  12. krwq commented on Apr 12, 2017

    @krwq
    Member

    Thanks @tarekgh for confirming 😉

  13. transferred this issue fromdotnet/corefxon Jan 31, 2020
  14. added this to the 2.0.0 milestone on Jan 31, 2020
  15. ghost locked as resolved and limited conversation to collaborators on Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.Globalizationgood first issueIssue should be easy to implement, good for first-time contributorshelp wanted[up-for-grabs] Good issue for external contributorstest-bugProblem in test source code (most likely)

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions