aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-13 17:47:01 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-13 17:47:01 +0200
commit55fab322485f67112c789a4a529765b5e6635238 (patch)
tree2bd5745278b06762c0fd5bd356f80edc3d96f003
parent13fa2431ce628fbd8e64b18e40bb0eda2ae46058 (diff)
downloadminishell_test-55fab322485f67112c789a4a529765b5e6635238.tar.gz
minishell_test-55fab322485f67112c789a4a529765b5e6635238.tar.bz2
minishell_test-55fab322485f67112c789a4a529765b5e6635238.zip
Added C macro to detect when minishell is tested inside of code
-rw-r--r--README.md4
-rwxr-xr-xsrc/main.py4
-rw-r--r--src/suites/flow.py12
3 files changed, 16 insertions, 4 deletions
diff --git a/README.md b/README.md
index 996f4a0..1954d31 100644
--- a/README.md
+++ b/README.md
@@ -9,9 +9,9 @@ Test for the minishell project of school 42.
The default path to your project is `..` but you can change it the the [configuration](src/config.py).
```sh
-$ ./run` # run all tests
+$ ./run # run all tests
-$ ./run --help`
+$ ./run --help
usage: run [-h] [-v] [-b] [-n] [-l] [-m] [-p] [suite [suite ...]]
Minishell test
diff --git a/src/main.py b/src/main.py
index 4ba5128..8efb43c 100755
--- a/src/main.py
+++ b/src/main.py
@@ -37,7 +37,9 @@ def main():
if config.MINISHELL_MAKE or args.make:
try:
print("========================================MAKE====================================")
- subprocess.run(["make", "-C", config.MINISHELL_DIR], check=True)
+ subprocess.run(["make", "-C", config.MINISHELL_DIR],
+ check=True,
+ env={"MINISHELL_TEST_FLAGS": "-DMINISHELL_TEST", **os.environ})
print("================================================================================")
except subprocess.CalledProcessError:
sys.exit(1)
diff --git a/src/suites/flow.py b/src/suites/flow.py
index cf8ca61..55c5647 100644
--- a/src/suites/flow.py
+++ b/src/suites/flow.py
@@ -6,7 +6,7 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:24:52 by charles #+# #+# #
-# Updated: 2020/09/12 15:30:37 by charles ### ########.fr #
+# Updated: 2020/09/13 17:19:09 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -35,6 +35,7 @@ def suite_end(test):
test("ls doesnotexists ; echo bonjour")
test("ls doesnotexists; echo bonjour")
test("echo bonjour; ls doesnotexists")
+ test("echo a ; ;", hook=hooks.error_line0)
@suite()
@@ -61,6 +62,11 @@ def suite_pipe(test):
test("export A=a | cat; echo $A")
# test("echo a | A=a; echo $A")
# test("A=a | cat; echo $A")
+ test("ls " + 40 * " | ls")
+ test("ls " + 80 * " | ls")
+ test("echo bonjour " + 40 * " | cat -e")
+ test("echo bonjour " + 80 * " | cat -e")
+ test("echo bonjour | | cat -e", hook=hooks.error_line0)
@suite(bonus=True)
@@ -148,3 +154,7 @@ def suite_parenthesis(test):
test("(ls doesntexist || ls)")
test("(ls doesntexist && ls)")
test("(ls && ls) && echo $?")
+ test("(echo a; echo b) | cat -e")
+ test("echo bonjour | (cat -e; echo a)")
+ test("echo bonjour | (echo a; cat -e)")
+ test("(echo bonjour ; echo aurevoir) | (cat -e | cat -e) | cat -e")