@@ -125,6 +125,11 @@ def _make_vcpkg_env(self, tmp_path):
125125 """Create a minimal vcpkg.json so generate() produces commands."""
126126 (tmp_path / "vcpkg.json" ).write_text ("{}" )
127127
128+ def _pin_linux_host (self , monkeypatch ):
129+ """Make generate() behave as on an x86_64 Linux host, whatever host runs the test."""
130+ monkeypatch .setattr ("hatch_cpp.toolchains.vcpkg.sys_platform" , "linux" )
131+ monkeypatch .setattr ("hatch_cpp.toolchains.vcpkg.platform_machine" , lambda : "x86_64" )
132+
128133 def test_generate_with_explicit_ref (self , tmp_path , monkeypatch ):
129134 monkeypatch .chdir (tmp_path )
130135 self ._make_vcpkg_env (tmp_path )
@@ -164,6 +169,7 @@ def test_generate_without_ref(self, tmp_path, monkeypatch):
164169
165170 def test_generate_uses_posix_command_paths (self , tmp_path , monkeypatch ):
166171 monkeypatch .chdir (tmp_path )
172+ self ._pin_linux_host (monkeypatch )
167173 self ._make_vcpkg_env (tmp_path )
168174
169175 cfg = HatchCppVcpkgConfiguration (vcpkg_triplet = "x64-linux" )
@@ -185,6 +191,7 @@ def test_generate_detects_linux_arm64_triplet(self, tmp_path, monkeypatch):
185191
186192 def test_generate_detects_emscripten_triplet (self , tmp_path , monkeypatch ):
187193 monkeypatch .chdir (tmp_path )
194+ self ._pin_linux_host (monkeypatch )
188195 self ._make_vcpkg_env (tmp_path )
189196 build_plan = SimpleNamespace (platform = SimpleNamespace (platform = "emscripten" ))
190197
@@ -206,6 +213,7 @@ def test_generate_uses_windows_command_paths(self, tmp_path, monkeypatch):
206213
207214 def test_generate_skips_clone_when_vcpkg_root_exists (self , tmp_path , monkeypatch ):
208215 monkeypatch .chdir (tmp_path )
216+ self ._pin_linux_host (monkeypatch )
209217 self ._make_vcpkg_env (tmp_path )
210218 vcpkg_root = tmp_path / "vcpkg"
211219 vcpkg_root .mkdir ()
@@ -225,6 +233,7 @@ def test_generate_skips_clone_when_vcpkg_root_exists(self, tmp_path, monkeypatch
225233
226234 def test_generate_reclones_when_vcpkg_root_exists_but_empty (self , tmp_path , monkeypatch ):
227235 monkeypatch .chdir (tmp_path )
236+ self ._pin_linux_host (monkeypatch )
228237 self ._make_vcpkg_env (tmp_path )
229238 (tmp_path / "vcpkg" ).mkdir ()
230239
@@ -253,6 +262,7 @@ def test_generate_bootstraps_when_vcpkg_executable_missing(self, tmp_path, monke
253262
254263 def test_generate_reclones_when_vcpkg_exists_but_not_working (self , tmp_path , monkeypatch ):
255264 monkeypatch .chdir (tmp_path )
265+ self ._pin_linux_host (monkeypatch )
256266 self ._make_vcpkg_env (tmp_path )
257267 vcpkg_root = tmp_path / "vcpkg"
258268 vcpkg_root .mkdir ()
0 commit comments