Skip to content

Commit 2cd4a23

Browse files
committed
more test fixes related to permissions
1 parent c798656 commit 2cd4a23

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

geojson_modelica_translator/modelica/modelica_runner.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,8 @@ def _docker_post_run_permissions_command(self) -> str:
8484
"""Return shell commands that make Docker-created outputs editable by the host user."""
8585
return (
8686
'if [[ -n "${HOST_UID:-}" && -n "${HOST_GID:-}" ]]; then '
87-
'for output_dir in "$PWD"/*_results; do '
88-
'if [[ -e "$output_dir" ]]; then '
89-
'chown -R "$HOST_UID:$HOST_GID" "$output_dir" 2>/dev/null || true ; '
90-
'chmod -R u+rwX "$output_dir" 2>/dev/null || true ; '
91-
"fi ; "
92-
"done ; "
87+
'chown -R "$HOST_UID:$HOST_GID" "$PWD" 2>/dev/null || true ; '
88+
'chmod -R u+rwX "$PWD" 2>/dev/null || true ; '
9389
"fi"
9490
)
9591

tests/modelica/test_modelica_runner.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ def test_docker_command_restores_permissions_after_failed_omc(self):
8787
assert exec_call[exec_call.index("-w") + 1] == f"/mnt/shared/{Path(self.run_path).name}"
8888
assert exec_call[-4:] == ["--", "simulate", "flag1", "flag2"]
8989
assert 'omc "$1.mos" "${@:2}" ; ret=$? ;' in script
90-
assert 'for output_dir in "$PWD"/*_results; do' in script
91-
assert 'chown -R "$HOST_UID:$HOST_GID" "$output_dir"' in script
92-
assert 'chmod -R u+rwX "$output_dir"' in script
90+
assert 'chown -R "$HOST_UID:$HOST_GID" "$PWD"' in script
91+
assert 'chmod -R u+rwX "$PWD"' in script
9392
assert 'chmod -R a+rwX "$PWD"' not in script
9493
assert len(run_calls) == 1
9594

@@ -124,8 +123,8 @@ def test_docker_interrupt_restores_permissions_before_exiting(self):
124123
cleanup_script = cleanup_call[cleanup_call.index("-c") + 1]
125124
assert "--rm" in cleanup_call
126125
assert cleanup_call[cleanup_call.index("-w") + 1] == f"/mnt/shared/{Path(self.run_path).name}"
127-
assert 'for output_dir in "$PWD"/*_results; do' in cleanup_script
128-
assert 'chown -R "$HOST_UID:$HOST_GID" "$output_dir"' in cleanup_script
126+
assert 'chown -R "$HOST_UID:$HOST_GID" "$PWD"' in cleanup_script
127+
assert 'chmod -R u+rwX "$PWD"' in cleanup_script
129128

130129
@pytest.mark.compilation
131130
def test_compile_bouncing_ball_in_docker(self):

0 commit comments

Comments
 (0)