diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-02-05 12:27:32 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-02-05 12:27:32 +0100 |
| commit | 904a033ae738e1c351f8fef71e2ec2418fc4db3d (patch) | |
| tree | 3de4980582c109c4f0d19111a2b88eafec9b9b36 /minishell_test/args.py | |
| parent | a3e983f78dc4cbcf6f75f78fa2b3c57e09cd1b2b (diff) | |
| download | minishell_test-904a033ae738e1c351f8fef71e2ec2418fc4db3d.tar.gz minishell_test-904a033ae738e1c351f8fef71e2ec2418fc4db3d.tar.bz2 minishell_test-904a033ae738e1c351f8fef71e2ec2418fc4db3d.zip | |
Renaming src -> minishell_test for package name, Renaming main.py -> __main__.py for package execution with python -m
Diffstat (limited to 'minishell_test/args.py')
| -rw-r--r-- | minishell_test/args.py | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/minishell_test/args.py b/minishell_test/args.py new file mode 100644 index 0000000..b7fcca6 --- /dev/null +++ b/minishell_test/args.py @@ -0,0 +1,87 @@ +# ############################################################################ # +# # +# ::: :::::::: # +# args.py :+: :+: :+: # +# +:+ +:+ +:+ # +# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2020/07/15 18:24:32 by charles #+# #+# # +# Updated: 2021/01/11 22:20:16 by charles ### ########.fr # +# # +# ############################################################################ # + +import argparse +import textwrap + + +def parse_args(): + """Parse command line arguments""" + + parser = argparse.ArgumentParser( + description=textwrap.dedent(r""" + ___ ____ _ _ _ _ _ _ + | \/ (_) (_) | | | | | | | | | + | . . |_ _ __ _ ___| |__ ___| | | | |_ ___ ___| |_ + | |\/| | | '_ \| / __| '_ \ / _ \ | | | __/ _ \/ __| __| + | | | | | | | | \__ \ | | | __/ | | | || __/\__ \ |_ + \_| |_/_|_| |_|_|___/_| |_|\___|_|_| \__\___||___/\__| + """), + formatter_class=argparse.RawTextHelpFormatter, + epilog=textwrap.dedent("""\ + Signal handling is not tested + There is a commented glob suite in src/suites/preprocess.py. + Good luck handling `*'.*'`. + """) + ) + parser.add_argument( + "-k", "--check-leaks", action="store_true", + help="Run valgrind on tests (disable usual comparison with bash)" + ) + parser.add_argument( + "-r", "--range", nargs=2, type=int, metavar=("BEGIN", "END"), + help="Range of test index to run (imply --show-index)" + ) + parser.add_argument( + "--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)" + ) + parser.add_argument( + "-b", "--bonus", action="store_true", + help="Enable bonus tests" + ) + parser.add_argument( + "-n", "--no-bonus", action="store_true", + help="Disable bonus tests" + ) + parser.add_argument( + "-l", "--list", action="store_true", + help="Print available test suites" + ) + parser.add_argument( + "-m", "--make", action="store_true", + help="Make minishell and exit" + ) + parser.add_argument( + "-g", "--pager", action="store_true", + help="After running the test, display the result in a pager of your choice" + ) + parser.add_argument( + "suites", nargs='*', metavar="suite", + help=textwrap.dedent("""\ + Test suites/group to run. + It tries to be smart and autocomplete the suite name + (e.g ./run int -> ./run preprocess/interpolation) + """) + ) + tmp = parser.parse_args() + if tmp.verbose is None: + tmp.verbose = 1 + return tmp |
