diff options
| -rw-r--r-- | README.md | 37 | ||||
| -rw-r--r-- | minishell_test/__init__.py | 1 | ||||
| -rw-r--r-- | minishell_test/args.py | 19 | ||||
| -rw-r--r-- | minishell_test/suite/decorator.py | 4 | ||||
| -rw-r--r-- | minishell_test/suite/suite.py | 12 | ||||
| -rw-r--r-- | minishell_test/suites/flow.py | 4 | ||||
| -rw-r--r-- | minishell_test/suites/path.py | 8 | ||||
| -rw-r--r-- | minishell_test/test/captured.py | 8 | ||||
| -rw-r--r-- | minishell_test/test/result.py | 20 | ||||
| -rw-r--r-- | minishell_test/test/test.py | 4 | ||||
| -rw-r--r-- | requirements.txt | 3 | ||||
| -rw-r--r-- | setup.cfg | 10 |
12 files changed, 67 insertions, 63 deletions
@@ -4,6 +4,22 @@ Test for the minishell project of school 42.  +## Installation + +### pip + +``` +$ pip3 install minishell-test +``` + +### Manual + +``` +$ git clone https://github.com/cacharle/minishell_test +$ cd minishell_test +$ pip3 install -e minishell_test +``` + ## Usage The default path to your project is `../minishell` but you can change it the the [configuration](src/config.py). @@ -12,16 +28,9 @@ The default path to your project is `../minishell` but you can change it the the $ ./run # run all tests $ ./run --help -usage: run [-h] [-k] [-x] [-r BEGIN END] [--show-range] [-v] [-b] [-n] [-l] - [-m] [-p] - [suite [suite ...]] +usage: run [-h] [-k] [-r BEGIN END] [--show-range] [-x] [-v] [-b] [-n] [-l] [-m] [-g] [suite ...] -___ ____ _ _ _ _ _ _ -| \/ (_) (_) | | | | | | | | | -| . . |_ _ __ _ ___| |__ ___| | | | |_ ___ ___| |_ -| |\/| | | '_ \| / __| '_ \ / _ \ | | | __/ _ \/ __| __| -| | | | | | | | \__ \ | | | __/ | | | || __/\__ \ |_ -\_| |_/_|_| |_|_|___/_| |_|\___|_|_| \__\___||___/\__| +Test for the minishell project of school 42. positional arguments: suite Test suites/group to run. @@ -31,20 +40,20 @@ positional arguments: optional arguments: -h, --help show this help message and exit -k, --check-leaks Run valgrind on tests (disable usual comparison with bash) - -x, --exit-first Exit on first fail -r BEGIN END, --range BEGIN END Range of test index to run (imply --show-index) --show-range Show test index (useful with --range) + -x, --exit-first Exit on first fail -v, --verbose Increase verbosity level (e.g -vv == 2) -b, --bonus Enable bonus tests -n, --no-bonus Disable bonus tests -l, --list Print available test suites -m, --make Make minishell and exit - -p, --pager After running the test, display the result in a pager of your choice + -g, --pager After running the test, display the result in a pager of your choice -Signal handling is not tested -There is a commented glob suite in src/suites/preprocess.py. -Good luck handling `*'.*'`. +Made by cacharle +https://github.com/cacharle +https://cacharle.xyz ``` ## Test compatibility diff --git a/minishell_test/__init__.py b/minishell_test/__init__.py index 8b13789..e69de29 100644 --- a/minishell_test/__init__.py +++ b/minishell_test/__init__.py @@ -1 +0,0 @@ - diff --git a/minishell_test/args.py b/minishell_test/args.py index b7fcca6..fb12841 100644 --- a/minishell_test/args.py +++ b/minishell_test/args.py @@ -6,7 +6,7 @@ # 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 # +# Updated: 2021/02/05 17:14:41 by charles ### ########.fr # # # # ############################################################################ # @@ -18,19 +18,12 @@ def parse_args(): """Parse command line arguments""" parser = argparse.ArgumentParser( - description=textwrap.dedent(r""" - ___ ____ _ _ _ _ _ _ - | \/ (_) (_) | | | | | | | | | - | . . |_ _ __ _ ___| |__ ___| | | | |_ ___ ___| |_ - | |\/| | | '_ \| / __| '_ \ / _ \ | | | __/ _ \/ __| __| - | | | | | | | | \__ \ | | | __/ | | | || __/\__ \ |_ - \_| |_/_|_| |_|_|___/_| |_|\___|_|_| \__\___||___/\__| - """), + description="Test for the minishell project of school 42.", 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 `*'.*'`. + epilog=textwrap.dedent(""" + Made by cacharle + https://github.com/cacharle + https://cacharle.xyz """) ) parser.add_argument( diff --git a/minishell_test/suite/decorator.py b/minishell_test/suite/decorator.py index a843bc4..45f96b6 100644 --- a/minishell_test/suite/decorator.py +++ b/minishell_test/suite/decorator.py @@ -6,7 +6,7 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:28:00 by charles #+# #+# # -# Updated: 2021/02/05 14:50:41 by charles ### ########.fr # +# Updated: 2021/02/05 17:44:25 by charles ### ########.fr # # # # ############################################################################ # @@ -26,7 +26,7 @@ def suite(groups: List[str] = [], bonus: bool = False): # type: ignore mod = inspect.getmodule(origin) if mod is None: raise NotImplementedError - mod_name = mod.__name__[len("suites."):] + mod_name = mod.__name__[len("minishell_test.suites."):] name = "{}/{}".format(mod_name, origin.__name__[len("suite_"):]) description = origin.__doc__ if description is None: diff --git a/minishell_test/suite/suite.py b/minishell_test/suite/suite.py index df342a0..8fd39bf 100644 --- a/minishell_test/suite/suite.py +++ b/minishell_test/suite/suite.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:29 by charles #+# #+# # -# Updated: 2021/02/05 14:24:36 by charles ### ########.fr # +# Updated: 2021/02/05 18:01:33 by charles ### ########.fr # # # # ############################################################################ # @@ -44,9 +44,9 @@ class Suite: names.append(name) continue matches = [n for n in suite_names - if n.find("/") != -1 - and n[n.find("/") + 1:].startswith(name) - or n.startswith(name)] + if n.find("/") != -1 and + n[n.find("/") + 1:].startswith(name) or + n.startswith(name)] if len(matches) == 1: names.append(matches[0]) elif len(matches) != 0 and all(n.startswith(name) for n in matches): @@ -63,8 +63,8 @@ class Suite: sys.exit(1) cls.available = list(set( - [s for s in cls.available if s.name in names] - + [s for s in cls.available if any(g for g in s.groups if g in names)] + [s for s in cls.available if s.name in names] + + [s for s in cls.available if any(g for g in s.groups if g in names)] )) cls.available.sort(key=lambda s: s.name) for s in cls.available: diff --git a/minishell_test/suites/flow.py b/minishell_test/suites/flow.py index 90aef7f..ed5fd03 100644 --- a/minishell_test/suites/flow.py +++ b/minishell_test/suites/flow.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:52 by charles #+# #+# # -# Updated: 2021/02/05 15:11:21 by charles ### ########.fr # +# Updated: 2021/02/05 17:40:00 by charles ### ########.fr # # # # ############################################################################ # @@ -20,6 +20,7 @@ from minishell_test.hooks import ( error_eof_to_expected_token ) + @suite() def suite_end(test): """ `;` tests """ @@ -58,6 +59,7 @@ def suite_end(test): test("ls " + 40 * " ; ls" + ";", setup="touch a b c") test("ls " + 80 * " ; ls" + ";", setup="touch a b c") + @suite() def suite_pipe(test): """ `|` tests """ diff --git a/minishell_test/suites/path.py b/minishell_test/suites/path.py index b350168..fa67d9a 100644 --- a/minishell_test/suites/path.py +++ b/minishell_test/suites/path.py @@ -6,7 +6,7 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/09 15:12:58 by charles #+# #+# # -# Updated: 2021/02/05 14:50:19 by charles ### ########.fr # +# Updated: 2021/02/05 17:47:32 by charles ### ########.fr # # # # ############################################################################ # @@ -22,9 +22,9 @@ def suite_path(test): if whoami_path is None: print("Couldn't find `whoami` in your PATH: Skipping suite") return - mode_fmt = ("mkdir path && cp " - + whoami_path - + " ./path/a && chmod {} ./path/a") + mode_fmt = ("mkdir path && cp " + + whoami_path + + " ./path/a && chmod {} ./path/a") test("a", setup=mode_fmt.format("000"), exports={"PATH": "path"}) test("a", setup=mode_fmt.format("001"), exports={"PATH": "path"}) test("a", setup=mode_fmt.format("002"), exports={"PATH": "path"}) diff --git a/minishell_test/test/captured.py b/minishell_test/test/captured.py index d24bcdf..7db9739 100644 --- a/minishell_test/test/captured.py +++ b/minishell_test/test/captured.py @@ -6,7 +6,7 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:16:25 by charles #+# #+# # -# Updated: 2021/02/05 14:55:31 by charles ### ########.fr # +# Updated: 2021/02/05 17:47:10 by charles ### ########.fr # # # # ############################################################################ # @@ -46,9 +46,9 @@ class Captured: raise NotImplementedError if self.is_timeout: return self.is_timeout == other.is_timeout - return (self.output == other.output - and self.status == other.status - and all(x == y for x, y in zip(self.files_content, other.files_content))) + return (self.output == other.output and + self.status == other.status and + all(x == y for x, y in zip(self.files_content, other.files_content))) @staticmethod def timeout(): diff --git a/minishell_test/test/result.py b/minishell_test/test/result.py index ec0f192..9769527 100644 --- a/minishell_test/test/result.py +++ b/minishell_test/test/result.py @@ -6,7 +6,7 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:17:34 by charles #+# #+# # -# Updated: 2021/02/05 14:55:23 by charles ### ########.fr # +# Updated: 2021/02/05 17:46:30 by charles ### ########.fr # # # # ############################################################################ # @@ -168,11 +168,11 @@ class Result(BaseResult): return "" file_header = self.indicator("FILE {}".format(file_name), "|#") + '\n' return ( - file_header - + self.expected_header - + self.cat_e(expected) - + self.actual_header - + self.cat_e(actual) + file_header + + self.expected_header + + self.cat_e(expected) + + self.actual_header + + self.cat_e(actual) ) def files_diff(self): @@ -194,10 +194,10 @@ class Result(BaseResult): .format(self.expected.status, self.actual.status), "| " ) + '\n' if self.expected.output != self.actual.output: - out += (self.expected_header - + self.cat_e(self.expected.output) - + self.actual_header - + self.cat_e(self.actual.output)) + out += (self.expected_header + + self.cat_e(self.expected.output) + + self.actual_header + + self.cat_e(self.actual.output)) return out def full_diff(self) -> str: diff --git a/minishell_test/test/test.py b/minishell_test/test/test.py index a6305b9..7b6a118 100644 --- a/minishell_test/test/test.py +++ b/minishell_test/test/test.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/06/16 21:48:50 by charles #+# #+# # -# Updated: 2021/02/05 14:42:26 by charles ### ########.fr # +# Updated: 2021/02/05 17:39:44 by charles ### ########.fr # # # # ############################################################################ # @@ -20,7 +20,7 @@ from minishell_test.test.captured import Captured from minishell_test.test.result import Result, LeakResult import minishell_test.sandbox as sandbox -HookType = Union[Callable[[str], str], List[Callable[[str], str]]] +HookType = Union[Callable[[str], str], List[Callable[[str], str]]] HookStatusType = Union[Callable[[int], int], List[Callable[[int], int]]] diff --git a/requirements.txt b/requirements.txt index eefaf4e..bf40793 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,3 @@ mypy==0.800 flake8==3.8.4 flake8_comprehensions==3.3.1 pep8_naming==0.11.1 -flake8-expression-complexity -flake8-isort -flake8-cognitive-complexity @@ -12,15 +12,19 @@ maintainer = Charles Cabergs maintainer_email = me@cacharle.xyz url = https://github.com/cacharle/minishell_test classifiers = - Intended Audience :: Developers Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Intended Audience :: Developers + Environment :: Console + License :: OSI Approved :: GNU General Public License v2 (GPLv2) Operating System :: MacOS Operating System :: POSIX :: Linux [options] +package_dir= + =minishell_test packages = find: python_requires = >=3.6 @@ -28,8 +32,8 @@ python_requires = >=3.6 # where = minishell_test [flake8] -ignore = E501,E221,W503,E241 -select = E,F,W,C4,N,ECE,CCR +ignore = E501,E221,W504,E241 +select = E,F,W,C4,N max-cognitive-complexity = 6 [mypy] |
