From a36a27b8ca85adf57b2a9926a53e74e3a3863d3d Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sun, 11 Oct 2020 15:38:53 +0200 Subject: Added leak verbose --- src/args.py | 20 +++++++++++++++----- src/config.py | 7 ++++++- src/prompt.py | 0 src/test/captured.py | 7 ++++++- src/test/result.py | 4 ++-- src/test/test.py | 4 +++- 6 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 src/prompt.py (limited to 'src') diff --git a/src/args.py b/src/args.py index 5473711..289083b 100644 --- a/src/args.py +++ b/src/args.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:32 by charles #+# #+# # -# Updated: 2020/10/09 10:58:47 by cacharle ### ########.fr # +# Updated: 2020/10/10 14:26:20 by cacharle ### ########.fr # # # # ############################################################################ # @@ -18,7 +18,7 @@ def parse_args(): """Parse command line arguments""" parser = argparse.ArgumentParser( - description=textwrap.dedent(r"""\ + description=textwrap.dedent("""\ ___ ____ _ _ _ _ _ _ | \/ (_) (_) | | | | | | | | | | . . |_ _ __ _ ___| |__ ___| | | | |_ ___ ___| |_ @@ -38,8 +38,14 @@ def parse_args(): help="Run valgrind on tests (disable usual comparison with bash)" ) parser.add_argument( - "-x", "--exit-first", action="store_true", - help="Exit on first fail" + "-p", "--prompt", + help=textwrap.dedent("""\ + The format of your prompt, the available format are: + - abs_path: absolute path to the current directory + - base_path: last directory of the path to the current directory + - username: current user + You can also the the environment variable MINISHELL_TEST_PROMPT. + """) ) parser.add_argument( "-r", "--range", nargs=2, type=int, metavar=("BEGIN", "END"), @@ -49,6 +55,10 @@ def parse_args(): "--show-range", action="store_true", help="Show test index (useful with --range)" ) + parser.add_argument( + "-x", "--exit-first", action="store_true", + help="Exit on first fail" + ) parser.add_argument( "-v", "--verbose", action="count", help="Increase verbosity level (e.g -vv == 2)" @@ -70,7 +80,7 @@ def parse_args(): help="Make minishell and exit" ) parser.add_argument( - "-p", "--pager", action="store_true", + "-g", "--pager", action="store_true", help="After running the test, display the result in a pager of your choice" ) parser.add_argument( diff --git a/src/config.py b/src/config.py index 561cbb9..a7001e7 100644 --- a/src/config.py +++ b/src/config.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:19 by charles #+# #+# # -# Updated: 2020/10/08 08:47:39 by cacharle ### ########.fr # +# Updated: 2020/10/10 14:22:02 by cacharle ### ########.fr # # # # ############################################################################ # @@ -22,6 +22,11 @@ import distutils.spawn # can be changed with `export MINISHELL_TEST_BONUS=yes` in your shell rc file. BONUS = False +# Your prompt (string that will be ignored) +# ./run -h to show the available format +# Create a new issue if your type of prompt isn't supported +PROMPT = None + # minishell dir path MINISHELL_DIR = ".." diff --git a/src/prompt.py b/src/prompt.py new file mode 100644 index 0000000..e69de29 diff --git a/src/test/captured.py b/src/test/captured.py index 4a9966d..15ef3f7 100644 --- a/src/test/captured.py +++ b/src/test/captured.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:16:25 by charles #+# #+# # -# Updated: 2020/10/07 18:25:05 by cacharle ### ########.fr # +# Updated: 2020/10/11 08:44:36 by cacharle ### ########.fr # # # # ############################################################################ # @@ -21,8 +21,13 @@ class Captured: files_content: content of the files altered by the command is_timeout: the command has timed out """ + # if config.PROMPT_OBJECT is not None: + # output = output.replace(config.PROMPT_OBJECT + "\n", "") + # output = output.replace(config.PROMPT_OBJECT, "") lines = output.split('\n') for i, l in enumerate(lines): + # if l.find(config.PROMPT_OBJECT) == 0: + # l.replace(config.PROMPT_OBJECT, "") if l.find(config.REFERENCE_ERROR_BEGIN) == 0: lines[i] = l.replace(config.REFERENCE_ERROR_BEGIN, config.MINISHELL_ERROR_BEGIN, 1) elif l.find(config.REFERENCE_PATH + ": ") == 0: diff --git a/src/test/result.py b/src/test/result.py index 55cda54..e651e49 100644 --- a/src/test/result.py +++ b/src/test/result.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:17:34 by charles #+# #+# # -# Updated: 2020/10/09 11:04:16 by cacharle ### ########.fr # +# Updated: 2020/10/11 14:09:24 by cacharle ### ########.fr # # # # ############################################################################ # @@ -98,7 +98,7 @@ class Result: elif config.VERBOSE_LEVEL == 2: return self.full_diff() else: - raise RuntimeError + raise RuntimeError("Invalid verbose level") def put(self, index: int): """Print a summary of the result""" diff --git a/src/test/test.py b/src/test/test.py index b487f10..238ba66 100644 --- a/src/test/test.py +++ b/src/test/test.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/06/16 21:48:50 by charles #+# #+# # -# Updated: 2020/10/09 11:00:57 by cacharle ### ########.fr # +# Updated: 2020/10/11 14:09:04 by cacharle ### ########.fr # # # # ############################################################################ # @@ -61,6 +61,8 @@ class Test: self.hook = [] self.hook_status = [] captured = self._run_sandboxed([*config.VALGRIND_CMD, "-c"]) + if config.VERBOSE_LEVEL == 2: + print(captured.output) self.result = Result.leak(self.full_cmd, captured.output) self.result.put(index) return -- cgit