Skip to content

tests: fix NameError in daemon_sock / fake_daemon fixtures (macOS CI)#30

Open
danielhertz1999-bit wants to merge 1 commit into
CodeAbra:mainfrom
danielhertz1999-bit:fix/macos-ci-af-unix
Open

tests: fix NameError in daemon_sock / fake_daemon fixtures (macOS CI)#30
danielhertz1999-bit wants to merge 1 commit into
CodeAbra:mainfrom
danielhertz1999-bit:fix/macos-ci-af-unix

Conversation

@danielhertz1999-bit

Copy link
Copy Markdown
Contributor

The build & test (macOS) gate is currently red on main (incl. the Release v1.2.0 run). This fixes the most clear-cut part of it.

What's broken

daemon_sock (test_mcp_tools.py) and fake_daemon (test_socket_disconnect_reconnect.py) both reference tmp_path in the fixture body without it being a parameter:

@pytest.fixture(scope="module")
def daemon_sock() -> "Path":
    sock_dir = tmp_path / "sock"   # NameError: name 'tmp_path' is not defined

So every test using them errors at setup — 5 errors on the macOS gate. (daemon_sock is also scope="module", where the function-scoped tmp_path wouldn't be injectable anyway.)

Fix

Bind the control socket under a short tempfile.mkdtemp(prefix="iai-sock-") dir (the same pattern as the existing short_socket conftest fixture). This:

  • removes the undefined-name reference, and
  • keeps the AF_UNIX path under the ~104-char sun_path limit — pytest's macOS tmp_path (/private/var/folders/.../pytest-of-runner/...) overflows it, which is the same root cause behind the other macOS socket failures.

Both fixtures already rmtree their sock_dir on teardown, so cleanup is unchanged. Verified the modules still collect cleanly.

Scope / remaining

I kept this to the two definitely-broken fixtures (they NameError 100% of the time). The other macOS failures — test_concurrency, test_capture_transcript_no_spawn_defer, test_bridge_socket_first — share the same AF_UNIX-path-too-long root cause (they build tmp_path / "sock"), and pass on Linux today. Happy to route those sockets through short dirs too in a follow-up, but I didn't want to churn currently-green fixtures I can't exercise on a macOS runner locally — your call on whether you'd like that.

🤖 Generated with Claude Code

Both fixtures referenced `tmp_path` in their body without it being a
parameter, so every test using them errored at setup with
"NameError: name 'tmp_path' is not defined" — visible on the macOS CI gate
(incl. the Release v1.2.0 run) as 5 setup errors across test_mcp_tools.py
and test_socket_disconnect_reconnect.py. daemon_sock is also module-scoped,
where the function-scoped tmp_path wouldn't be usable regardless.

Bind the control socket under a short tempfile.mkdtemp(prefix="iai-sock-")
dir instead — which both removes the undefined-name reference and keeps the
AF_UNIX path under the ~104-char sun_path limit (pytest's macOS tmp_path,
/private/var/folders/.../pytest-of-runner/..., overflows it). Both fixtures
already rmtree their sock_dir on teardown, so cleanup is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant