Add tests for code/shell execution & improve config fixture (#1268)

Co-authored-by: Reinier van der Leer <github@pwuts.nl>
This commit is contained in:
rickythefox
2023-04-28 14:51:29 +02:00
committed by GitHub
parent 1772a01d04
commit 20ef130341
3 changed files with 61 additions and 18 deletions

View File

@@ -113,15 +113,9 @@ def execute_shell(command_line: str) -> str:
str: The output of the command
"""
if not CFG.execute_local_commands:
return (
"You are not allowed to run local shell commands. To execute"
" shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' "
"in your config. Do not attempt to bypass the restriction."
)
current_dir = os.getcwd()
current_dir = Path.cwd()
# Change dir into workspace if necessary
if CFG.workspace_path not in current_dir:
if not current_dir.is_relative_to(CFG.workspace_path):
os.chdir(CFG.workspace_path)
print(f"Executing command '{command_line}' in working directory '{os.getcwd()}'")
@@ -154,6 +148,7 @@ def execute_shell_popen(command_line) -> str:
Returns:
str: Description of the fact that the process started and its id
"""
current_dir = os.getcwd()
# Change dir into workspace if necessary
if CFG.workspace_path not in current_dir: