34 lines
1.4 KiB
Markdown
34 lines
1.4 KiB
Markdown
# PR#144: Tests in One Locale
|
|
|
|
> **WARNING:** This document describes only the change applied in this PR.
|
|
> It may already be outdated once the next PR is merged.
|
|
> Historic PR-documentation is not maintained along with new PRs — treat it as a snapshot, not as current documentation.
|
|
|
|
## The Problem
|
|
|
|
The tests ran in whatever locale the host had, and so did the processes they start, bash and git among them.
|
|
On a host with a German `LC_NUMERIC`, bash writes `EPOCHREALTIME` as `1791625756,465101`; `$((…))` reads the comma as its comma operator.
|
|
That made a test of PR#143 fail locally, while it would have passed on another host.
|
|
|
|
## Non-Goals
|
|
|
|
- No change to the locale of Werkator itself or of the builds it runs.
|
|
|
|
## The Scenarios
|
|
|
|
#### Scenario#144.01: Tests run in the US English locale
|
|
|
|
- **Given** a host with another locale, e.g. a German `LC_NUMERIC`
|
|
- **When** a test runs, under Gradle or under PIT
|
|
- **Then** the test and the processes it starts use `en_US.UTF-8`
|
|
- **So that** a test that formats or parses numbers, dates or messages behaves the same on every host.
|
|
|
|
##### Verified by
|
|
|
|
- [TestLocaleIntegrationTest](../../src/test/kotlin/de/hoennig/werkator/framework/TestLocaleIntegrationTest.kt)
|
|
|
|
## The Solution
|
|
|
|
- Every `Test` task sets `LANG` and `LC_ALL` to `en_US.UTF-8`, and `user.language` and `user.country` to `en` and `US`.
|
|
- The `pitest` task sets the same environment for its main process; PIT's test processes inherit it.
|