Skip to content

fix(cli): make i18n locale-detection test deterministic on macOS (refs #6240)#6243

Merged
houko merged 2 commits into
mainfrom
fix/6240-macos-flaky-tests
Jun 20, 2026
Merged

fix(cli): make i18n locale-detection test deterministic on macOS (refs #6240)#6243
houko merged 2 commits into
mainfrom
fix/6240-macos-flaky-tests

Conversation

@houko

@houko houko commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Part of the main-red macOS failures tracked in #6240. macOS tests are SKIPPED on PRs and only run on main after merge, so these were never caught pre-merge.

crates/librefang-cli/src/i18n.rs::tests::test_detect_system_language failed deterministically on macOS: it sets LANGUAGE / LANG and asserts on detect_system_language(), but both detect_system_language and is_utf8_locale also read LC_ALL and LC_MESSAGES, with higher precedence than LANG. The macOS CI runner exports those to a UTF-8 locale, so is_utf8_locale() returned true off LC_ALL, the non-UTF-8 LANG=uk_UA.KOI8-U case fell through to LANGUAGE, and it returned "uk" instead of "en" (panic at i18n.rs:218). Linux passes because those vars are unset there.

Change

The test backs up + clears LC_ALL, LC_MESSAGES, and LANG up front so it controls every input the detection logic reads, then restores all three at the end. No production code changes.

Scope note — the other half of #6240 is NOT fixed here

The remaining macOS failures are librefang-hands::registry::tests::* (25 tests), which fail with:

fatal: unable to access 'https://github.com/librefang/librefang-registry.git/': Could not resolve host: github.com
... expected at least 15 hands, got 0

i.e. the macOS CI runner has no github.com egress, so resolve_home_dir_for_tests()sync_registry() (a git clone / HTTP download of the registry) fails and the registry is empty. Those tests are correct; the runner lacks network. That is a CI-infra / test-design decision (give the macOS runner egress, filter the network-dependent registry::tests on the macOS lane, or make those tests offline-tolerant) — intentionally left out of this PR rather than blind-editing 25 tests. Flagging for a maintainer call.

Verification

The failing platform (macOS) cannot be run locally, so this is verified by inspection: after the change the test sets exactly the locale vars each case needs and clears the rest, so the result no longer depends on the runner's ambient LC_*. The existing assertions are unchanged and continue to hold on the Linux/Windows lanes.

Refs #6240.

…#6240)

`test_detect_system_language` only controlled LANGUAGE and LANG, but `detect_system_language` and `is_utf8_locale` also read LC_ALL and LC_MESSAGES, which take precedence over LANG.
CI runners (notably the macOS lane) export LC_ALL / LC_MESSAGES to a UTF-8 locale, so `is_utf8_locale()` returned true off LC_ALL and the non-UTF-8 LANG case asserted "uk" instead of "en" — failing deterministically on macOS while passing on Linux where those vars are unset.

The test now backs up and clears LC_ALL, LC_MESSAGES and LANG up front so it fully controls every input the detection logic reads, and restores all of them at the end.
@github-actions github-actions Bot added the size/S 10-49 lines changed label Jun 20, 2026
@houko
houko merged commit 9e8882b into main Jun 20, 2026
31 checks passed
@houko
houko deleted the fix/6240-macos-flaky-tests branch June 20, 2026 01:19
houko added a commit that referenced this pull request Jun 20, 2026
…ane (#6240) (#6247)

* ci(macos): skip network-dependent hands registry tests on the macOS lane (#6240)

librefang-hands `registry::tests` clone github.com/librefang/librefang-registry at runtime to populate a test home, then assert >= 15 hands.
GitHub-hosted macOS runners resolve crates.io but consistently fail to resolve github.com for this clone ("Could not resolve host: github.com" -> "expected at least 15 hands, got 0"), failing 13 tests deterministically on macOS across every main push while they pass on Linux/Windows where the clone succeeds.

The logic under test is platform-independent and fully covered by the Linux + Windows lanes, so exclude just this network-dependent module on the macOS lane via a nextest filter rather than red-flagging every main push.
Completes the macOS-red fix begun in #6243 (the i18n half).

* style(ci): rewrap macos lane comments to one sentence per line

---------

Co-authored-by: Evan <[email protected]>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S 10-49 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants