summaryrefslogtreecommitdiff
path: root/tests/modules/os/test.lua
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-06-08 13:34:02 +0800
committerOpportunityLiu <[email protected]>2019-06-08 13:34:02 +0800
commit1af88102687e493cab40e62b0a2b8b7d42417ae6 (patch)
tree272a80b424e68024a9ecda138159864d9659fe5a /tests/modules/os/test.lua
parente165a8e43abed4eb2eca64c3b5adefb57cd65600 (diff)
improve test lib
Diffstat (limited to 'tests/modules/os/test.lua')
-rw-r--r--tests/modules/os/test.lua58
1 files changed, 41 insertions, 17 deletions
diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua
index 681a2ec75..a0ff57ec5 100644
--- a/tests/modules/os/test.lua
+++ b/tests/modules/os/test.lua
@@ -1,38 +1,62 @@
-function main()
+function test_cpdir(t)
-- get mclock
local tm = os.mclock()
-- test cpdir
os.mkdir("test1")
- assert(os.exists("test1"))
+ t:require(os.exists("test1"))
os.cp("test1","test2")
- assert(os.exists("test2"))
+ t:require(os.exists("test2"))
os.rmdir("test1")
- assert(not os.exists("test1"))
+ t:require_not(os.exists("test1"))
io.writefile("test2/awd","awd")
os.rmdir("test2")
- assert(not os.exists("test2"))
+ t:require_not(os.exists("test2"))
+ -- assert mclock
+ t:require(os.mclock() >= tm)
+end
+
+function test_rename(t)
+ -- get mclock
+ local tm = os.mclock()
-- test rename
os.mkdir("test1")
- assert(os.exists("test1"))
+ t:require(os.exists("test1"))
os.mv("test1","test2")
- assert(not os.exists("test1"))
- assert(os.exists("test2"))
+ t:require_not(os.exists("test1"))
+ t:require(os.exists("test2"))
os.rmdir("test2")
- assert(not os.exists("test2"))
+ t:require_not(os.exists("test2"))
+ -- assert mclock
+ t:require(os.mclock() >= tm)
+end
+
+function test_cp_mvdir_into_another_dir(t)
+ -- get mclock
+ local tm = os.mclock()
-- test cp/mvdir into another dir
os.mkdir("test1")
os.mkdir("test2")
- assert(os.exists("test1") and os.exists("test2"))
+ t:require(os.exists("test1"))
+ t:require(os.exists("test2"))
os.cp("test1","test2")
- assert(os.exists("test2/test1"))
+ t:require(os.exists("test2/test1"))
os.mv("test1","test2/test1")
- assert(not os.exists("test1"))
- assert(os.exists("test2/test1/test1"))
+ t:require_not(os.exists("test1"))
+ t:require(os.exists("test2/test1/test1"))
os.rmdir("test2")
- assert(not os.exists("test2"))
+ t:require_not(os.exists("test2"))
+ -- assert mclock
+ t:require(os.mclock() >= tm)
+end
+
+function test_setenv(t)
+ -- get mclock
+ local tm = os.mclock()
-- test setenv
os.setenv("__AWD","DWA")
- assert(os.getenv("__AWD")=="DWA")
+ t:are_equal(os.getenv("__AWD"), "DWA")
+ os.setenv("__AWD","DWA2")
+ t:are_equal(os.getenv("__AWD"), "DWA2")
-- assert mclock
- assert(os.mclock()>=tm)
-end
+ t:require(os.mclock() >= tm)
+end \ No newline at end of file