diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-09-10 15:07:30 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-09-10 15:07:30 +0200 |
| commit | c0b1a90cf9c52a0c9b1623ac695516031d5ccdba (patch) | |
| tree | b286ff19de9e57eb1948f751072f09dc3e79f8fc | |
| parent | 2de1bf6e7dbda85ca3bb4ad77edac611a04b1ae3 (diff) | |
| download | minishell_test-c0b1a90cf9c52a0c9b1623ac695516031d5ccdba.tar.gz minishell_test-c0b1a90cf9c52a0c9b1623ac695516031d5ccdba.tar.bz2 minishell_test-c0b1a90cf9c52a0c9b1623ac695516031d5ccdba.zip | |
Updated README, Added auto build
| -rw-r--r-- | README.md | 22 | ||||
| -rw-r--r-- | args.py | 6 | ||||
| -rw-r--r-- | config.py | 5 | ||||
| -rwxr-xr-x | minishell_test | 3 | ||||
| -rwxr-xr-x | run (renamed from main.py) | 19 | ||||
| -rw-r--r-- | suites/cmd.py | 4 |
6 files changed, 35 insertions, 24 deletions
@@ -4,12 +4,12 @@ Test for the minishell project of school 42.  -# Usage +## Usage The default path to your project is `..` but you can change it the the [configuration](config.py). -* `> ./main.py --help` -* `> ./main.py` +* `> ./run --help` +* `> ./run` ## Test compatibility @@ -27,17 +27,19 @@ README.md test.sh README.md test.sh ``` -The reasons for this: -1. You're free to set the prompt to whatever you want -2. Termcaps would be a nightmare to test +This allows you to set the prompt to whatever you want. -# Configuration +## Python Version + +This test works with python >= 3.4. The timeout detection only works with python >= 3.8. + +## Configuration The default configuration can be changed in [config.py](config.py) -# Add new tests +## Add new tests -## Add individual test +### Add individual test In your suite function you can use the `test` function. With the following arguments: @@ -55,7 +57,7 @@ test("cat < somefile > otherfile", files=["otherfile"]) ``` -## Add Suite +### Add Suite A test suite is a group of related tests. @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:32 by charles #+# #+# # -# Updated: 2020/09/09 15:17:58 by charles ### ########.fr # +# Updated: 2020/09/10 13:52:37 by charles ### ########.fr # # # # ############################################################################ # @@ -23,8 +23,8 @@ def parse_args(): help="increase verbosity level (e.g -vv == 2)" ) parser.add_argument( - "-g", "--generate", metavar="NUMBER", type=int, - help="number of new random test to generate" + "-b", "--build", action="store_true", + help="build minishell and exit" ) parser.add_argument( "-l", "--list", action="store_true", @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:19 by charles #+# #+# # -# Updated: 2020/07/19 20:29:52 by charles ### ########.fr # +# Updated: 2020/09/10 13:54:27 by charles ### ########.fr # # # # ############################################################################ # @@ -19,6 +19,9 @@ MINISHELL_DIR = ".." # minishell executable MINISHELL_EXEC = "minishell" +# build minishell before executing the test if set to True +MINISHELL_BUILD = True + # path to reference shell (shell which will be compared minishell) # has to support the -c option (sh, bash and zsh support it) REFERENCE_PATH = "/bin/bash" diff --git a/minishell_test b/minishell_test deleted file mode 100755 index 8a418ed..0000000 --- a/minishell_test +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -python3 ./main.py $@ @@ -16,6 +16,7 @@ import os import sys import shutil import distutils.spawn +import subprocess import config from args import parse_args @@ -29,6 +30,19 @@ import suites.status import suites.path def main(): + args = parse_args() + if args.list: + print("The available suites are:") + print('\n'.join([" - " + s.name for s in Suite.available])) + sys.exit(0) + + if config.MINISHELL_BUILD or args.build: + try: + subprocess.run(["make", "-C", config.MINISHELL_DIR], check=True) + except subprocess.CalledProcessError: + sys.exit(1) + if args.build: + sys.exit(0) if os.path.exists(config.EXECUTABLES_PATH): shutil.rmtree(config.EXECUTABLES_PATH) os.mkdir(config.EXECUTABLES_PATH) @@ -36,11 +50,6 @@ def main(): shutil.copy(distutils.spawn.find_executable(cmd), # FIXME search whole PATH os.path.join(config.EXECUTABLES_PATH, cmd)) - args = parse_args() - if args.list: - print("The available suites are:") - print('\n'.join([" - " + s.name for s in Suite.available])) - sys.exit(0) config.VERBOSE_LEVEL = args.verbose Suite.setup(args.suites) diff --git a/suites/cmd.py b/suites/cmd.py index a2738b5..1302ae3 100644 --- a/suites/cmd.py +++ b/suites/cmd.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 15:11:46 by charles #+# #+# # -# Updated: 2020/07/19 18:55:52 by charles ### ########.fr # +# Updated: 2020/09/10 14:25:40 by charles ### ########.fr # # # # ############################################################################ # @@ -89,7 +89,7 @@ def suite_redirection(test): test("echo foo >>>> bar") test("echo foo >>>>> bar") - test("cat <<< bar", setup="echo bonjour > bar") + test("cat << < bar", setup="echo bonjour > bar") test("cat <<<< bar", setup="echo bonjour > bar") test("cat <<<<< bar", setup="echo bonjour > bar") |
