From dcb4a6453ca1ca6789c3121a739f373abeaba14c Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Fri, 11 Sep 2020 15:52:01 +0200 Subject: Added output hook and sort_lines hook --- src/suites/builtin.py | 17 +++++++++-------- src/suites/cmd.py | 16 +++++++++++++++- src/suites/parenthesis.py | 7 ++++++- src/suites/status.py | 30 ------------------------------ 4 files changed, 30 insertions(+), 40 deletions(-) delete mode 100644 src/suites/status.py (limited to 'src/suites') diff --git a/src/suites/builtin.py b/src/suites/builtin.py index da146e0..c782f4d 100644 --- a/src/suites/builtin.py +++ b/src/suites/builtin.py @@ -6,13 +6,14 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:43 by charles #+# #+# # -# Updated: 2020/09/09 13:28:02 by charles ### ########.fr # +# Updated: 2020/09/11 16:13:26 by charles ### ########.fr # # # # ############################################################################ # import os import config +import hooks from suite import suite @suite() @@ -42,7 +43,7 @@ def suite_echo(test): @suite() def suite_export(test): - test("export") + test("export", hook=hooks.sort_lines) # test("export A=; env | grep A=; echo $A") # test("export A; env | grep A; echo $A") test("export A=a; echo $A") @@ -105,8 +106,8 @@ def suite_cd(test): test("cd '' ''; pwd; echo $PWD"); test("cd '' '' ''; pwd; echo $PWD"); test("cd ' '; pwd; echo $PWD"); - test("cd '\t'; pwd; echo $PWD"); - test("cd '\t \t\t\t '; pwd; echo $PWD"); + # test("cd '\t'; pwd; echo $PWD"); + # test("cd '\t \t\t\t '; pwd; echo $PWD"); test("cd d ''; pwd; echo $PWD", setup="mkdir d") test("cd d d; pwd; echo $PWD", setup="mkdir d") test("cd d ' '; pwd; echo $PWD", setup="mkdir d") @@ -220,10 +221,10 @@ def suite_pwd(test): @suite() def suite_env(test): - test("env") # TODO ordering doesn't mater flag - test("env", setup="export A=a") - test("env", setup="export A=a B=b C=c") - test("env | cat -e", setup="export A=a B=b C=c") + test("env", hook=hooks.sort_lines) + test("env", setup="export A=a", hook=hooks.sort_lines) + test("env", setup="export A=a B=b C=c", hook=hooks.sort_lines) + test("env | cat -e", setup="export A=a B=b C=c", hook=hooks.sort_lines) @suite() def suite_exit(test): diff --git a/src/suites/cmd.py b/src/suites/cmd.py index 4fc5f55..8698392 100644 --- a/src/suites/cmd.py +++ b/src/suites/cmd.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 15:11:46 by charles #+# #+# # -# Updated: 2020/09/11 14:25:04 by charles ### ########.fr # +# Updated: 2020/09/11 16:14:18 by charles ### ########.fr # # # # ############################################################################ # @@ -315,3 +315,17 @@ def suite_cmd_path(test): test("./somedir", setup='mkdir somedir && chmod 6777 somedir') test("./somedir", setup='mkdir somedir && chmod 0000 somedir') test("./somedir", setup='mkdir somedir && chmod 0000 somedir') + + +@suite() +def suite_status(test): + test("echo $?") + test("echo; echo $?") + test("notfound; echo $?") + test("cat < doesntexist; echo $?") + test("cat < noperm; echo $?", setup="echo bonjour > noperm; chmod 000 noperm") + + test("echo") + test("notfound") + test("cat < doesntexist") + test("cat < noperm", setup="echo bonjour > noperm; chmod 000 noperm") diff --git a/src/suites/parenthesis.py b/src/suites/parenthesis.py index 98320e8..d3ec5bf 100644 --- a/src/suites/parenthesis.py +++ b/src/suites/parenthesis.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:57 by charles #+# #+# # -# Updated: 2020/09/11 14:23:35 by charles ### ########.fr # +# Updated: 2020/09/11 16:13:54 by charles ### ########.fr # # # # ############################################################################ # @@ -55,3 +55,8 @@ def suite_parenthesis(test): test("(exit); echo bonjour") test("(echo bonjour; exit; echo aurevoir)") + + test("(ls && ls)") + test("(ls doesntexist || ls)") + test("(ls doesntexist && ls)") + test("(ls && ls) && echo $?") diff --git a/src/suites/status.py b/src/suites/status.py deleted file mode 100644 index 416b69a..0000000 --- a/src/suites/status.py +++ /dev/null @@ -1,30 +0,0 @@ -# ############################################################################ # -# # -# ::: :::::::: # -# status.py :+: :+: :+: # -# +:+ +:+ +:+ # -# By: charles +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2020/07/15 18:24:40 by charles #+# #+# # -# Updated: 2020/07/15 18:24:40 by charles ### ########.fr # -# # -# ############################################################################ # - -from suite import suite - -@suite() -def suite_status(test): - test("echo $?") - test("echo; echo $?") - test("notfound; echo $?") - test("cat < doesntexist; echo $?") - test("cat < noperm; echo $?", setup="echo bonjour > noperm; chmod 000 noperm") - test("(ls && ls) && echo $?") - - test("echo") - test("notfound") - test("cat < doesntexist") - test("cat < noperm", setup="echo bonjour > noperm; chmod 000 noperm") - test("(ls && ls)") - test("(ls doesntexist || ls)") - test("(ls doesntexist && ls)") -- cgit