aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGravatar BanceDev 2024-10-15 11:40:26 -0400
committerGravatar BanceDev 2024-10-15 11:40:26 -0400
commit6295ae273d4a15b60b580344b986986d004c22ad (patch)
treeea8eb39136ab6f128a5388ad656c0b899a91997d /test
parentv0.2.3 (diff)
updated help messages
Diffstat (limited to '')
-rw-r--r--test/chaining_test.lua24
-rw-r--r--test/history_test.lua6
-rw-r--r--test/run_tests.lua26
3 files changed, 47 insertions, 9 deletions
diff --git a/test/chaining_test.lua b/test/chaining_test.lua
index 411dcdd..31ede87 100644
--- a/test/chaining_test.lua
+++ b/test/chaining_test.lua
@@ -15,7 +15,6 @@ 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
@@ -53,18 +52,37 @@ else
lush.exit()
end
-if lush.exec("echo hi > test.txt") then
+if
+ lush.exec(
+ "echo hi > test.txt; echo hi 1> test.txt; echo this wont redirect 2> test.txt; echo but this will &> 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
+if
+ lush.exec(
+ "echo hi >> test.txt; echo hi 1>> test.txt; echo this wont append 2>> test.txt; echo but this will &>> test.txt"
+ )
+then
print("append test passed ✅\n")
else
print("append test failed ❌\n")
lush.exit()
end
+if
+ lush.exec(
+ 'cat "example.lua" | grep "hello" | sort | uniq && echo hi >> test.txt; echo this should print && cd lol || echo lol doesnt exist &> test.txt'
+ )
+then
+ print("complex chain test passed ✅\n")
+else
+ print("complex chain test failed ❌\n")
+ lush.exit()
+end
+
lush.cd(cwd)
diff --git a/test/history_test.lua b/test/history_test.lua
index 50be957..621f22b 100644
--- a/test/history_test.lua
+++ b/test/history_test.lua
@@ -26,7 +26,11 @@ if lush.getHistory(1) == lush.lastHistory() then
if lush.getHistory(9) == 'cat "example.lua" | grep "hello" | sort | uniq' then
-- ensure args history is stored correctly
if lush.getHistory(11) == "args_test.lua testarg1 testarg2 testarg3" then
- print("getHistory test passed ✅\n")
+ if lush.getHistory(0) == nil and lush.getHistory(-1) == nil then
+ print("getHistory test passed ✅\n")
+ else
+ print("getHistory test failed at zero and negative history ❌\n")
+ end
else
print("getHistory test failed at args history ❌\n")
lush.exit()
diff --git a/test/run_tests.lua b/test/run_tests.lua
index 39749d3..0f5c5bd 100644
--- a/test/run_tests.lua
+++ b/test/run_tests.lua
@@ -19,18 +19,34 @@ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
print("Starting Lunar Shell End-to-End Testing...\n")
print("Entering Debug Mode...")
lush.debug(true)
+local rc = true
print("Testing Args...")
-lush.exec("args_test.lua testarg1 testarg2 testarg3")
+rc = lush.exec("args_test.lua testarg1 testarg2 testarg3")
+if rc == false then
+ lush.exit()
+end
print("\nTesting Chaining...")
-lush.exec("chaining_test.lua")
+rc = lush.exec("chaining_test.lua")
+if rc == false then
+ lush.exit()
+end
print("\nTesting File Checks...")
-lush.exec("filecheck_test.lua")
+rc = lush.exec("filecheck_test.lua")
+if rc == false then
+ lush.exit()
+end
print("\nTesting History...")
-lush.exec("history_test.lua")
+rc = lush.exec("history_test.lua")
+if rc == false then
+ lush.exit()
+end
print("\nTesting Environment Variables...")
-lush.exec("env_test.lua")
+rc = lush.exec("env_test.lua")
+if rc == false then
+ lush.exit()
+end