Skip to content

Commit

Permalink
fix: run scripts fix list of string
Browse files Browse the repository at this point in the history
  • Loading branch information
k4black committed Feb 6, 2024
1 parent 957f69e commit 8ec62d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion checker/plugins/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ def set_up_env_sandbox() -> None: # pragma: nocover
for variable in args.env_whitelist:
os.environ[variable] = env[variable]

if isinstance(args.script, list):
safe_shell_script = " ".join(args.script)
else:
safe_shell_script = args.script

try:
result = subprocess.run(
args.script,
safe_shell_script,
shell=True,
cwd=args.origin,
timeout=args.timeout, # kill process after timeout, raise TimeoutExpired
Expand Down
3 changes: 3 additions & 0 deletions tests/plugins/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ def test_plugin_args(self, parameters: dict[str, Any], expected_exception: Excep
"script, output, expected_exception",
[
("echo Hello", "Hello", None),
(["echo", "Hello"], "Hello", None),
("sleep 0.1", "", None),
(["sleep", "0.1"], "", None),
("true", "", None),
("false", "", PluginExecutionFailed),
("echo Hello && false", "Hello", PluginExecutionFailed),
(["echo", "Hello", "&&", "false"], "Hello", PluginExecutionFailed),
],
)
def test_simple_cases(self, script: str, output: str, expected_exception: Exception | None) -> None:
Expand Down

0 comments on commit 8ec62d0

Please sign in to comment.