aboutsummaryrefslogtreecommitdiff
path: root/suites
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-07-15 18:26:30 +0200
committerCharles <sircharlesaze@gmail.com>2020-07-15 18:26:30 +0200
commit8a97914ac822703362c22bb6228905f3fbe13d99 (patch)
tree9da9bb39933de640a52187d82a8d5e27ba79c984 /suites
parent9132220296cdf6ab29c570fe0534649cfcc1cd8d (diff)
downloadminishell_test-8a97914ac822703362c22bb6228905f3fbe13d99.tar.gz
minishell_test-8a97914ac822703362c22bb6228905f3fbe13d99.tar.bz2
minishell_test-8a97914ac822703362c22bb6228905f3fbe13d99.zip
Removed not valuable information from log, Added cmd_variable tests
Diffstat (limited to 'suites')
-rw-r--r--suites/__init__.py12
-rw-r--r--suites/builtin.py12
-rw-r--r--suites/cmd.py152
-rw-r--r--suites/operation.py12
-rw-r--r--suites/parenthesis.py12
-rw-r--r--suites/preprocess.py21
-rw-r--r--suites/status.py12
7 files changed, 198 insertions, 35 deletions
diff --git a/suites/__init__.py b/suites/__init__.py
index 736c3c5..138a69b 100644
--- a/suites/__init__.py
+++ b/suites/__init__.py
@@ -1,3 +1,15 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# __init__.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/07/15 18:24:48 by charles #+# #+# #
+# Updated: 2020/07/15 18:24:48 by charles ### ########.fr #
+# #
+# ############################################################################ #
+
import os
import glob
diff --git a/suites/builtin.py b/suites/builtin.py
index 666a744..22c3683 100644
--- a/suites/builtin.py
+++ b/suites/builtin.py
@@ -1,3 +1,15 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# builtin.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/07/15 18:24:43 by charles #+# #+# #
+# Updated: 2020/07/15 18:24:44 by charles ### ########.fr #
+# #
+# ############################################################################ #
+
import config
from suite import suite
diff --git a/suites/cmd.py b/suites/cmd.py
index d4dc2e5..a9fcde7 100644
--- a/suites/cmd.py
+++ b/suites/cmd.py
@@ -1,6 +1,21 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# cmd.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/07/15 15:11:46 by charles #+# #+# #
+# Updated: 2020/07/15 18:21:56 by charles ### ########.fr #
+# #
+# ############################################################################ #
+
+import distutils
+
import config
from suite import suite
+
@suite
def suite_redirection(test):
test("echo bonjour > test", setup="", files=["test"])
@@ -94,41 +109,108 @@ def suite_cmd_error(test):
@suite
def suite_cmd_variable(test):
+ test("A=a bash -c 'echo $A'")
+ test("A=a B=b bash -c 'echo $A$B'")
+ test("A=a B=b C=c D=d E=e F=f G=g H=h bash -c 'echo $A$B$C$D$E$F$G$H'")
+ test("A=a A=bonjour bash -c 'echo $A'")
+ test("A=aA=bonjour bash -c 'echo $A'")
+ test("BONJOURJESUIS=a bash -c 'echo $BONJOURJESUIS'")
+ test("bonjourjesuis=a bash -c 'echo $bonjourjesuis'")
+ test("bonjour_je_suis=a bash -c 'echo $bonjour_je_suis'")
+ test("BONJOURJESUIS1=a bash -c 'echo $BONJOURJESUIS1'")
+ test("bO_nJq123o__1ju_je3234sui__a=a bash -c 'echo $bO_nJq123o__1ju_je3234sui__a'")
+ test("a0123456789=a bash -c 'echo $a0123456789")
+ test("abcdefghijklmnopqrstuvwxyz=a bash -c 'echo $abcdefghijklmnopqrstuvwxyz'")
+ test("ABCDEFGHIJKLMNOPQRSTUVWXYZ=a bash -c 'echo $ABCDEFGHIJKLMNOPQRSTUVWXYZ'")
+ test("__________________________=a bash -c 'echo $__________________________'")
+ test("_bonjour_=a bash -c 'echo $_bonjour_'")
+ test("_=a bash -c 'echo $_a'")
+ test("1=a bash -c 'echo $1'")
+ test("BONJOURJESUIS =a bash -c 'echo $BONJOURJESUIS '")
+ test("BONJOURJESUIS= a bash -c 'echo $BONJOURJESUIS'")
+ test(r"BONJOUR\\JESUIS=a bash -c 'echo $BONJOUR\\JESUIS'")
+ test(r"BONJOUR\'JESUIS=a bash -c 'echo $BONJOUR\'JESUIS'")
+ test(r'BONJOUR\"JESUIS=a bash -c "echo $BONJOUR\"JESUIS"')
+ test(r"BONJOUR\$JESUIS=a bash -c 'echo $BONJOUR\$JESUIS'")
+ test(r"BONJOUR\&JESUIS=a bash -c 'echo $BONJOUR\&JESUIS'")
+ test(r"BONJOUR\|JESUIS=a bash -c 'echo $BONJOUR\|JESUIS'")
+ test(r"BONJOUR\;JESUIS=a bash -c 'echo $BONJOUR\;JESUIS'")
+ test(r"BONJOUR\_JESUIS=a bash -c 'echo $BONJOUR\_JESUIS'")
+ test(r"BONJOUR\0JESUIS=a bash -c 'echo $BONJOUR\0JESUIS'")
+ test(r"\B\O\N\ \ \ \ \ \ \ JOURJESUIS=a bash -c 'echo $\B\O\N\ \ \ \ \ \ \ JOURJESUIS'")
+ test(r"A=\B\O\N\ \ \ \ \ \ \ JOURJESUIS bash -c 'echo $A'")
+ test(r"A='bonjour je suis charles' bash -c 'echo $A'")
+ test(r'A="bonjour je suis charles" bash -c "echo $A"')
+ test(r"A==a bash -c 'echo $A'")
+ test(r"A===a bash -c 'echo $A'")
+ test(r"A====a bash -c 'echo $A'")
+ test(r"A=====a bash -c 'echo $A'")
+ test(r"A======a bash -c 'echo $A'")
+ test(r"A=a=a=a=a=a bash -c 'echo $A'")
+
+ test("A=a; echo $A")
+ test("A=a B=b; echo $A$B")
+ test("A=a B=b C=c D=d E=e F=f G=g H=h; echo $A$B$C$D$E$F$G$H")
+ test("A=a A=bonjour; echo $A")
+ test("A=aA=bonjour; echo $A")
+ test("BONJOURJESUIS=a; echo $BONJOURJESUIS")
+ test("bonjourjesuis=a; echo $bonjourjesuis")
+ test("bonjour_je_suis=a; echo $bonjour_je_suis")
+ test("BONJOURJESUIS1=a; echo $BONJOURJESUIS1")
+ test("bO_nJq123o__1ju_je3234sui__a=a; echo $bO_nJq123o__1ju_je3234sui__a")
+ test("a0123456789=a; echo $a0123456789")
+ test("abcdefghijklmnopqrstuvwxyz=a; echo $abcdefghijklmnopqrstuvwxyz")
+ test("ABCDEFGHIJKLMNOPQRSTUVWXYZ=a; echo $ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+ test("__________________________=a; echo $__________________________")
+ test("_bonjour_=a; echo $_bonjour_")
+ test("_=a; echo $_a")
+ test("1=a; echo $1")
+ test("BONJOURJESUIS =a; echo $BONJOURJESUIS ")
+ test("BONJOURJESUIS= a; echo $BONJOURJESUIS")
+ test(r"BONJOUR\\JESUIS=a; echo $BONJOUR\\JESUIS")
+ test(r"BONJOUR\'JESUIS=a; echo $BONJOUR\'JESUIS")
+ test(r'BONJOUR\"JESUIS=a; echo $BONJOUR\"JESUIS')
+ test(r"BONJOUR\$JESUIS=a; echo $BONJOUR\$JESUIS")
+ test(r"BONJOUR\&JESUIS=a; echo $BONJOUR\&JESUIS")
+ test(r"BONJOUR\|JESUIS=a; echo $BONJOUR\|JESUIS")
+ test(r"BONJOUR\;JESUIS=a; echo $BONJOUR\;JESUIS")
+ test(r"BONJOUR\_JESUIS=a; echo $BONJOUR\_JESUIS")
+ test(r"BONJOUR\0JESUIS=a; echo $BONJOUR\0JESUIS")
+ test(r"\B\O\N\ \ \ \ \ \ \ JOURJESUIS=a; echo $\B\O\N\ \ \ \ \ \ \ JOURJESUIS")
+ test(r"A=\B\O\N\ \ \ \ \ \ \ JOURJESUIS; echo $A")
+ test(r"A='bonjour je suis charles'; echo $A")
+ test(r'A="bonjour je suis charles"; echo $A')
+ test(r"A==a; echo $A")
+ test(r"A===a; echo $A")
+ test(r"A====a; echo $A")
+ test(r"A=====a; echo $A")
+ test(r"A======a; echo $A")
+ test(r"A=a=a=a=a=a; echo $A")
+
+ test("PATH=a ls")
+ test("PATH=a echo aa")
test("A=a echo $A")
test("A=a B=b echo $A$B")
test("A=a B=b C=c D=d E=e F=f G=g H=h echo $A$B$C$D$E$F$G$H")
- test("A=a A=bonjour echo $A")
- test("A=aA=bonjour echo $A")
- test("BONJOURJESUIS=a echo $BONJOURJESUIS")
- test("bonjourjesuis=a echo $bonjourjesuis")
- test("bonjour_je_suis=a echo $bonjour_je_suis")
- test("BONJOURJESUIS1=a echo $BONJOURJESUIS1")
- test("bO_nJq123o__1ju_je3234sui__a=a echo $bO_nJq123o__1ju_je3234sui__a")
- test("a0123456789=a echo $a0123456789")
- test("abcdefghijklmnopqrstuvwxyz=a echo $abcdefghijklmnopqrstuvwxyz")
- test("ABCDEFGHIJKLMNOPQRSTUVWXYZ=a echo $ABCDEFGHIJKLMNOPQRSTUVWXYZ")
- test("__________________________=a echo $__________________________")
- test("_bonjour_=a echo $_bonjour_")
- test("_=a echo $_a")
- test("1=a echo $1")
- test("BONJOURJESUIS =a echo $BONJOURJESUIS ")
- test("BONJOURJESUIS= a echo $BONJOURJESUIS")
- test(r"BONJOUR\\JESUIS=a echo $BONJOUR\\JESUIS")
- test(r"BONJOUR\'JESUIS=a echo $BONJOUR\'JESUIS")
- test(r'BONJOUR\"JESUIS=a echo $BONJOUR\"JESUIS')
- test(r"BONJOUR\$JESUIS=a echo $BONJOUR\$JESUIS")
- test(r"BONJOUR\&JESUIS=a echo $BONJOUR\&JESUIS")
- test(r"BONJOUR\|JESUIS=a echo $BONJOUR\|JESUIS")
- test(r"BONJOUR\;JESUIS=a echo $BONJOUR\;JESUIS")
- test(r"BONJOUR\_JESUIS=a echo $BONJOUR\_JESUIS")
- test(r"BONJOUR\0JESUIS=a echo $BONJOUR\0JESUIS")
- test(r"\B\O\N\ \ \ \ \ \ \ JOURJESUIS=a echo $\B\O\N\ \ \ \ \ \ \ JOURJESUIS")
- test(r"A=\B\O\N\ \ \ \ \ \ \ JOURJESUIS echo $A")
- test(r"A='bonjour je suis charles' echo $A")
- test(r'A="bonjour je suis charles" echo $A')
- test(r"A==a echo $A")
- test(r"A===a echo $A")
- test(r"A====a echo $A")
- test(r"A=====a echo $A")
- test(r"A======a echo $A")
- test(r"A=a=a=a=a=a echo $A")
+ test("A=$PATH bash -c 'echo $A'")
+ test("A=\"$PATH je suis\" bash -c 'echo $A'")
+ test("A='$PATH je suis' bash -c 'echo $A'")
+ test("$TEST bash -c 'echo $A'", setup="export TEST='A=a'")
+
+@suite
+def suite_cmd_path(test):
+ ls_path = distutils.spawn.find_executable("ls")
+ cat_path = distutils.spawn.find_executable("cat")
+
+ test(ls_path, setup="touch a b c")
+ test(ls_path + " -l", setup="touch a b c")
+ test("./bonjour", setup="touch a b c; cp {} bonjour".format(ls_path))
+ test("./bonjour -l", setup="touch a b c; cp {} bonjour".format(ls_path))
+ test("./somedir/bonjour -l",
+ setup="mkdir somedir; touch a b c; touch somedir/d somedir/e;" +
+ "cp {} somedir/bonjour".format(ls_path))
+
+ test("./ls . a b c",
+ setup="touch a b c; echo bonjour > a; cp {} ls".format(cat_path))
+ test("ls . a b c",
+ setup="touch a b c; echo bonjour > a; cp {} ls".format(cat_path))
diff --git a/suites/operation.py b/suites/operation.py
index 8d912d3..fd54f00 100644
--- a/suites/operation.py
+++ b/suites/operation.py
@@ -1,3 +1,15 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# operation.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/07/15 18:24:52 by charles #+# #+# #
+# Updated: 2020/07/15 18:24:53 by charles ### ########.fr #
+# #
+# ############################################################################ #
+
from suite import suite
@suite
diff --git a/suites/parenthesis.py b/suites/parenthesis.py
index 30f1cce..a06fdda 100644
--- a/suites/parenthesis.py
+++ b/suites/parenthesis.py
@@ -1,3 +1,15 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# parenthesis.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/07/15 18:24:57 by charles #+# #+# #
+# Updated: 2020/07/15 18:24:57 by charles ### ########.fr #
+# #
+# ############################################################################ #
+
from suite import suite
@suite
diff --git a/suites/preprocess.py b/suites/preprocess.py
index 34dac00..891747e 100644
--- a/suites/preprocess.py
+++ b/suites/preprocess.py
@@ -1,3 +1,15 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# preprocess.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/07/15 18:25:00 by charles #+# #+# #
+# Updated: 2020/07/15 18:25:01 by charles ### ########.fr #
+# #
+# ############################################################################ #
+
import config
from suite import suite
@@ -119,6 +131,15 @@ def suite_glob(test):
test("echo */a", setup="mkdir d; touch d/a d/b d/c")
test("echo d/*", setup="mkdir d; touch d/a d/b d/c")
+ test("*")
+ test("*", setup="touch a b c")
+ test("*.c", setup="touch a b c foo.c bar.c")
+ test("src/*.c", setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c")
+ test("*/*.c", setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c")
+ test("*/*.c",
+ setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c;\
+ mkdir inc; touch inc/a inc/b inc/c inc/foo.c inc/bar.c")
+
@suite
def suite_escape(test):
test(r"echo \a")
diff --git a/suites/status.py b/suites/status.py
index f116ec1..62c076e 100644
--- a/suites/status.py
+++ b/suites/status.py
@@ -1,3 +1,15 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# status.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/07/15 18:24:40 by charles #+# #+# #
+# Updated: 2020/07/15 18:24:40 by charles ### ########.fr #
+# #
+# ############################################################################ #
+
from suite import suite
@suite