@@ -632,16 +632,44 @@ def test_command_recurses_dir():
632632
633633
634634def test_root_path_validation (caplog ):
635+ import tempfile
636+ import os as test_os
637+
635638 caplog .set_level (logging .WARNING , logger = "borg.patterns" )
636639
637- # absolute path should not warn
638- parse_inclexcl_command ("R /absolute/path" )
639- assert "does not look like an absolute path" not in caplog .text
640+ # Test 1: Unix-style absolute path that doesn't exist
641+ # On Unix systems, /absolute/paths don't trigger "relative" warning
642+ # On Windows, such paths may not exist but still validate correctly
643+ caplog .clear ()
644+ parse_inclexcl_command ("R /absolute/unix/path" )
645+ # Should not have "relative" warning (starts with /)
646+ assert "relative" not in caplog .text
647+
648+ # Test 2: absolute path that doesn't exist should warn about existence
649+ caplog .clear ()
650+ parse_inclexcl_command ("R /nonexistent/absolute/path/12345" )
651+ assert "does not exist" in caplog .text
640652
641- # relative path should warn
653+ # Test 3: relative path that exists should warn about relative
654+ caplog .clear ()
655+ with tempfile .TemporaryDirectory () as tmpdir :
656+ # Create temp subdir to be relative
657+ old_cwd = test_os .getcwd ()
658+ try :
659+ test_os .chdir (tmpdir )
660+ # Create a subdir
661+ test_os .makedirs ("test_root_dir" , exist_ok = True )
662+ parse_inclexcl_command ("R test_root_dir" )
663+ assert "relative" in caplog .text
664+ assert "does not exist" not in caplog .text
665+ finally :
666+ test_os .chdir (old_cwd )
667+
668+ # Test 4: relative path that doesn't exist should warn about both
642669 caplog .clear ()
643- parse_inclexcl_command ("R relative/path" )
644- assert "does not look like an absolute path" in caplog .text
670+ parse_inclexcl_command ("R relative/nonexistent/path" )
671+ assert "relative" in caplog .text
672+ assert "does not exist" in caplog .text
645673
646674
647675@pytest .mark .parametrize (
0 commit comments