Skip to content

Promote develop to main: Make the Test Suite Pass on Windows - #2528

Merged
ptr727 merged 3 commits into
mainfrom
develop
Oct 8, 2026
Merged

ptr727 merged 3 commits into
mainfrom
develop

Conversation

@ptr727

@ptr727 ptr727 commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Summary

Promotes three changes from develop, which together make python3 -m unittest discover -s tests pass on a Windows host from Git Bash.

  • Absorb a Windows Closed Pipe and Remove Read-Only Staged Objects in local_review #2521: two Windows defects in scripts/local_review.py, and the tests that exercise them.
    • A write to a closed pipe raises OSError with EINVAL on Windows rather than BrokenPipeError, so status | head -0 exited 120 outside the 0/1/2 contract. closed_reader now recognizes both forms.
    • worktree_states left its throwaway object directory behind on Windows, holding the staged content of every untracked file, because rmtree(ignore_errors=True) could not unlink git's read-only loose objects. An onexc handler now clears the read-only bit and retries.
  • Write spec/validate.py Output as UTF-8, and Fix Four Windows-Shaped Test Assertions #2523: spec/validate.py writes its output as UTF-8 on every host, and a cp1252 regression case pins that on Linux CI too. Four Windows-shaped test assertions take the host's path, quoting, and flag forms. test_release_guards runs its guard script from a file, since Git Bash's parse of a Windows command line halves each doubled backslash inside a quoted -c argument, and host_capability.bash_path records that.
  • Make the jq Carriage-Return Test Fail When Its Stub Is Not Reached #2524: the jq carriage-return test's fixture now says cataloged, so the test fails when its stub is not reached.

Closes #2488.
Closes #2513.

Verification

🤖 Generated with Claude Code

ptr727 and others added 3 commits October 7, 2026 20:58
…ocal_review (#2521)

## Summary

Clears the `test_local_review` cluster of #2488, 15 of its Windows
failures, two of them real defects in `scripts/local_review.py` rather
than in the tests.

- **A closed pipe on Windows.** A write to a pipe whose reader has
exited raises `OSError` with `errno` `EINVAL` there, not
`BrokenPipeError`. `emit` and `main` caught only the subclass, so the
interpreter's shutdown flush exited 120, outside the 0/1/2 contract. A
new `closed_reader` recognizes both forms, and `main`'s backstop now
catches `OSError`, sending any other one to the same boundary report as
before through a small `crashed` helper.
- **A leaked object directory on Windows.** `worktree_states` removed
its throwaway object directory with `ignore_errors=True`. Windows
refuses to unlink git's read-only loose objects, so the directory,
holding the staged content of every untracked file, outlived each read
inside the git directory. The removal now clears the read-only bit and
retries through an `onexc` handler.
- **Tests.** The `coderabbit` stand-in gets a `.cmd` wrapper on Windows,
since Windows runs no shebang and `shutil.which` there finds only a
`PATHEXT` name. The dangling-ref case makes git's read-only loose object
writable before unlinking it. The piped case runs under the suite's own
interpreter rather than a bare `python3`.

Part of #2488. The remaining failures there sit in `test_spec_validate`,
`test_host_gate`, `test_docker_lint`, and `test_release_guards`, and are
left to a separate pull request.

## Verification

- On the Windows host from Git Bash, `python3 -m unittest discover -s
tests -p test_local_review.py` went from 7 failures and 8 errors to `OK
(skipped=6)`, every skip an existing host-capability one.
- The two `ReceiptCase` piped tests and
`test_staging_leaves_no_throwaway_paths_behind` still fail against the
unchanged `local_review.py`, so the script change rather than the test
change is what fixes them.
- The full suite on this host now reports 7 failures and 2 errors, all
in the four modules named above.
- `ruff format --check`, `ruff check`, and `mypy` pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Local reviews now handle closed output streams more reliably and
report unexpected I/O errors instead of silently ignoring them.
* Temporary review files are cleaned up more reliably on Windows,
including when files are read-only.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…2524)

## Summary


`ArchivedRepositoryCase.test_a_trailing_carriage_return_from_jq_is_stripped`
stubbed `jq` to print `archived` followed by a carriage return, while
its registry fixture also said `archived`. Any real `jq` on PATH gave
the same verdict, so the test passed whether or not the stub ran. The
fixture now says `cataloged`, so only the stub can stop the script at
the archived exemption.

Part of the Windows lane. The promotion pull request closes #2513.

## Verification

