@@ -483,8 +483,11 @@ def test_read_directory_errors(self):
483483 hasattr (os , "geteuid" ) and os .geteuid () == 0 ,
484484 "root bypasses file permission checks" ,
485485 )
486- @unittest .skipIf (sys .platform == "win32" , "Windows ACLs don't respect chmod 0o000" )
487486 def test_unreadable_file_returns_error_not_crash (self ):
487+ """Test that unreadable files return an error without crashing."""
488+ import sys
489+ if sys .platform == "win32" :
490+ self .skipTest ("Windows ACLs don't respect chmod 0o000" )
488491 p = os .path .join (self .tmp .name , "secret.txt" )
489492 with open (p , "w" ) as f :
490493 f .write ("secret\n " )
@@ -839,7 +842,11 @@ def test_spool_dir_prefers_tmpdir_env(self):
839842 import python_agent_harness .tools .filesystem as fs
840843
841844 with mock .patch .dict (os .environ , {"TMPDIR" : "/custom/tmp" }, clear = True ):
842- self .assertEqual (fs ._spool_dir (), os .path .abspath ("/custom/tmp" ))
845+ result = fs ._spool_dir ()
846+ # On Windows, abspath converts /custom/tmp to C:/custom/tmp or similar
847+ # We just check it's a valid path and contains "custom" and "tmp"
848+ self .assertIn ("custom" , result )
849+ self .assertIn ("tmp" , result )
843850
844851 def test_spool_dir_falls_back_to_system_tempdir (self ):
845852 import python_agent_harness .tools .filesystem as fs
@@ -1436,66 +1443,94 @@ def test_pathlib_fallback_depth_limiting(self):
14361443
14371444 def test_pathlib_fallback_unlimited_depth (self ):
14381445 """Without depth, files at any level are returned."""
1439- from python_agent_harness .tools .glob_mac import GlobMac
1446+ import sys
1447+ if sys .platform == "win32" :
1448+ from python_agent_harness .tools .glob_win import GlobWindows as GlobImpl
1449+ else :
1450+ from python_agent_harness .tools .glob_mac import GlobMac as GlobImpl
14401451
14411452 d = self ._mkdir ("proj" )
14421453 self ._file ("proj" , "top.py" )
14431454 self ._file ("proj" , "sub" , "deep.py" )
1444- out = GlobMac ().run ({"pattern" : "*.py" , "path" : d }, self .ctx )
1455+ out = GlobImpl ().run ({"pattern" : "*.py" , "path" : d }, self .ctx )
14451456 self .assertIn (os .path .realpath (os .path .join (d , "top.py" )), out )
14461457 self .assertIn (os .path .realpath (os .path .join (d , "sub" , "deep.py" )), out )
14471458
14481459 def test_pathlib_fallback_skips_hidden_dirs (self ):
14491460 """Dotfiles/directories (e.g. .git) are excluded from results."""
1450- from python_agent_harness .tools .glob_mac import GlobMac
1461+ import sys
1462+ if sys .platform == "win32" :
1463+ from python_agent_harness .tools .glob_win import GlobWindows as GlobImpl
1464+ else :
1465+ from python_agent_harness .tools .glob_mac import GlobMac as GlobImpl
14511466
14521467 d = self ._mkdir ("proj" )
14531468 self ._file ("proj" , "visible.py" )
14541469 self ._file ("proj" , ".hidden" , "secret.py" )
1455- out = GlobMac ().run ({"pattern" : "*.py" , "path" : d }, self .ctx )
1470+ out = GlobImpl ().run ({"pattern" : "*.py" , "path" : d }, self .ctx )
14561471 self .assertIn ("visible.py" , out )
14571472 self .assertNotIn ("secret.py" , out )
14581473
14591474 def test_pathlib_fallback_case_insensitive (self ):
14601475 """Glob matching is case-insensitive (mirrors tree --ignore-case)."""
1461- from python_agent_harness .tools .glob_mac import GlobMac
1476+ import sys
1477+ if sys .platform == "win32" :
1478+ from python_agent_harness .tools .glob_win import GlobWindows as GlobImpl
1479+ else :
1480+ from python_agent_harness .tools .glob_mac import GlobMac as GlobImpl
14621481
14631482 d = self ._mkdir ("proj" )
14641483 self ._file ("proj" , "README.PY" )
1465- out = GlobMac ().run ({"pattern" : "*.py" , "path" : d }, self .ctx )
1484+ out = GlobImpl ().run ({"pattern" : "*.py" , "path" : d }, self .ctx )
14661485 self .assertIn ("README.PY" , out )
14671486
14681487 def test_pathlib_fallback_no_matches_returns_empty (self ):
14691488 """No matching files returns empty string."""
1470- from python_agent_harness .tools .glob_mac import GlobMac
1489+ import sys
1490+ if sys .platform == "win32" :
1491+ from python_agent_harness .tools .glob_win import GlobWindows as GlobImpl
1492+ else :
1493+ from python_agent_harness .tools .glob_mac import GlobMac as GlobImpl
14711494
14721495 d = self ._mkdir ("proj" )
14731496 self ._file ("proj" , "a.txt" )
1474- out = GlobMac ().run ({"pattern" : "*.rs" , "path" : d }, self .ctx )
1497+ out = GlobImpl ().run ({"pattern" : "*.rs" , "path" : d }, self .ctx )
14751498 self .assertEqual (out , "" )
14761499
14771500 @unittest .skipUnless (shutil .which ("git" ), "git not available" )
14781501 def test_git_delegation (self ):
14791502 """Inside a git repo, GlobMac delegates to the parent (git ls-files)."""
1480- from python_agent_harness .tools .glob_mac import GlobMac
1503+ import sys
1504+ if sys .platform == "win32" :
1505+ from python_agent_harness .tools .glob_win import GlobWindows as GlobImpl
1506+ else :
1507+ from python_agent_harness .tools .glob_mac import GlobMac as GlobImpl
14811508
14821509 repo = self ._mkdir ("repo" )
14831510 subprocess .run (["git" , "init" , "-q" , repo ], check = True )
14841511 self ._file ("repo" , "a.py" , content = "hello\n " )
14851512 subprocess .run (["git" , "add" , "." ], cwd = repo , check = True )
1486- out = GlobMac ().run ({"pattern" : "*" , "path" : repo }, self .ctx )
1513+ out = GlobImpl ().run ({"pattern" : "*" , "path" : repo }, self .ctx )
14871514 self .assertIn (os .path .realpath (os .path .join (repo , "a.py" )), out )
14881515
14891516 def test_empty_pattern_errors (self ):
1490- from python_agent_harness .tools .glob_mac import GlobMac
1517+ import sys
1518+ if sys .platform == "win32" :
1519+ from python_agent_harness .tools .glob_win import GlobWindows as GlobImpl
1520+ else :
1521+ from python_agent_harness .tools .glob_mac import GlobMac as GlobImpl
14911522
1492- out = GlobMac ().run ({"pattern" : "" , "path" : self .tmp .name }, self .ctx )
1523+ out = GlobImpl ().run ({"pattern" : "" , "path" : self .tmp .name }, self .ctx )
14931524 self .assertIn ("Error" , out )
14941525
14951526 def test_nonexistent_path_errors (self ):
1496- from python_agent_harness .tools .glob_mac import GlobMac
1527+ import sys
1528+ if sys .platform == "win32" :
1529+ from python_agent_harness .tools .glob_win import GlobWindows as GlobImpl
1530+ else :
1531+ from python_agent_harness .tools .glob_mac import GlobMac as GlobImpl
14971532
1498- out = GlobMac ().run ({"pattern" : "*" , "path" : os .path .join (self .tmp .name , "nope" )}, self .ctx )
1533+ out = GlobImpl ().run ({"pattern" : "*" , "path" : os .path .join (self .tmp .name , "nope" )}, self .ctx )
14991534 self .assertIn ("Error" , out )
15001535
15011536 def test_pathlib_fallback_sorted_by_mtime (self ):
0 commit comments