@@ -60,7 +60,7 @@ def test_shell_coverage_setup_does_not_require_git(checkout, tmp_path):
6060 check = True ,
6161 capture_output = True ,
6262 text = True ,
63- env = {"PATH" : "/usr/bin:/bin" },
63+ env = {"HOME" : str ( tmp_path / "home" ), " PATH" : "/usr/bin:/bin" },
6464 )
6565
6666 expected_root = str (mounted_checkout .resolve ())
@@ -88,3 +88,49 @@ def test_shell_coverage_setup_provides_container_identity(tmp_path):
8888 )
8989
9090 assert result .stdout .splitlines () == ["nemo-ci" , "nemo-ci" ]
91+
92+
93+ @pytest .mark .parametrize ("configured_cache" , [None , Path ("/root-owned-cache" )])
94+ def test_shell_coverage_setup_provides_writable_cache (configured_cache , tmp_path ):
95+ home = tmp_path / "home"
96+ home .mkdir ()
97+ env = {"HOME" : str (home ), "PATH" : "/usr/bin:/bin" }
98+ if configured_cache is not None :
99+ env ["XDG_CACHE_HOME" ] = str (configured_cache )
100+
101+ result = subprocess .run (
102+ [
103+ "bash" ,
104+ "-c" ,
105+ 'source "$1"; printf "%s\\ n" "$XDG_CACHE_HOME"' ,
106+ "coverage-test" ,
107+ str (PROJECT_ROOT / "tests" / "coverage.sh" ),
108+ ],
109+ check = True ,
110+ capture_output = True ,
111+ text = True ,
112+ cwd = tmp_path ,
113+ env = env ,
114+ )
115+
116+ assert result .stdout .strip () == str (home / ".cache" )
117+
118+
119+ def test_shell_coverage_setup_preserves_writable_cache (tmp_path ):
120+ cache = tmp_path / "cache"
121+ cache .mkdir ()
122+ result = subprocess .run (
123+ [
124+ "bash" ,
125+ "-c" ,
126+ 'source "$1"; printf "%s\\ n" "$XDG_CACHE_HOME"' ,
127+ "coverage-test" ,
128+ str (PROJECT_ROOT / "tests" / "coverage.sh" ),
129+ ],
130+ check = True ,
131+ capture_output = True ,
132+ text = True ,
133+ cwd = tmp_path ,
134+ env = {"HOME" : str (tmp_path / "home" ), "PATH" : "/usr/bin:/bin" , "XDG_CACHE_HOME" : str (cache )},
135+ )
136+ assert result .stdout .strip () == str (cache )
0 commit comments