@@ -151,12 +151,73 @@ def read_bytes():
151151    assert_log (
152152        "Checking for launcher.*" ,
153153        "Create %s linking to %s" ,
154-         "Failed to read launcher template at %s." ,
154+         "Failed to read launcher template at %s\\ ." ,
155155        "Failed to read %s" ,
156156        assert_log .end_of_log (),
157157    )
158158
159159
160+ def  test_write_alias_launcher_unlinkable (fake_config , assert_log , tmp_path ):
161+     def  fake_link (x , y ):
162+         raise  OSError ("Error for testing" )
163+ 
164+     fake_config .scratch  =  {}
165+     fake_config .launcher_exe  =  tmp_path  /  "launcher.txt" 
166+     fake_config .launcher_exe .write_bytes (b'Arbitrary contents' )
167+     fake_config .default_platform  =  '-32' 
168+     fake_config .global_dir  =  tmp_path  /  "bin" 
169+     IC ._write_alias (
170+         fake_config ,
171+         {"tag" : "test" },
172+         {"name" : "test.exe" },
173+         tmp_path  /  "target.exe" ,
174+         _link = fake_link 
175+     )
176+     assert_log (
177+         "Checking for launcher.*" ,
178+         "Create %s linking to %s" ,
179+         "Failed to create hard link.+" ,
180+         "Created %s as copy of %s" ,
181+         assert_log .end_of_log (),
182+     )
183+ 
184+ 
185+ def  test_write_alias_launcher_unlinkable_remap (fake_config , assert_log , tmp_path ):
186+     # This is for the fairly expected case of the PyManager install being on one 
187+     # drive, but the global commands directory being on another. In this 
188+     # situation, we can't hard link directly into the app files, and will need 
189+     # to copy. But we only need to copy once, so if a launcher_remap has been 
190+     # set (in the current process), then we have an available copy already and 
191+     # can link to that. 
192+ 
193+     def  fake_link (x , y ):
194+         if  x .match ("launcher.txt" ):
195+             raise  OSError (17 , "Error for testing" )
196+ 
197+     fake_config .scratch  =  {
198+         "install_command._write_alias.launcher_remap" : {"launcher.txt" : tmp_path  /  "actual_launcher.txt" },
199+     }
200+     fake_config .launcher_exe  =  tmp_path  /  "launcher.txt" 
201+     fake_config .launcher_exe .write_bytes (b'Arbitrary contents' )
202+     (tmp_path  /  "actual_launcher.txt" ).write_bytes (b'Arbitrary contents' )
203+     fake_config .default_platform  =  '-32' 
204+     fake_config .global_dir  =  tmp_path  /  "bin" 
205+     IC ._write_alias (
206+         fake_config ,
207+         {"tag" : "test" },
208+         {"name" : "test.exe" },
209+         tmp_path  /  "target.exe" ,
210+         _link = fake_link 
211+     )
212+     assert_log (
213+         "Checking for launcher.*" ,
214+         "Create %s linking to %s" ,
215+         "Failed to create hard link.+" ,
216+         ("Created %s as hard link to %s" , ("test.exe" , "actual_launcher.txt" )),
217+         assert_log .end_of_log (),
218+     )
219+ 
220+ 
160221@pytest .mark .parametrize ("default" , [1 , 0 ]) 
161222def  test_write_alias_default (alias_checker , monkeypatch , tmp_path , default ):
162223    prefix  =  Path (tmp_path ) /  "runtime" 
0 commit comments