@@ -276,12 +276,16 @@ def run_shell_function(
276
276
self ,
277
277
shell_script_path : Path ,
278
278
shell_function_name : str ,
279
- args : Iterable [str ] = (),
279
+ script_args : Iterable [str ] = (),
280
+ function_args : Iterable [str ] = (),
280
281
env : dict [str , str ] | None = None ,
281
282
) -> str :
282
283
env = env or {}
284
+ script_args_str = " " .join (shlex .quote (arg ) for arg in script_args )
285
+ function_args_str = " " .join (shlex .quote (arg ) for arg in function_args )
283
286
shell_notebook_id = subprocess .run (
284
- f"""source { shell_script_path } && { shell_function_name } { " " .join (shlex .quote (arg ) for arg in args )} """ ,
287
+ # set temporary positional parameters for the `source`ing
288
+ f"""set -- { script_args_str } && source { shell_script_path } && set -- && { shell_function_name } { function_args_str } """ ,
285
289
shell = True ,
286
290
executable = "/bin/bash" ,
287
291
env = env ,
@@ -300,6 +304,7 @@ def get_targets() -> Generator[tuple[str, Path], None, None]:
300
304
python_311 = gen_gha_matrix_jobs .extract_image_targets (ROOT_DIR , env = {"RELEASE_PYTHON_VERSION" : "3.11" })
301
305
python_312 = gen_gha_matrix_jobs .extract_image_targets (ROOT_DIR , env = {"RELEASE_PYTHON_VERSION" : "3.12" })
302
306
targets = python_311 + python_312
307
+ # TODO(jdanek): this is again duplicating knowledge, but, what can I do?
303
308
expected_manifest_paths = {
304
309
"jupyter-minimal-ubi9-python-3.12" : ROOT_DIR / "manifests/base/jupyter-minimal-notebook-imagestream.yaml" ,
305
310
"runtime-minimal-ubi9-python-3.12" : ROOT_DIR / "manifests/base/jupyter-minimal-notebook-imagestream.yaml" ,
@@ -354,13 +359,15 @@ def test_compare_with_shell_implementation(self, target: str, expected_manifest_
354
359
notebook_id = self .run_shell_function (
355
360
shell_script_path ,
356
361
"_get_notebook_id" ,
362
+ script_args = [target ],
357
363
env = {"notebook_workload_name" : target },
358
364
)
359
365
assert notebook_id
360
366
361
367
source_of_truth_filepath = self .run_shell_function (
362
368
shell_script_path ,
363
369
"_get_source_of_truth_filepath" ,
364
- [notebook_id ],
370
+ script_args = [target ],
371
+ function_args = [notebook_id ],
365
372
)
366
373
assert source_of_truth_filepath == str (expected_manifest_path )
0 commit comments