aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-06-16 19:35:49 +0200
committerCharles <sircharlesaze@gmail.com>2020-06-16 19:35:49 +0200
commit2ac2df38b1d812f5ef25a4d9a9f25143005b82b8 (patch)
tree3e6b794b393a0a9a586e1b03799ac66999ec8c65 /utils.py
parentf7571404f308d889dc0e7baf1edea3774b8e45f5 (diff)
downloadminishell_test-2ac2df38b1d812f5ef25a4d9a9f25143005b82b8.tar.gz
minishell_test-2ac2df38b1d812f5ef25a4d9a9f25143005b82b8.tar.bz2
minishell_test-2ac2df38b1d812f5ef25a4d9a9f25143005b82b8.zip
Added test for interpolation, glob and escape
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/utils.py b/utils.py
index 4c0cff3..0a6539b 100644
--- a/utils.py
+++ b/utils.py
@@ -88,7 +88,7 @@ def put_result(passed: bool, cmd: str):
print(red("{:74} [FAIL]".format(cmd)))
-def run_sandboxed(program: str, cmd: str, setup: str = None, files: [str] = []) -> str:
+def run_sandboxed(program: str, cmd: str, setup: str = None, files: [str] = [], exports: {str, str} = {}) -> str:
""" run the command in a sandbox environment, return the output (stdout and stderr) of it """
try:
@@ -109,7 +109,7 @@ def run_sandboxed(program: str, cmd: str, setup: str = None, files: [str] = [])
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE,
cwd=config.SANDBOX_PATH,
- env={'PATH': config.PATH_VARIABLE})
+ env={'PATH': config.PATH_VARIABLE, **exports})
output = process_status.stdout.decode()
output_files = []
@@ -132,11 +132,11 @@ verbose = False
def check(expected: str, actual: str, expected_files: [str], actual_files: [str]) -> bool:
return actual == expected and all([a == e for a, e in zip(actual_files, expected_files)])
-def test(cmd: str, setup: str = None, files: [str] = []):
+def test(cmd: str, setup: str = None, files: [str] = [], exports: {str, str} = {}):
""" get expected and actual strings, compare them and push them to the suites result """
- (expected, expected_files) = run_sandboxed(config.REFERENCE_SHELL_PATH, cmd, setup, files)
- (actual, actual_files) = run_sandboxed(config.MINISHELL_PATH, cmd, setup, files)
+ (expected, expected_files) = run_sandboxed(config.REFERENCE_SHELL_PATH, cmd, setup, files, exports)
+ (actual, actual_files) = run_sandboxed(config.MINISHELL_PATH, cmd, setup, files, exports)
passed = check(expected, actual, expected_files, actual_files)
global status