Skip to content

test: force C locale for printf in cellAreaM2 CLI test - #1176

Merged
isaacbrodsky merged 1 commit into
uber:masterfrom
gords2:fix-cli-cellarea-locale
Jun 25, 2026
Merged

isaacbrodsky merged 1 commit into
uber:masterfrom
gords2:fix-cli-cellarea-locale

Conversation

@gords2

@gords2 gords2 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #1170.

testCliCellAreaM2 runs:

test "`h3 cellAreaM2 -c 85283473fffffff | xargs printf '%.3f'`" = '265092558.128'

printf's %f conversion uses the system locale's decimal separator. On a locale such as en_SE.UTF-8 (which uses ,), the pipeline produces 265092558,128, so the comparison against the expected 265092558.128 fails — which blocks the build (e.g. the Arch AUR package, as reported).

h3 itself outputs the value correctly (265092558.1282817721); only the test's printf post-processing is locale-sensitive.

Fix: run printf under the C locale so the decimal separator is always .:

-"cellAreaM2 -c 85283473fffffff | xargs printf '%.3f'"
+"cellAreaM2 -c 85283473fffffff | xargs env LC_ALL=C printf '%.3f'"

env LC_ALL=C is used (rather than a bare LC_ALL=C printf) because printf is launched by xargs, which doesn't interpret VAR=value env assignments. This is the only CLI test fixture that uses printf, so no other tests are affected.

The testCliCellAreaM2 test pipes h3 output through 'xargs printf %.3f',
which formats the decimal separator per the system locale. On locales that
use ',' as the decimal separator the test produces 265092558,128 and fails,
even though h3 itself outputs the value correctly. Run printf under
LC_ALL=C so the separator is always '.'.

Fixes uber#1170
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 99.176%. remained the same — gords2:fix-cli-cellarea-locale into uber:master

@isaacbrodsky
isaacbrodsky merged commit 5e2ddc9 into uber:master Jun 25, 2026
47 checks passed
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.

Test testCliCellAreaM2_test143 fails due to locale

4 participants