Skip to content

tests/test_update_shape_landing.py: the gh its landing tests drive update-shape.py with is a Python stub the update's child starts through a sitecustomize hook rather than a #!/bin/sh file on PATH, so the eight tests that carried WINDOWS_SKIP run on Windows too and the --pr landing and re-run paths (#204) are run by all three CI jobs, not two (#334) - #336

Merged
brettheap merged 1 commit into
mainfrom
fix/landing-tests-windows
Oct 12, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-3 (openRepoShape-3)
Claim: #334 (comment)

What

tests/test_update_shape_landing.py only; no script changes.

  • The gh the landing tests drive update-shape.py with is now a Python program (GH_STUB) instead of a #!/bin/sh file on PATH. It logs its argv (bytes, one line per call, each argument ended by a unit separator, so the same log on every OS), answers pr list from the state directory, makes pr create exit 97 with the same HTTP 422 line while create-fails exists, and exits 64 on anything else: what the shell stub did.
  • A sitecustomize.py (GH_ON_PATH) is put first on the update's child PYTHONPATH. It does what PATH resolution did on POSIX: a subprocess.Popen whose program is named gh is started as python <the stub> <the same arguments>. The stub is a real process; its exit code and its two streams cross real pipes, and its arguments cross the OS's own command-line quoting. shape_materialize.run still builds the CommandFailed from it, so the refusal and the NEXT line still name gh. git is untouched; with no GH_STUB in the environment the module does nothing.
  • The eight @WINDOWS_SKIP marks (nine test items; MERGED/CLOSED is one function) come off, and the WINDOWS_SKIP and stat imports with them. Each was skipped for the stub, as the file's docstring said; none names a second reason, and git, the refusing commit hook and the NEXT-line quoting they also exercise are done by tests in this file that were already running on Windows.
  • The gh fixture's interface is unchanged (env, calls, failing, answer, forget); env carries PYTHONPATH, GH_STUB, GH_LOG, GH_STATE in place of a PATH entry.
  • Two docstrings that called the in-process tests "the Windows job's coverage" are corrected; their bodies are unchanged. One docstring's parenthesis about the stub on Windows is dropped.

Why not a gh.cmd (the suggestion in the task). subprocess.run(["gh", ...]) on Windows is CreateProcess, which appends .exe to a program name that has no extension (its documented rule); gh.cmd is not what gh names. Worse, as I understand the hosted Windows images they ship a real gh.exe further down PATH, so a .cmd beside the old script would be bypassed and the real one would answer. I could not run Windows here, so that is from documentation and memory of the images, not measured; it is why the hook rewrites the program instead of relying on PATH. The issue's own direction (more in-process tests) was kept for the two that exist and not extended, because the flush-order test needs real streams in one pipe.

Why

Measured on this host (Linux), with -p no:cacheprovider, tests/test_update_shape_landing.py:

main 71b58a1 this head
as is 33 passed 33 passed
WINDOWS_SKIP's condition forced true in a scratch conftest.py (what Windows CI decides) 24 passed, 9 skipped 33 passed, 0 skipped
hook made inert, no gh anywhere on PATH (scratch copy) n/a 7 of the 9 stub-driven items fail (gh.calls() is [], or the run exits 2 with "gh could not be started")
a gh that exits 99 and writes a marker FIRST on PATH, hook on n/a 33 passed, the marker was never written

The last row is the property the Windows job needs: a real gh on PATH is never reached. The 7 failing items are the ones whose assertions read what gh was asked or answered; test_the_commit_and_the_push_print_above_the_refusal_in_one_log and test_a_rerun_from_another_branch_is_still_nothing_to_do pass without a working stub because a missing gh and a failing one both exit 2 and neither asserts a call; they are written that way.

No assert line and no test name moves: git diff -U0 | grep -E '^[-+]\s*(assert|def test_)' is empty.

What the Windows job will exercise

The nine items now run in tests-windows, each a real update-shape.py subprocess doing real git commit and push into bare repositories, with the stub started as python.exe <stub> <args> by CreateProcess. That runs: the sitecustomize hook loading from PYTHONPATH in the child; the argument round trip through Windows command-line quoting (--title and --body carry spaces, backticks and an apostrophe, and the tests compare the logged argv with the NEXT line); exit 97 and the stub's stderr reaching landing_failed; stdout and stderr ordering over one real pipe; and the re-run paths on gh pr list answers that are [], OPEN, MERGED and CLOSED.
What it does not run: CreateProcess finding a gh by searching PATH. A missing gh stays covered on Windows by test_a_gh_missing_from_path_is_the_step_that_failed_on_both_runs and the in-process test, both already unskipped. If the Windows job fails on one of these nine, the CI log is the diagnosis and a fix goes on this branch.

Tests

On head 6c93590 (rebased onto origin/main c7c02fa, one commit, one file):

  • tests/test_update_shape_landing.py tests/test_repo_hygiene.py tests/test_cli_reference.py tests/test_git_output_decoding.py tests/test_update_shape.py: 176 passed in 378.34s, no skips.
  • tests/test_update_shape_landing.py alone: 33 passed (19 test functions, 33 items) on the Linux host. Skipped by operating system: none. test_a_gh_missing_from_path_is_the_step_that_failed_on_both_runs still skips by its own guard where gh lives beside git or Python (a Linux runner), as before.
  • CI on 6c93590, all three jobs green: tests 3471 passed, 6 skipped; tests-macos 3467 passed, 10 skipped; tests-windows 3190 passed, 287 skipped. Two other recent pull-request runs on the same base show 296 and 297 skipped on Windows, against 287 here; those branches carry tests of their own, and the -q log names no tests, so this is a count and not a list.
  • Not run locally: the full suite, Windows, macOS.

Composes with

git merge-tree --write-tree <branch> HEAD at 6c93590, wave A siblings (all CLEAN; none changes tests/test_update_shape_landing.py, so nothing here can conflict with them beyond the one file this PR touches):

branch head files it changes merge
fix/pin-rewrite-indentation dc0fa7b 6 CLEAN
fix/update-shape-next-quoting 9faf93f 4 CLEAN
fix/guard-call-forms 90ecef7 1 CLEAN
fix/adopt-plan-asks-unsafe-paths 49b8716 4 CLEAN
fix/adopt-refuse-existing-split-branch a52ca3c 3 CLEAN
fix/ruleset-hint-tracking-branch dba5f78 5 CLEAN
fix/doctor-contracts-manifests fa4ec4f 2 CLEAN
fix/adopt-spelled-unambiguous 51a6e06 7 CLEAN
fix/family-add-member-id d719ac4 2 CLEAN

This head also merges CLEAN into the current origin/main.

Left out

  • Six other files skip on Windows for the same #! gh stub (test_free_plan_hint.py four times, test_neutral_pin_validator.py, test_scaffold_pin_and_reuse.py, test_scaffold_pin_collisions.py, test_scaffold_leg_paths.py, test_scaffold_leg_path_collisions.py); GH_STUB and GH_ON_PATH could move to tests/conftest.py for them, and test_free_plan_hint.py would need a Popen patch in the test process instead of the sitecustomize.
  • A POSIX-only test that puts a real gh file on PATH, to keep the old "found by PATH search" check on two of three OSes, was not added.

Closes #334

🤖 Generated with Claude Code

…`update-shape.py` with is a Python stub the update's child starts through a `sitecustomize` hook rather than a `#!/bin/sh` file on PATH, so the eight tests that carried `WINDOWS_SKIP` run on Windows too and the `--pr` landing and re-run paths (#204) are run by all three CI jobs, not two (#334)

#227 drove `update-shape.py apply --branch --push --pr` against a `gh` that was a shell script on PATH, so every test that reached it was skipped on Windows: `CreateProcess` reads no shebang. No file the suite can write is a `gh` there either: for a program name with no extension it appends `.exe`, so a `gh.cmd` beside a script is not what `gh` names, and the runner's real `gh.exe` further down PATH would be the one that ran. So the stub is no longer found by searching PATH.

- The stub is a Python program (`GH_STUB`): it logs its argv to `GH_LOG`, one line per call and each argument ended by a unit separator, as bytes, so the log is the same on every OS; `pr list` answers from `GH_STATE/list`; `pr create` exits 97 with the same `HTTP 422` line while `GH_STATE/create-fails` exists, else prints the URL and records the pull request; anything else exits 64.
- Python imports `sitecustomize` at start-up from `PYTHONPATH`, so the update's child interpreter is started with a `sitecustomize.py` (`GH_ON_PATH`) first on it. It does what PATH resolution would have done: a `subprocess.Popen` whose program is named `gh` is started as `python <the stub> <the same arguments>`. The stub is a real process, its exit code and streams cross real pipes and the arguments cross the OS's own command-line quoting; `shape_materialize.run` still builds the `CommandFailed` from that process, and the refusal and the NEXT line still name `gh`, not python. `git` is untouched, and with no `GH_STUB` in the environment the module does nothing.
- The `gh` fixture's interface is unchanged (`env`, `calls`, `failing`, `answer`, `forget`); `env` carries `PYTHONPATH`, `GH_STUB`, `GH_LOG` and `GH_STATE` in place of a `PATH` entry.
- The eight `@WINDOWS_SKIP` marks come off, nine test items: each was skipped for the stub, as the file's own docstring said, and the rest of what they do (`git`, a refusing commit hook, NEXT-line quoting) is also done by tests of this file that were never skipped on Windows. The `WINDOWS_SKIP` and `stat` imports go with them.
- The two in-process tests keep their bodies. Their docstrings no longer call themselves the Windows job's coverage: the first is the same two runs with no process for `gh`, the second is the only coverage of a missing `gh` on a runner that has `gh` beside `git` (the subprocess test skips there).

