Skip to content

Share capture-mode setup in tree snapshot tests and drop unreachable open-failure branches - #176

Merged
Deicyde merged 4 commits into
mainfrom
golf/tree-snapshot-test-guards
Oct 11, 2026
Merged

Deicyde merged 4 commits into
mainfrom
golf/tree-snapshot-test-guards

Conversation

@Deicyde

@Deicyde Deicyde commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #95. +27/-82 against main.

  • Capture-mode setup (tests/test_tree_snapshot_limits.py). Seven tests and the _capture helper spelled out the descriptor-capture skip, the portable-capture patch or the os.listdir guard inline. They now call _require_descriptor_capture, _use_portable_capture and _forbid_unbounded_listdir. The first two are imported from tests/test_lean_sources.py, where Share checkpoint, bind-count, and fixture helpers in the Lean source tests #181 added them with the same bodies, as tests/test_contract.py imports helpers from tests/test_impact.py. The guard's two assertion messages become one, "unexpected unbounded os.listdir call"; they appear only in a failure report, since the tests match the TreeSnapshotError text.
  • _open_failure (autoform_cli/_directory_binding.py). open_directory handles ENOENT and ENOTDIR as retryable before it calls _open_failure, so the FileNotFoundError and NotADirectoryError branches could not run. They are removed; no test reached them.

The branch merges current main (with #178 and #181). No other open PR edits these files, and it merges cleanly with all 18 of them.

Validation at exact head 50161a2c: ruff check autoform_cli servers tests is clean. tests/test_tree_snapshot_limits.py passes (37), and tests/test_lean_sources.py gives 140 passed, 3 skipped and 1 expected failure.

Seven tests and the _capture helper spelled out the descriptor-capture
skip, the portable-capture patch or the listdir guard inline. Three
helpers now hold them; the guard's two assertion messages become one.
open_directory handles ENOENT and ENOTDIR as retryable before it calls
_open_failure, so the FileNotFoundError and NotADirectoryError cases
could not run.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 7, 2026
#181 added _require_descriptor_capture and _use_portable_capture to tests/test_lean_sources.py with the same bodies as the copies here. Import them instead, as tests/test_contract.py imports helpers from tests/test_impact.py.
@Deicyde

Deicyde commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Review at 50161a2

Verdict: merge-ready (the PR is still a draft). The two _open_failure branches that were removed could not run on any platform, Windows included:

  • _open_failure has one caller, open_directory (autoform_cli/_directory_binding.py:117). That call runs only for an OSError whose errno is not in _RETRYABLE_OPEN_ERRNOS (ENOENT, ENOTDIR, ELOOP, ESTALE).
  • On POSIX, os.open builds its error with OSError(errno, ...), and CPython maps ENOENT to FileNotFoundError and ENOTDIR to NotADirectoryError. So an os.open error of either type always carries a retryable errno and goes to the retry branch at :111. Checked on this host: a missing path, a regular file, and a path through a file give FileNotFoundError/ENOENT, NotADirectoryError/ENOTDIR and NotADirectoryError/ENOTDIR.
  • On Windows, DIRECTORY_BINDING_SUPPORTED is false, because there is no os.O_DIRECTORY and os.supports_dir_fd is empty. open_directory raises at :100-101 before os.open runs.
  • No test forces the flag on or patches os.open to raise an errno-less exception. The one test that patches os.open (tests/test_lean_sources.py:592-600) raises OSError(errno, ...), which maps to the subclass with its errno set.
  • The "does not exist" and "is not a directory" messages users see come from lean._lasting_root_failure, which this PR doesn't touch.

The test refactor keeps every skip guard and patch. The imported helpers have exactly the bodies they replace, and only the os.listdir AssertionError text changes. The Windows CI job runs tests/test_tree_snapshot_limits.py, so it covers the new tests.test_lean_sources import, and it is green at this head.

Landing

Posted by PR swarm: Review #175 #176 #188

@Deicyde
Deicyde marked this pull request as ready for review October 11, 2026 02:46
@Deicyde
Deicyde merged commit 924c310 into main Oct 11, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant