Skip to content

Fixes #194. Some tests fail due to different cultures.#195

Merged
BDisp merged 7 commits into
gui-cs:developfrom
BDisp:issue/194_fix-tests-culture
May 21, 2026
Merged

Fixes #194. Some tests fail due to different cultures.#195
BDisp merged 7 commits into
gui-cs:developfrom
BDisp:issue/194_fix-tests-culture

Conversation

@BDisp
Copy link
Copy Markdown
Collaborator

@BDisp BDisp commented May 20, 2026

Fixes #194

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@tig
Copy link
Copy Markdown
Member

tig commented May 20, 2026

Concern: Process-global state mutation in parallel tests

CultureInfo.DefaultThreadCurrentCulture is process-wide. Setting it in each test class constructor races with parallel tests in the same assembly"

Suggested fix: Replace all three constructors with a single <InvariantGlobalization>true</InvariantGlobalization> in the integration test .csproj:

<PropertyGroup>
  <InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

This:

  • Applies invariant culture at the runtime level (no race)
  • Eliminates per-class boilerplate
  • Automatically covers new test classes
  • Doesn't mutate shared state from test code

If invariant globalization is too broad (e.g., some tests intentionally verify locale behavior), an alternative is a shared xUnit IAssemblyFixture that sets culture once at assembly startup.

@BDisp
Copy link
Copy Markdown
Collaborator Author

BDisp commented May 21, 2026

If I run 'dotnet jb cleanupcode Terminal.Gui.Editor.slnx --profile="TG.Editor Full Cleanup"' locally and commit the result will result in 55 files changed besides getting a build errors because of the lack of "#nullable" and related warnings. This is a normal behavior? I don't know what to do because it touches other files than what I really changed.

@tig
Copy link
Copy Markdown
Member

tig commented May 21, 2026

You should only use clean up on files you touched. The files forked from AvaloniaEdit should not be modified.

Copy link
Copy Markdown
Member

@tig tig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the updated implementation (AssemblyFixture + pt-PT regression tests).

The approach is sound:

  • \InvariantCultureAssemblyFixture\ via [assembly: AssemblyFixture]\ sets the default culture once per test run — much better than per-class constructors.
  • The pt-PT tests correctly use thread-local \CultureInfo.CurrentCulture\ overrides with save/restore in \ inally, which takes precedence over the assembly-level default.
  • All 60 integration tests pass.

One minor note: my earlier suggestion of <InvariantGlobalization>true\ would break the pt-PT tests (the runtime disallows non-invariant \CultureInfo\ instantiation), so the \AssemblyFixture\ pattern is the right call here.

LGTM ✅

@BDisp
Copy link
Copy Markdown
Collaborator Author

BDisp commented May 21, 2026

I noticed that the echo is showing incomplete command and the complete command is:

          dotnet jb cleanupcode Terminal.Gui.Editor.slnx \
            --profile="TG.Editor Full Cleanup" \
            --no-build \
            --exclude="third_party/**/*;src/Terminal.Gui.Editor/Document/**/*;src/Terminal.Gui.Editor/Utils/**/*;src/Terminal.Gui.Editor/Search/**/*" \
            || true
          if ! git diff --exit-code; then
            echo "::error::ReSharper code cleanup found style drift. Run 'dotnet jb cleanupcode Terminal.Gui.Editor.slnx --profile=\"TG.Editor Full Cleanup\"' locally and commit the result."
            exit 1
          fi

@BDisp BDisp merged commit f0868c9 into gui-cs:develop May 21, 2026
4 checks passed
@BDisp BDisp deleted the issue/194_fix-tests-culture branch May 21, 2026 13:56
@tig
Copy link
Copy Markdown
Member

tig commented May 21, 2026

Thanks. See #200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some tests fail due to different cultures.

2 participants