Repository navigation
fix(tests): resolve test collection and execution failures on Windows - #2028
prasad2512 wants to merge 1 commit into
Conversation
fe59a53 to
8e68840
Compare
chrikrah
left a comment
There was a problem hiding this comment.
@prasad2512 I'd merge 8e68840. I have no Windows machine, so I removed os.geteuid before pytest imports the modules. At bcd55fe two modules fail to collect and at your head none do. The tests you touched pass on Linux as before.
$ python nogeteuid.py tests/lib/tools/test_file_store.py tests/lib/tools/memory_sync # del os.geteuid, then pytest --collect-only
bcd55fe: 99 tests collected, 2 errors (AttributeError: module 'os' has no attribute 'geteuid')
8e68840: 145 tests collected
$ python -m pytest tests/lib/test_bedrock.py tests/lib/tools/memory_sync tests/lib/tools/test_agent_toolset.py tests/lib/tools/test_file_store.py -q -n 4
bcd55fe: 271 passed 8e68840: 271 passed
$ python -m pytest tests/lib -q -n 4 # 8e68840, env -i, CPython 3.10
2209 passed, 10 skipped, 1 xfailed
$ pyright --pythonplatform Windows <the five touched files> # pyright 1.1.399
0 errors, 0 warnings, 0 informations
# not run: Windows itself, so the NamedTemporaryFile lock and the FileStore skips rest on reading
non-blocking: every job in .github/workflows/ci.yml runs on ubuntu-latest, so nothing stops the next os.geteuid() in a decorator from breaking collection again. The two runtime calls left, test_credentials.py:3946 and test_agent_toolset.py:861, already sit behind an os.name check.
The fixture you replaced came in with 46e4b98 (#974) and its delete=True handle carries no reason tied to the platform, so tmp_path loses nothing.
The three @needs_symlinks lines in item 4 are also in #1917 (okxint), open since 09-07.
@dtmeadows-ant the change is tests only. I'd add a windows-latest collect-only step, which costs one runner and would have caught all three decorators. Is Windows a platform you mean to support for contributors?
|
Thank you so much @chrikrah for the thorough verification and testing on Linux! Really appreciate your confirmation on test collection and regression safety. Happy to make any further adjustments if needed by @dtmeadows-ant. Looking forward to having Windows contributor support enabled cleanly! |
|
Hi @dtmeadows-ant, just gently following up on this PR. All CI checks and Windows test collection fixes have been verified and approved by @chrikrah (and duplicate PR #2035 was closed). Please let me know if anything else is needed from my end to get this merged. Thank you! |
Fixes #2027
Summary
Resolves multiple test collection and test execution errors encountered when running the test suite on Windows / non-POSIX platforms:
Guard
os.geteuid()againstAttributeErrorduring pytest collection:In
tests/lib/tools/test_file_store.py(lines 207 & 317) andtests/lib/tools/memory_sync/test_delete_discipline.py(line 168),@pytest.mark.skipif(os.geteuid() == 0, ...)crashed test collection on Windows withAttributeError: module 'os' has no attribute 'geteuid'becauseos.geteuidis POSIX-only. Addedos.name != "posix" or getattr(os, "geteuid", lambda: -1)() == 0guards. Also guarded the runtime check intests/lib/tools/memory_sync/test_memory_sync.py:372to matchtest_credentials.pyandtest_agent_toolset.py.Skip non-POSIX platforms on memory sync suites:
FileStorerequiresO_NOFOLLOWsupport and explicitly refuses non-POSIX platforms (_platform_supported()raisingRuntimeError: FileStore requires O_NOFOLLOW support on this platform). Whiletest_file_store.pyalready carriedpytestmark = pytest.mark.skipif(os.name != "posix", reason="FileStore refuses non-POSIX platforms"),test_memory_sync.pyandtest_delete_discipline.pywere missing this file-level skip marker. Added the marker so these suites skip cleanly on Windows.Resolve
NamedTemporaryFilelock contention in Bedrock tests:In
tests/lib/test_bedrock.py,mock_aws_configopenedtempfile.NamedTemporaryFile(mode="w+", delete=True)in a context manager. On Windows, an open temporary file cannot be opened by a second process/handle, causingboto3.Sessionto raisebotocore.exceptions.ProfileNotFoundand fail 4 tests (test_region_infer_from_profile,test_region_infer_from_specified_profile, andtest_region_infer_from_aws_profile_argument). Replaced with pytest's built-intmp_pathfixture.Mark remaining symlink tests in
test_agent_toolset.py:Added
@needs_symlinksmarker totest_read_through_symlink_escape_is_rejected,test_glob_post_filters_symlink_escape, andtest_grep_skips_symlinked_filesto avoidWinError 1314privilege failures on Windows.Tests Verified
uv run pytest -n 0 tests/lib/test_bedrock.py tests/lib/tools/test_file_store.py tests/lib/tools/memory_sync/test_delete_discipline.py tests/lib/tools/memory_sync/test_memory_sync.py tests/lib/tools/test_agent_toolset.py(103 passed, 105 skipped, 0 failures)uv run ruff check tests/lib/test_bedrock.py tests/lib/tools/(All checks passed)uv run ruff format --check tests/lib/test_bedrock.py tests/lib/tools/(All formatted)uv run pyright tests/lib/test_bedrock.py tests/lib/tools/(0 errors, 0 warnings)