Unchanged: no `assert` line and no test name moves (`git diff -U0 | grep -E '^[-+]\s*(assert|def test_)'` is empty), so no assertion is weakened; the scripts are untouched.

What this does not exercise: the operating system finding a `gh` by searching PATH. The old stub did on POSIX only, and a missing `gh` stays covered by `test_a_gh_missing_from_path_is_the_step_that_failed_on_both_runs` and the in-process test.

Left out: six other files skip on Windows for the same `#!` `gh` stub (`test_free_plan_hint.py` four times, `test_neutral_pin_validator.py`, `test_scaffold_pin_and_reuse.py`, `test_scaffold_pin_collisions.py`, `test_scaffold_leg_paths.py`, `test_scaffold_leg_path_collisions.py`); `GH_STUB` and `GH_ON_PATH` could move to `tests/conftest.py` for them.

Lane: openreposhape-3 (openRepoShape-3)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-3, 2026-10-12T11:28Z) @codex review

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 11 hours and 14 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR makes the landing-test gh dependency cross-platform by running a Python stub through a child-only sitecustomize subprocess hook, allowing nine previously Windows-skipped scenarios to execute with real process, pipe, and argument-quoting behavior across all CI jobs while preserving existing assertions and fixture semantics.

File-Level Changes

Change Details Files
Replace the POSIX shell-based gh fixture with a cross-platform Python subprocess stub and child-process launch hook.
  • Implement byte-stable argv logging and preserve pr list, pr create, and failure behavior.
  • Inject sitecustomize.py through the child PYTHONPATH to rewrite only gh launches to python <stub>, leaving git and other commands unchanged.
  • Preserve the fixture's existing environment, call-inspection, response, and failure controls while switching from PATH setup to GH_STUB, GH_LOG, and GH_STATE.
tests/test_update_shape_landing.py
Enable the previously Windows-skipped landing and rerun scenarios on all CI platforms.
  • Remove the Windows skip markers and now-unused imports from the nine affected test items.
  • Retain real subprocess pipes, exit statuses, argument quoting, git operations, and pull-request state transitions in the cross-platform tests.
  • Update module and test docstrings to describe the new coverage and clarify the remaining missing-gh and in-process coverage.
tests/test_update_shape_landing.py

Assessment against linked issues

Issue Objective Addressed Explanation
#334 Make the eight gh-stub-driven landing and re-run tests in tests/test_update_shape_landing.py runnable on Windows instead of skipping them. ✅
#334 Replace the POSIX-only shell gh stub with a cross-platform test stub that preserves the tested behavior, including argument handling, pull-request responses, failures, and real subprocess streams. ✅
#334 Ensure the Windows CI job exercises the --pr landing and re-run paths, including Windows command-line quoting and the relevant landing_failed behavior, while retaining coverage for missing gh and in-process cases. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T11:30:56.516913Z 6c93590 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sonarqubecloud

Copy link
Copy Markdown

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 6c935904c8

ℹ️ 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".

@brettheap
brettheap merged commit 8a14ac9 into main Oct 12, 2026
5 checks passed
@brettheap
brettheap deleted the fix/landing-tests-windows branch October 12, 2026 12:24
brettheap added a commit that referenced this pull request Oct 12, 2026
…, #253 via #264, #302 via #318, #288 via #309, #279 via #310, #306 via #311, #334 via #336, #239 via #269, #243 via #268, #321 via #335) into fix/adopt-record-submodule-placement

