From 68ce253ca289030922581b10a34094750c34d729 Mon Sep 17 00:00:00 2001 From: BanceDev Date: Fri, 27 Sep 2024 09:33:01 -0400 Subject: added exit api function --- test/args_test.lua | 2 +- test/chaining_test.lua | 8 ++++++++ test/env_test.lua | 2 ++ test/filecheck_test.lua | 5 +++++ test/history_test.lua | 3 +++ test/run_tests.lua | 1 + 6 files changed, 20 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/args_test.lua b/test/args_test.lua index d14fd73..a698b36 100644 --- a/test/args_test.lua +++ b/test/args_test.lua @@ -17,7 +17,7 @@ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. if args == nil then print("args test failed, no args found ❌\n") - return + lush.exit() else print("args:") for i = 1, #args do diff --git a/test/chaining_test.lua b/test/chaining_test.lua index 83f3e76..411dcdd 100644 --- a/test/chaining_test.lua +++ b/test/chaining_test.lua @@ -15,48 +15,56 @@ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ]] +-- TODO: Add more edge case tests for chaining operators local cwd = lush.getcwd() lush.cd("~/.lush/scripts") if lush.exec('cat "example.lua" | grep "hello" | sort | uniq') then print("piping test passed ✅\n") else print("piping test failed ❌\n") + lush.exit() end if lush.exec("echo hi && echo bye") then print("and test passed ✅\n") else print("and test failed ❌\n") + lush.exit() end if lush.exec("cd lol || echo lol does not exist") then print("or test passed ✅\n") else print("or test failed ❌\n") + lush.exit() end if lush.exec("sleep 2 &") then print("background test passed ✅\n") else print("background test failed ❌\n") + lush.exit() end if lush.exec("echo hi; echo bye") then print("semicolon test passed ✅\n") else print("semicolon test failed ❌\n") + lush.exit() end if lush.exec("echo hi > test.txt") then print("redirect test passed ✅\n") else print("redirect test failed ❌\n") + lush.exit() end if lush.exec("echo hi >> test.txt") then print("append test passed ✅\n") else print("append test failed ❌\n") + lush.exit() end lush.cd(cwd) diff --git a/test/env_test.lua b/test/env_test.lua index 972a730..4a0d9d2 100644 --- a/test/env_test.lua +++ b/test/env_test.lua @@ -20,6 +20,7 @@ if lush.getenv("ENVTEST") == "envtest" then print("setenv test passed ✅\n") else print("setenv test failed ❌\n") + lush.exit() end lush.unsetenv("ENVTEST") @@ -27,4 +28,5 @@ if lush.getenv("ENVTEST") == nil then print("unsetenv test passed ✅\n") else print("unsetenv test failed ❌\n") + lush.exit() end diff --git a/test/filecheck_test.lua b/test/filecheck_test.lua index af0c130..9a2ffd7 100644 --- a/test/filecheck_test.lua +++ b/test/filecheck_test.lua @@ -19,28 +19,33 @@ if lush.exists("~/.lush/scripts/example.lua") then print("exists test passed ✅\n") else print("exists test failed ❌\n") + lush.exit() end if lush.isFile("~/.lush/scripts/example.lua") then print("isFile test passed ✅\n") else print("isFile test failed ❌\n") + lush.exit() end if not lush.isDirectory("~/.lush/scripts/example.lua") then print("isDirectory test passed ✅\n") else print("isDirectory test failed ❌\n") + lush.exit() end if lush.isReadable("~/.lush/scripts/example.lua") then print("isReadable test passed ✅\n") else print("isReadable test failed ❌\n") + lush.exit() end if lush.isWriteable("~/.lush/scripts/example.lua") then print("isWriteable test passed ✅\n") else print("isWriteable test failed ❌\n") + lush.exit() end diff --git a/test/history_test.lua b/test/history_test.lua index 69d8287..50be957 100644 --- a/test/history_test.lua +++ b/test/history_test.lua @@ -29,10 +29,13 @@ if lush.getHistory(1) == lush.lastHistory() then print("getHistory test passed ✅\n") else print("getHistory test failed at args history ❌\n") + lush.exit() end else print("getHistory test failed at piping history ❌\n") + lush.exit() end else print("getHistory test failed at lastHistory ❌\n") + lush.exit() end diff --git a/test/run_tests.lua b/test/run_tests.lua index 6c54157..39749d3 100644 --- a/test/run_tests.lua +++ b/test/run_tests.lua @@ -15,6 +15,7 @@ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ]] +-- TODO: Add API method for asserting command output equals some string print("Starting Lunar Shell End-to-End Testing...\n") print("Entering Debug Mode...") lush.debug(true) -- cgit v1.2.3-59-g8ed1b