Repository navigation
Fix culture-dependent test failures by setting en-US culture - #7580
Merged
Merged
Conversation
nkolev92
reviewed
Jul 21, 2026
gekka
marked this pull request as draft
July 25, 2026 05:02
gekka
marked this pull request as ready for review
July 25, 2026 12:51
gekka
marked this pull request as draft
July 26, 2026 02:07
gekka
marked this pull request as ready for review
July 26, 2026 02:08
nkolev92
previously approved these changes
Jul 28, 2026
Contributor
|
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 30 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
Nigusu-Allehu
approved these changes
Aug 24, 2026
Nigusu-Allehu
enabled auto-merge (squash)
August 24, 2026 16:48
zivkan
disabled auto-merge
August 25, 2026 23:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Fixes: Nuget/Home#15004
Description
This PR ensures that tests run under the
en-USculture by default.Many existing tests contain assertions that compare localized messages against English-language expected values. Running the test suite under a non-English culture can therefore cause unrelated test failures.
By setting the test culture to
en-US, test results become consistent across different environments and system locales.Note
This PR removes the
SkipSharedsetting fromNuGet.VisualStudio.Implementation.Test.csproj.I could not determine why
SkipSharedwas configured for this project. Other test projects in the solution do not use this setting, and removing it is necessary for the proposed culture configuration to be applied consistently.However, since I do not know the original reason for this project-specific setting, this change may be unintended.
PR Checklist
Update
I understand that
UseCultureAttributecan be applied to individual tests to address culture-related failures. However, the scale of the problem is much larger. On my machine, simply running:.\build.ps1 -RunUnitTestsresults in more than 440 test failures under a non-English culture.Since -RunUnitTests executes only the unit tests, I would expect the number of failures to be even higher when running the full test suite via: PowerShell1.\runTests.ps1
I cannot provide an exact number that running on CI because much of the full test suite is intended to run on dedicated CI machines and is not readily executable by external contributors.
While it is theoretically possible to fix these failures by adding UseCultureAttribute to each affected test, doing so would require a significant amount of work and would be difficult to maintain over time.
More importantly, the current situation demonstrates that relying on individual developers to remember to apply UseCultureAttribute is not a reliable solution. There are already many tests that contain culture-dependent assertions without the attribute, and it is likely that future tests will continue to be added without it.
The goal of this PR is to address the issue at the test framework level by providing a consistent culture for all test executions. This allows existing tests to pass without requiring hundreds of individual modifications and helps prevent similar issues from being introduced in the future.
Update 2
I found another issue with the suggestion of simply applying
UseCultureAttributeto the affected tests.For example:
NuGet.Client/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetListCommandTest.cs
Lines 51 to 78 in 069976e
This test invokes
nuget.exeand validates its output by comparing the resulting strings.Even if
UseCultureAttributeis applied to the test method, the attribute only affects the test process itself. The spawnednuget.exeprocess still runs using the operating system's culture settings. As a result, any localized messages produced bynuget.exemay differ from the English strings expected by the test.In other words, applying
UseCultureAttributeto the test method does not necessarily guarantee that child processes use the same culture. Tests that validate the output of external processes can still fail under non-English system cultures.