aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--args.py7
-rwxr-xr-xmain.py1
-rw-r--r--suites/__init__.py4
-rw-r--r--suites/builtin.py12
-rw-r--r--suites/path.py71
-rw-r--r--suites/preprocess.py7
-rw-r--r--test.py6
7 files changed, 100 insertions, 8 deletions
diff --git a/args.py b/args.py
index 60b09c4..358077c 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/07/15 18:24:33 by charles ### ########.fr #
+# Updated: 2020/09/09 15:17:58 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -14,7 +14,10 @@ import argparse
def parse_args():
- parser = argparse.ArgumentParser(description="Minishell test", epilog="Make sure read README.md")
+ parser = argparse.ArgumentParser(
+ description="Minishell test",
+ epilog="Make sure read README.md"
+ )
parser.add_argument(
"-v", "--verbose", action="count",
help="increase verbosity level (e.g -vv == 2)"
diff --git a/main.py b/main.py
index b3437a9..f1d4c10 100755
--- a/main.py
+++ b/main.py
@@ -26,6 +26,7 @@ import suites.preprocess
import suites.operation
import suites.parenthesis
import suites.status
+import suites.path
def main():
if os.path.exists(config.EXECUTABLES_PATH):
diff --git a/suites/__init__.py b/suites/__init__.py
index 138a69b..68bad1f 100644
--- a/suites/__init__.py
+++ b/suites/__init__.py
@@ -6,7 +6,7 @@
# 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 #
+# Updated: 2020/09/09 15:20:22 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -16,4 +16,4 @@ import glob
modules = glob.glob(os.path.join(os.path.dirname(__file__), "*.py"))
__all__ = [os.path.basename(f)[:-3] for f in modules if os.path.isfile(f) and not f.endswith("__init__.py")]
-print(__all__)
+# print(__all__)
diff --git a/suites/builtin.py b/suites/builtin.py
index 4e79432..30297e0 100644
--- a/suites/builtin.py
+++ b/suites/builtin.py
@@ -6,7 +6,7 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:24:43 by charles #+# #+# #
-# Updated: 2020/08/28 17:36:12 by charles ### ########.fr #
+# Updated: 2020/09/09 13:28:02 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -125,6 +125,16 @@ def suite_cd(test):
test("cd //////////////////////////////////////////////////////; pwd; echo $PWD");
test("cd")
+ test("cd ' /'; pwd; echo $PWD")
+ test("cd ' / '; pwd; echo $PWD")
+ test("cd ' /'; pwd; echo $PWD")
+ test("cd ' / '; pwd; echo $PWD")
+ test("cd ' // '; pwd; echo $PWD")
+
+ test("cd //home; pwd; echo $PWD")
+ test("cd ' //home'; pwd; echo $PWD")
+ test("cd ' //home '; pwd; echo $PWD")
+
test("cd d", setup="mkdir -m 000 d")
test("cd d", setup="mkdir -m 001 d")
test("cd d", setup="mkdir -m 002 d")
diff --git a/suites/path.py b/suites/path.py
new file mode 100644
index 0000000..b30215f
--- /dev/null
+++ b/suites/path.py
@@ -0,0 +1,71 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# path.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/09/09 15:12:58 by charles #+# #+# #
+# Updated: 2020/09/09 15:39:17 by charles ### ########.fr #
+# #
+# ############################################################################ #
+
+import config
+from suite import suite
+
+@suite
+def suite_path(test):
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 000 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 001 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 002 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 003 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 004 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 005 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 006 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 007 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 010 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 020 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 030 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 040 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 050 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 060 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 070 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 100 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 200 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 300 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 400 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 500 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 600 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 700 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 755 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 644 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 311 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 111 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 222 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 333 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 0777 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 1000 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 2000 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 3000 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 4000 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 5000 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 6000 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 7000 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 1777 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 2777 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 3777 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 4777 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 5777 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 6777 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 7777 ./path/a", exports={"PATH": "path"})
+ test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 0000 ./path/a", exports={"PATH": "path"})
+
+ test("b", setup="mkdir path && cp /bin/ls ./path/a && ln -s ./path/a ./path/b", exports={"PATH": "path"})
+
+ test("ls", exports={"PATH": "doesnotexits"})
+ test("ls", exports={"PATH": "doesnotexits:asdfasdfas"})
+ test("ls", exports={"PATH": "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z"})
+ test("ls", exports={"PATH": "________"})
+ test("ls", exports={"PATH": " "})
+ test("ls", exports={"PATH": " : "})
+ test("ls", exports={"PATH": " /bin "})
diff --git a/suites/preprocess.py b/suites/preprocess.py
index 90b37ca..a34e18d 100644
--- a/suites/preprocess.py
+++ b/suites/preprocess.py
@@ -6,7 +6,7 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:25:00 by charles #+# #+# #
-# Updated: 2020/08/28 17:28:35 by charles ### ########.fr #
+# Updated: 2020/09/09 12:50:34 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -84,6 +84,11 @@ def suite_interpolation(test):
test('echo $A"$B"$C"A"$B"$C"', exports={"A": "foo ", "B": " bar ", "C": "baz "})
test("echo $A'$B'$C'A'$B'$C'", exports={"A": "foo ", "B": " bar ", "C": "baz "})
+ test("echo $A")
+ test("echo $A$B")
+ test("echo $A$B$C")
+ test("echo $A$B$C$D")
+
test("echo [$A]", exports={"A": r"bonjour\je"})
test("echo [$A]", exports={"A": r"\b\\o\\\nj\\\\\\\our\\je\\\\"})
test("echo [$A]", exports={"A": r" \b\\o\\\nj\\\\\\\our\\je\\\\"})
diff --git a/test.py b/test.py
index e9e298b..f43518c 100644
--- a/test.py
+++ b/test.py
@@ -6,7 +6,7 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/06/16 21:48:50 by charles #+# #+# #
-# Updated: 2020/08/27 21:02:56 by charles ### ########.fr #
+# Updated: 2020/09/09 15:18:27 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -44,6 +44,7 @@ class Captured:
def timeout():
return Captured("", 0, [], is_timeout = True)
+
class Result:
RED_CHARS = "\033[31m"
GREEN_CHARS = "\033[32m"
@@ -201,7 +202,8 @@ class Test:
if self.setup != "":
s = "[SETUP {}] {}".format(self.setup, s)
if len(self.exports) != 0:
- s = "[EXPORTS {}] {}".format(' '.join(["{}='{:.20}'".format(k, v) for k, v in self.exports.items()]), s)
+ s = "[EXPORTS {}] {}".format(
+ ' '.join(["{}='{:.20}'".format(k, v) for k, v in self.exports.items()]), s)
self.result = Result(s, self.files, expected, actual)
self.result.put()