Skip to content

Make Whitaker fallback tests hermetic (#53)#54

Open
lodyai[bot] wants to merge 1 commit into
mainfrom
issue-53-test-lint-targets-whitaker-fallback-cases-fail-on-a-clean-main-checkout
Open

Make Whitaker fallback tests hermetic (#53)#54
lodyai[bot] wants to merge 1 commit into
mainfrom
issue-53-test-lint-targets-whitaker-fallback-cases-fail-on-a-clean-main-checkout

Conversation

@lodyai

@lodyai lodyai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

This branch makes the generated-project Whitaker fallback tests hermetic by stripping inherited WHITAKER, MAKEFLAGS, MFLAGS, and MAKELEVEL values before invoking make lint. It preserves the template Makefile behaviour and keeps the fallback cases focused on the intended PATH, $HOME/.local/bin, and missing-tool branches.

Closes #53.

Review walkthrough

Validation

  • WHITAKER=true uvx --with pytest-copier --with pyyaml --with syrupy --with make-parser --with hypothesis pytest -vv tests/test_template/test_lint_targets.py::test_makefile_resolves_whitaker_fallback: 3 passed.
  • uvx --with pytest-copier --with pyyaml --with syrupy --with make-parser --with hypothesis pytest tests/: 50 passed, 1 skipped.
  • coderabbit review --agent: first pass reported one docstring concern, which was fixed.
  • coderabbit review --agent: second pass completed with 0 findings.

Notes

No template or snapshot changes were needed because the failure was caused by inherited environment state in the test subprocess, not by the generated Makefile fallback chain.

References

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @LodyAI[bot], you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Changes

Subprocess environment isolation

Layer / File(s) Summary
Build hermetic project environments
tests/helpers/subprocess_env.py
Define the resolution-variable set and construct subprocess environments by copying os.environ, removing those variables, and applying overrides.
Apply the helper to fallback testing
tests/test_template/test_lint_targets.py
Use the shared environment helper for Whitaker fallback subprocesses and include captured output in failure diagnostics.

Suggested labels: Issue

Poem

Variables vanish,
Whitaker finds its path,
Tests speak when they fail,
Clean environments bloom.


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Testing (Overall) ❌ Error The fallback test can pass for the wrong Whitaker binary because it does not assert the resolved path and still exposes /usr/bin:/bin. Assert stdout contains the expected Whitaker binary: ... line and use an isolated PATH for the home/missing cases so a host Whitaker cannot satisfy them.
Developer Documentation ⚠️ Warning No docs changed: the PR only touches tests, and searches found no developer-guide/design/ADR entry for the new subprocess_env helper or env-sanitising policy. Update docs/developers-guide.md (and any relevant design/ADR/execplan entry) to describe the new test helper and the hermetic subprocess environment contract.
✅ Passed checks (18 passed)
Check name Status Explanation
Title check ✅ Passed Match the title to the hermetic Whitaker fallback test change and include the issue reference.
Description check ✅ Passed Keep the description aligned with the Whitaker fallback test hermeticity change.
Linked Issues check ✅ Passed Satisfy #53 by isolating subprocess environment state and exercising the intended Whitaker fallback branches.
Out of Scope Changes check ✅ Passed Keep the changes focused on the test helper and lint-target test updates, with no unrelated edits.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
User-Facing Documentation ✅ Passed No user-facing feature changed; the PR only adjusts test helpers and lint tests, and the users’ guide already documents the generated make lint target.
Module-Level Documentation ✅ Passed PASS: Both touched modules have top-level docstrings; the new helper explains hermetic subprocess envs and the test module documents rendered lint target tests.
Testing (Unit And Behavioural) ✅ Passed Treat the rendered project’s make lint subprocess as the boundary and cover path, home, and missing-tool branches.
Testing (Property / Proof) ✅ Passed No new range invariant or proof obligation appears; the helper is a fixed environment filter, and the updated integration test already exercises the behaviour directly.
Testing (Compile-Time / Ui) ✅ Passed PASS: The PR only hardens test subprocess environments; it adds no Rust/TS compile-time surface or UI/text output that would call for trybuild or new snapshots.
Unit Architecture ✅ Passed generated_project_env is a small boundary helper that only copies and filters env state; the subprocess command and its side-effects stay explicit in the test.
Domain Architecture ✅ Passed PASS: The diff only touches test helpers and generated-project lint tests; no domain code or business rules were changed, so domain boundaries are unaffected.
Observability ✅ Passed Treat this as not applicable: the PR only changes test helper code and test assertions, with no production observability surface altered.
Security And Privacy ✅ Passed No secrets, auth gaps, unsafe injection, or over-broad permissions were introduced; the helper only strips make control vars and the new diagnostics expose only test subprocess output.
Performance And Resource Use ✅ Passed Only a single os.environ.copy(), four fixed pops, and one dict update were added in test code; no new unbounded loops, retries, or repeated I/O appear.
Concurrency And State ✅ Passed The change confines environment edits to a copied subprocess mapping and introduces no shared mutable state, locks, or async work.
Architectural Complexity And Maintainability ✅ Passed The change adds one small, explicit test helper in the existing tests/helpers package and uses it once; it removes duplication without adding indirection or hidden lifecycle.
Rust Compiler Lint Integrity ✅ Passed No Rust sources changed; the PR only updates Python test helpers and diagnostics, so no lint suppressions or suspicious clones were introduced.
📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #53

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-53-test-lint-targets-whitaker-fallback-cases-fail-on-a-clean-main-checkout

Comment @coderabbitai help to get the list of available commands.

Strip inherited make and Whitaker resolution variables from generated-project
lint subprocesses so the fallback cases exercise the intended PATH, HOME, and
missing-tool branches regardless of the parent test environment.

Include captured stdout and stderr in fallback assertions so future resolution
failures report the selected Whitaker command directly.
@leynos
leynos force-pushed the issue-53-test-lint-targets-whitaker-fallback-cases-fail-on-a-clean-main-checkout branch from 7584444 to b062f30 Compare July 17, 2026 18:01
@leynos
leynos marked this pull request as ready for review July 17, 2026 18:01

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b062f30234

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +8 to +14
MAKE_RESOLUTION_VARIABLES = frozenset(
{
"WHITAKER",
"MAKEFLAGS",
"MFLAGS",
"MAKELEVEL",
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Strip GNUMAKEFLAGS from generated make env

GNU make also reads GNUMAKEFLAGS: the manual says it is parsed just before MAKEFLAGS in the same way (https://www.gnu.org/software/make/manual/html_node/Options_002fRecursion.html). Because this helper copies it through, a parent shell with GNUMAKEFLAGS=WHITAKER=/path/to/fake or an equivalent --eval assignment still overrides the generated Makefile before the WHITAKER ?= fallback, so the whitaker_location == "missing" case can run that binary and pass instead of exercising the missing-tool branch. Please strip GNUMAKEFLAGS alongside the other make-control variables.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot added the Issue label Jul 17, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_template/test_lint_targets.py`:
- Around line 96-103: Update the test assertions around the generated lint
target execution to verify that result.stdout contains “Whitaker binary:
{expected_whitaker}” for cases where WHITAKER is present, using the resolved
expected path or home-directory value. Keep the existing return-code and marker
assertions, but ensure the test distinguishes the intended WHITAKER resolution
from the bare whitaker fallback.
- Around line 71-75: Update the PATH setup in the test targeting logic to use an
isolated temporary tool directory for the home and missing cases instead of
/usr/bin:/bin, while retaining path_bin for the path case. Ensure any required
test utilities are available in that sandbox or rely on shell built-ins so
host-installed whitaker cannot affect the intended branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 18c89b8e-1163-42a7-862e-ee029f3b1fe8

📥 Commits

Reviewing files that changed from the base of the PR and between c35f20a and b062f30.

📒 Files selected for processing (2)
  • tests/helpers/subprocess_env.py
  • tests/test_template/test_lint_targets.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/whitaker (auto-detected)

Comment on lines +71 to +75
"PATH": os.pathsep.join(
[str(path_bin), "/usr/bin", "/bin"]
if whitaker_location == "path"
else ["/usr/bin", "/bin"]
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Remove host tool directories from the fallback PATH.

Use an isolated temporary tool directory for the home and missing cases instead of /usr/bin:/bin. The generated Makefile checks command -v whitaker first, so a host-installed binary can win and prevent the test from exercising the intended branch. Provide required test utilities inside the sandbox or use shell built-ins.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_template/test_lint_targets.py` around lines 71 - 75, Update the
PATH setup in the test targeting logic to use an isolated temporary tool
directory for the home and missing cases instead of /usr/bin:/bin, while
retaining path_bin for the path case. Ensure any required test utilities are
available in that sandbox or rely on shell built-ins so host-installed whitaker
cannot affect the intended branch.

Comment on lines +96 to +103
assert result.returncode == 0, (
f"stdout:\n{result.stdout}\n"
f"stderr:\n{result.stderr}"
)
assert marker.exists(), (
f"expected generated lint target to execute {whitaker_location} Whitaker"
f"expected generated lint target to execute {whitaker_location} Whitaker\n"
f"stdout:\n{result.stdout}\n"
f"stderr:\n{result.stderr}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the resolved WHITAKER value.

Assert that stdout contains Whitaker binary: {expected_whitaker} for present cases. The recipe prepends $(USER_BIN_PATH) to PATH, so merely checking the marker can pass even when Make selected the bare whitaker fallback rather than the intended path or home-directory resolution.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_template/test_lint_targets.py` around lines 96 - 103, Update the
test assertions around the generated lint target execution to verify that
result.stdout contains “Whitaker binary: {expected_whitaker}” for cases where
WHITAKER is present, using the resolved expected path or home-directory value.
Keep the existing return-code and marker assertions, but ensure the test
distinguishes the intended WHITAKER resolution from the bare whitaker fallback.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_lint_targets whitaker-fallback cases fail on a clean main checkout

0 participants