aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md22
-rw-r--r--args.py6
-rw-r--r--config.py5
-rwxr-xr-xminishell_test3
-rwxr-xr-xrun (renamed from main.py)19
-rw-r--r--suites/cmd.py4
6 files changed, 35 insertions, 24 deletions
diff --git a/README.md b/README.md
index 5c07be3..bacd967 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,12 @@ Test for the minishell project of school 42.
![screenshot](./screenshot.png)
-# 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.
diff --git a/args.py b/args.py
index 358077c..2d0d57a 100644
--- a/args.py
+++ b/args.py
@@ -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",
diff --git a/config.py b/config.py
index f7b169b..e05c36b 100644
--- a/config.py
+++ b/config.py
@@ -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 $@
diff --git a/main.py b/run
index f1d4c10..a71a485 100755
--- a/main.py
+++ b/run
@@ -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")