From 7081b93b8ed4f98c628400e05d22d0523f41a842 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 27 Feb 2021 12:24:37 +0100 Subject: Fixing #16 - Adding support for custom config file in user directory --- minishell_test/hooks.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'minishell_test/hooks.py') diff --git a/minishell_test/hooks.py b/minishell_test/hooks.py index 9881354..dbbd975 100644 --- a/minishell_test/hooks.py +++ b/minishell_test/hooks.py @@ -6,15 +6,14 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 16:10:20 by charles #+# #+# # -# Updated: 2021/02/05 15:13:30 by charles ### ########.fr # +# Updated: 2021/02/27 12:09:25 by cacharle ### ########.fr # # # # ############################################################################ # import re -import sys import os -import minishell_test.config as config +from minishell_test import config def sort_lines(output): @@ -31,7 +30,7 @@ def error_line0(output): lines = output.split('\n') if len(lines) != 3: return output - prefix = "{}: -c: line 0: ".format(config.REFERENCE_PATH) + prefix = "{}: -c: line 0: ".format(config.SHELL_REFERENCE_PATH) if lines[0].find(prefix) != 0: return output return lines[0].replace(prefix, "minishell: ") + "\n" @@ -44,7 +43,7 @@ def discard(output): def export_singleton(output): """Remove variable that are not set to anything in a call to export without arguments""" - prefix = "export " if ("--posix" in config.REFERENCE_ARGS) else "declare -x " + prefix = "export " if ("--posix" in config.SHELL_REFERENCE_ARGS) else "declare -x " return sort_lines( '\n'.join([line for line in output.split('\n') if re.match("^{}[a-zA-Z]+$".format(prefix), line) is None]) @@ -63,20 +62,16 @@ def replace_double_semi_colon(output): def platform_status(darwin_status, linux_status, windows_status=None): def hook(status): - if config.PLATFORM == "Darwin": + if config.PLATFORM == "darwin": return status - elif config.PLATFORM == "Linux": + elif config.PLATFORM == "linux": return (darwin_status if status == linux_status else status) - else: - raise RuntimeError("This platform exit codes are not supported yet," - "feel free to contact me to add it.") - sys.exit(2) return status return hook def is_directory(output): - if config.PLATFORM == "Linux": + if config.PLATFORM == "linux": return output.replace("Is a directory", "is a directory") else: return output @@ -88,14 +83,14 @@ def is_directory(output): def shlvl_0_to_1(output): - if config.PLATFORM == "Linux": + if config.PLATFORM == "linux": return output.replace("SHLVL=0", "SHLVL=1") else: return output def delete_escape(output): - if config.PLATFORM == "Linux": + if config.PLATFORM == "linux": return output.replace("\\", "") else: return output @@ -109,7 +104,7 @@ def error_eof_to_expected_token(output): def linux_discard(output): - if config.PLATFORM == "Linux": + if config.PLATFORM == "linux": return "DISCARDED BY MINISHELL TEST" else: return output -- cgit From c92f2be21c6be2d44cd836dd7f362e545b9a1a90 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 27 Feb 2021 14:46:21 +0100 Subject: Added make_args and check_error_messages configuration options --- minishell_test/hooks.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'minishell_test/hooks.py') diff --git a/minishell_test/hooks.py b/minishell_test/hooks.py index dbbd975..531580a 100644 --- a/minishell_test/hooks.py +++ b/minishell_test/hooks.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 16:10:20 by charles #+# #+# # -# Updated: 2021/02/27 12:09:25 by cacharle ### ########.fr # +# Updated: 2021/02/27 14:44:19 by cacharle ### ########.fr # # # # ############################################################################ # @@ -22,9 +22,8 @@ def sort_lines(output): def error_line0(output): - """Replace "/bin/bash: -c: line 0:" by "minishell:" and delete the second line""" - error_message = os.environ.get("MINISHELL_TEST_DONT_CHECK_ERROR_MESSAGE") - if error_message is not None and error_message == "yes": + """Replace "/bin/bash: -c: line n:" by "minishell:" and delete the second line""" + if not config.CHECK_ERROR_MESSAGES: return "DISCARDED BY TEST" lines = output.split('\n') -- cgit From 0cf5f137f886bd4e80868dcf2cf74b3f3b2c28d3 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 27 Feb 2021 15:43:07 +0100 Subject: Fixing #10 - bash error line with number 0 or 1 --- minishell_test/hooks.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'minishell_test/hooks.py') diff --git a/minishell_test/hooks.py b/minishell_test/hooks.py index 531580a..6356080 100644 --- a/minishell_test/hooks.py +++ b/minishell_test/hooks.py @@ -6,12 +6,11 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 16:10:20 by charles #+# #+# # -# Updated: 2021/02/27 14:44:19 by cacharle ### ########.fr # +# Updated: 2021/02/27 15:40:25 by cacharle ### ########.fr # # # # ############################################################################ # import re -import os from minishell_test import config @@ -29,10 +28,10 @@ def error_line0(output): lines = output.split('\n') if len(lines) != 3: return output - prefix = "{}: -c: line 0: ".format(config.SHELL_REFERENCE_PATH) - if lines[0].find(prefix) != 0: + prefix = config.SHELL_REFERENCE_PREFIX + "-c: " + if not lines[0].startswith(prefix): return output - return lines[0].replace(prefix, "minishell: ") + "\n" + return lines[0].replace(prefix, config.MINISHELL_PREFIX, 1) + "\n" def discard(output): -- cgit