diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-06-16 19:35:49 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-06-16 19:35:49 +0200 |
| commit | 2ac2df38b1d812f5ef25a4d9a9f25143005b82b8 (patch) | |
| tree | 3e6b794b393a0a9a586e1b03799ac66999ec8c65 /utils.py | |
| parent | f7571404f308d889dc0e7baf1edea3774b8e45f5 (diff) | |
| download | minishell_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.py | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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 |