Brings in the twelve commits from c7c02fa to a1b3a4b on top of 71b58a1,
merged by sha. No rebase. Among the files this branch changes:
346079d (#216) and e43fa95 (#243) change adopt-project.py; 34ecbc2 (#260)
changes scripts/shape_materialize.py; 87373a6 (#306) changes
shape-doctor.py and tests/test_shape_doctor.py; 7491530 (#288) changes
AGENTS.md and tests/test_repo_hygiene.py.

Two conflicts, each resolved keeping both sides:

- adopt-project.py, the module docstring's `execute` paragraph. #243 ends
  "the root's only submodules are the two leg mounts, each at the commit
  pushed to its leg."; this branch follows "two leg mounts." with "The
  split's `project.yaml` records the leg each source submodule kept in a
  leg was answered into, under `submodules:`, for `shape-doctor.py` to
  check it against." The merge has #243's sentence, then this branch's,
  re-wrapped to the paragraph's width. The module docstring is not in
  `--help` (docs/cli.md holds neither sentence).
- tests/test_repo_hygiene.py, `test_agents_md_is_short_enough_to_be_read`.
  Each side moved the AGENTS.md cap from 464 and wrote a paragraph
  saying why: #288 to 477, for thirteen lines, and this branch to 472,
  for eight. AGENTS.md itself merged cleanly and holds both: 485 lines,
  main's 477 plus this branch's +9 -1. The merge keeps #288's paragraph
  word for word, then this branch's, renumbered "2026-10-12: 477 -> 485"
  because it now follows #288's, and asserts `<= 485`.

`git merge-tree --write-tree` of the two parents gives the same tree in
every file but these two.

Checked:

- adopt-project.py: `_commit_the_split` was changed by both sides, in
  hunks that do not touch. #243 clones the assembly with `--template=`;
  this branch builds `append` with the `submodules:` record. The merged
  function holds both, and each side's text is unchanged. Every other
  definition one side changed is that side's text.
- shape-doctor.py: #306 changes `validator_row` and `run_validator`.
  This branch's placement functions, F1's
  `gitmodules_the_record_answers` among them, are this branch's text.
- No top-level name is bound twice in adopt-project.py,
  scaffold-project.py, scripts/repo_shape.py,
  scripts/shape_materialize.py, shape-doctor.py, validate-manifest.py,
  update-shape.py, scripts/family.py or scripts/bump-leg.py. Each merged
  module's names are the base's plus what either side added.
- AGENTS.md is main's plus exactly this branch's changed lines.
- The branch's diff against main is #189 alone: 12 files, +1694 -157. That
  is +1670 at 27d039b, plus F1's fix and test (+23), plus the one line
  the docstring re-wrap adds.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 12, 2026
… of main's commits merge with no conflict, among them #243's template-less clone of the assembly and #216's literal `git grep` in adopt-project.py, and #260's one-pass `render` in shape_materialize.py

origin/main moved 71b58a1 -> 8cdca5e. It was merged by sha, as the
coordinator asked for e43fa95 or later:
- c7c02fa (#299 via #315), scripts/family.py;
- 346079d (#216 via #228), adopt-project.py: `plan`'s follow-up
  `git grep`;
- 34ecbc2 (#260 via #316), scripts/shape_materialize.py: `render`
  substitutes in one pass;
- 86da808 (#253 via #264), scripts/bump-leg.py;
- 6f4ce47 (#302 via #318), scripts/family.py;
- 7491530 (#288 via #309), AGENTS.md, README, docs and
  scaffold-project.py's --help;
- 7591455 (#279 via #310), tests/conftest.py: `git()` takes its default
  identity as `-c` config;
- 87373a6 (#306 via #311), shape-doctor.py;
- 8a14ac9 (#334 via #336), tests/test_update_shape_landing.py;
- c1b6732 (#239 via #269), update-shape.py;
- e43fa95 (#243 via #268), adopt-project.py: the assembly root is cloned
  with `--template=`, and the verification refuses a mount whose gitlink
  is not the commit pushed to its leg (`adopt-mount-commit`);
- a1b3a4b (#321 via #335), tests/test_git_output_decoding.py;
- 8cdca5e (#295 via #312), the template's scripts/validate-pins.py.

`git merge-tree` and this merge give the same tree, 07e6b49.
adopt-project.py, scripts/shape_materialize.py and
tests/test_adopt_ignored_shape_files.py auto-merge. In the last of these
main's 346079d and this branch's 86a5e30 change different cases.

Checked on the merged tree:
- AST (fin183g/names.py, base 71b58a1): no top-level name is bound twice
  in adopt-project.py, scaffold-project.py, scripts/repo_shape.py or
  scripts/shape_materialize.py, and none is loaded but bound nowhere.
  Main changed the signature of no function this branch calls.
- Every sentence 86a5e30 changed is still there: in `_through`, in
  `_link_parts`, in `_verify`'s `_resolve` (which e43fa95's
  `adopt-mount-commit` leaves as it was), and in the three test files.
- `_commit_the_split` now clones the assembly with `--template=`. The
  next commit, F3, reads what that clone holds in its own `.git`, which
  is why F3 comes after this merge.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant