glaterza opened a new pull request, #45247:
URL: https://github.com/apache/superset/pull/45247
### SUMMARY
Fixes #45245.
#44395 added two tests that run the real msgcat step of
`scripts/translations/babel_update.sh`. They never run on CI, and one of them
fails on any machine that has gettext.
- **They skip on CI.** Python-Unit does not install gettext, so
`shutil.which("msgcat")` is `None` and both tests skip. The JUnit report of the
Python-Unit run on master at `7aadf35e7d` lists both as skipped
(https://github.com/apache/superset/actions/runs/38381761342).
- **One fails where gettext exists.** The test runs the script with a
restricted `PATH` (`/usr/bin:/bin` plus stubs). The script calls `python` on
line 77. macOS, Ubuntu 26.04 and Debian 13 have no `/usr/bin/python`. The
trailing-line test fails with `line 77: python: command not found`.
- **The failing-msgcat test passed for the wrong reason.** With the msgcat
`|| exit 1` removed, the script still stopped before `pybabel update`. It
stopped one line later, at the missing `python`.
This PR changes three things:
1. Both end-to-end tests put `python` and `python3` shims on the restricted
`PATH`. Each shim runs the interpreter that runs pytest. A shared
`_stage_script` helper replaces the setup that two tests repeated.
2. Python-Unit and Python-Nightly-Canary install gettext. The step copies
the one in `superset-translations.yml`, with the same pinned action. Like that
step, it leaves `execute_install_scripts` off. The gettext package needs no
post-install script.
3. The two tests call `_require_msgcat()`. It skips when msgcat is missing.
It fails instead when `SUPERSET_GETTEXT_STRICT` is set. Both workflows set that
variable at job level.
Item 3 follows the `SUPERSET_TESTCONTAINERS_STRICT` pattern from #43502
(`tests/testcontainers/db_engine_specs/_driver.py`). I did not key it on `CI`.
GitHub, GitLab, CircleCI and Buildkite all set `CI`, so a pipeline outside this
repository without gettext would get two new failures. As with
`SUPERSET_TESTCONTAINERS_STRICT`, any non-empty value turns strict mode on.
`babel_update.sh` itself does not change.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Local runs at `256e6cb7f1`, on master `139a06eee1`.
Before (master's test file, macOS with Homebrew gettext):
```
FAILED
babel_update_test.py::test_the_trailing_line_strip_keeps_the_last_entry_intact
babel_update.sh: line 77: python: command not found
1 failed, 5 passed
```
After (this branch):
```
6 passed
```
The same runs in Docker, with only `python3`, `python3-pytest` and `gettext`
from apt:
| Image | `/usr/bin/python` | Master's test file | This branch |
|---|---|---|---|
| `ubuntu:26.04` (the CI runner's release) | none | 1 failed, 5 passed | 6
passed |
| `ubuntu:26.04` with `python-is-python3` | present | not run | 6 passed |
| `debian:13` | none | 1 failed, 5 passed | 6 passed |
Each test fails when the behavior it guards breaks. Each test stays green on
a harmless change:
| Change to a copy of `babel_update.sh` or to the test | Test | Master |
This branch |
|---|---|---|---|
| Remove `\|\| exit 1` after msgcat | failing-msgcat test | passes | fails |
| Change it to `\|\| exit 2` | failing-msgcat test | passes | passes |
| Remove the `python` shims (macOS) | trailing-line test | n/a | fails |
| Change the script's `python` call to `python3` | trailing-line test |
passes | passes |
Without msgcat on `PATH`:
```
SUPERSET_GETTEXT_STRICT=true: 2 failed ("SUPERSET_GETTEXT_STRICT is set,
but gettext's msgcat is not on PATH: install gettext in this job"), 4 passed
CI=true only: 2 skipped ("gettext's msgcat is not installed
on this machine"), 4 passed
nothing set: 2 skipped, 4 passed
```
Python-Nightly-Canary on my fork, with Python 3.13.15, on the first commit
of this branch. The gettext step has not changed since.
```
Install gettext tools 14:45:57 → 14:46:04 (7 s)
tests/unit_tests/scripts/translations/babel_update_test.py ...... [
73%]
tests/unit_tests/websocket/test_channel.py .............
[100%]
##[error]The operation was canceled.
```
All six tests passed, and none skipped. The job then hit its 45-minute
timeout, 3 seconds after the last test. The canary on master has the same
timeout problem, which #45246 describes.
### TESTING INSTRUCTIONS
1. Install gettext (`brew install gettext` or `apt-get install gettext`).
2. Run `pytest tests/unit_tests/scripts/translations/babel_update_test.py`.
Expect 6 passed. On master, expect the trailing-line test to fail with `python:
command not found`.
3. Remove gettext from `PATH` and run the same command with
`SUPERSET_GETTEXT_STRICT=true`. Expect 2 failed. Without the variable, expect 2
skipped.
4. In this PR's Python-Unit run, open the `junit-results-current` artifact.
It lists both msgcat tests as passed, not skipped.
All 136 tests in `tests/unit_tests/scripts/translations/` pass locally with
gettext and `SUPERSET_GETTEXT_STRICT=true`, also with Python-Unit's `-n auto
--dist loadfile`. No other test in `tests/` depends on gettext.
`check_translation_regression_test.py` mocks its `msgfmt` call.
The superset-pr-kit checks skipped three items: toolchain and frontend (no
frontend files changed), and catalogs (the translation template did not change).
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #45245
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]