- With the change, the module passes on the Windows host from Git Bash
and, run by the local review pass, under Linux with a real `jq`.
- With the stub's `PATH` line removed, the test fails on both, since a
real `jq` now answers `cataloged` and the script falls through to
`REACHED_NEXT`.
- With `configure.sh`'s carriage-return strip removed, the test fails
under Linux, which is what CI runs. Under Git Bash the strip makes no
difference to the outcome, since Git Bash's command substitution already
drops a trailing carriage return before the newline, so a Windows run
cannot speak for the strip either way.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…est Assertions (#2523)

## Summary

Clears the rest of #2488, the 9 Windows failures left once #2521 cleared
the `test_local_review` cluster. With both changes, `python3 -m unittest
discover -s tests` passes on the Windows host from Git Bash.

- **`spec/validate.py` writes UTF-8.** On Windows a piped stdout uses
the ANSI code page, so the validator crashed reporting a registry name
that code page cannot encode, a zero-width space for one, and wrote
others, such as `ß`, in a form the suite's UTF-8 decode rejected. It now
reconfigures both streams to UTF-8 at the top of `main`, through the
same `utf8_console` helper `scripts/pr_review.py` already carries. On
Linux the streams were already UTF-8, so CI output is unchanged.
- **`test_release_guards` runs its guard script from a file.** The
handoff read this failure as jq 1.8.2 rejecting `\S`, and that diagnosis
is wrong: winget's jq 1.8.2 compiles the filter and gives every expected
verdict when it receives it intact. The script went through `bash -c`,
and Git Bash's own parse of the Windows command line collapses each
doubled backslash inside a quoted argument, so the filter arrived
holding an invalid escape and every value was refused. The test now
writes the script to a temporary file and runs that, and
`host_capability.bash_path`'s docstring records the trap for the next
test.
- **`test_host_gate`** asserted POSIX forms where Windows prints a
backslash path, the PowerShell call operator, and `-Repo`. Each
assertion now takes the host's form, and on Linux each expected string
is still byte-identical to the literal it replaces.
- **`test_docker_lint`** expected a forward-slash mount source from a
native Windows `Path`. The expectation takes the separator from the
host, and the doubled-quote escaping it pins is unchanged.

Part of #2488, which the promotion pull request closes.

## Verification

- On the Windows host from Git Bash, `test_spec_validate`,
`test_host_gate`, `test_docker_lint`, and `test_release_guards` each
pass, and the python-versions guard case runs rather than skips.
- The full suite on this branch failed only in `test_local_review`,
which #2521 fixes and which has since merged into `develop`.
- `ruff format --check`, `ruff check`, and `mypy` pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 8, 2026 13:34
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1567810e-7541-443e-9870-c751117bbf25
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.25806% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.40%. Comparing base (8bdfa25) to head (5c5d890).
⚠️ Report is 327 commits behind head on main.

Files with missing lines Patch % Lines
scripts/local_review.py 36.00% 16 Missing ⚠️
spec/validate.py 16.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2528      +/-   ##
==========================================
- Coverage   58.50%   58.40%   -0.10%     
==========================================
  Files          16       16              
  Lines        8066     8090      +24     
==========================================
+ Hits         4719     4725       +6     
- Misses       3347     3365      +18     
Flag Coverage Δ
python-3.13 58.40% <32.25%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Re-raise unexpected non-pipe output errors in scripts/local_review.py.

1 open finding
What changed in this PR

Promotes Windows compatibility fixes and regression tests so the full unittest suite passes under Git Bash.

Changes:

  • Handles Windows pipe errors and read-only cleanup.
  • Forces validator output to UTF-8.
  • Strengthens platform-specific shell, path, and fixture tests.

Review found that scripts/local_review.py can silently discard unexpected output errors; non-pipe errors should be re-raised.

File Description
tests/​test_spec_validate.py Adds UTF-8 regression coverage.
tests/​test_release_guards.py Runs guard scripts from temporary files.
tests/​test_local_review.py Updates Windows-compatible test helpers.
tests/​test_host_gate.py Uses platform-specific command forms.
tests/​test_docker_lint.py Uses host-specific path separators.
tests/​test_configure_archived.py Ensures the jq stub is exercised.
tests/​host_capability.py Documents Git Bash behavior.
spec/​validate.py Configures validator output as UTF-8.
scripts/​local_review.py Handles Windows pipe errors and read-only cleanup.

🧠 Review effort: Lite


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread scripts/local_review.py
@ptr727
ptr727 merged commit 9eda5a1 into main Oct 8, 2026
13 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.

Make the jq Carriage-Return Test Fail When Its Stub Is Not Reached Make the Test Suite Pass or Skip Cleanly on Windows

2 participants