From 9aeced3ae3e4fc43631208ed6e54ce256ce184aa Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 08:19:06 +0800 Subject: add test for os directory operation --- tests/modules/os/test.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/modules/os/test.lua (limited to 'tests/modules/os/test.lua') diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua new file mode 100644 index 000000000..29dbbcc39 --- /dev/null +++ b/tests/modules/os/test.lua @@ -0,0 +1,11 @@ +function main() + os.mkdir("test1") + assert(os.exists("test1")) + os.cp("test1","test2") + assert(os.exists("test2")) + os.rmdir("test1") + assert(not os.exists("test1")) + io.writefile("test2/awd","awd") + os.rmdir("test2") + assert(not os.exists("test2")) +end -- cgit v1.3.1 From 4f67991edadbedab69f36a7a3c73b44ff3f65ba6 Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 09:26:31 +0800 Subject: add more test on cp/mv --- tests/modules/os/test.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/modules/os/test.lua') diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua index 29dbbcc39..ffb81d3cc 100644 --- a/tests/modules/os/test.lua +++ b/tests/modules/os/test.lua @@ -1,4 +1,5 @@ function main() + -- test cpdir os.mkdir("test1") assert(os.exists("test1")) os.cp("test1","test2") @@ -8,4 +9,23 @@ function main() io.writefile("test2/awd","awd") os.rmdir("test2") assert(not os.exists("test2")) + -- test rename + os.mkdir("test1") + assert(os.exists("test1")) + os.mv("test1","test2") + assert(not os.exists("test1")) + assert(os.exists("test2")) + os.rmdir("test2") + assert(not os.exists("test2")) + -- test cp/mvdir into another dir + os.mkdir("test1") + os.mkdir("test2") + assert(os.exists("test1") and os.exists("test2")) + os.cp("test1","test2") + assert(os.exists("test2/test1")) + os.mv("test1","test2/test1") + assert(not os.exists("test1")) + assert(os.exists("test2/test1/test1")) + os.rmdir("test2") + assert(not os.exists("test2")) end -- cgit v1.3.1 From 93fbbb2131cb92fd6d2c5dc64dea3ea54f6e4d64 Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 09:31:30 +0800 Subject: add test for os.setenv & os.mclock --- tests/modules/os/test.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/modules/os/test.lua') diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua index ffb81d3cc..681a2ec75 100644 --- a/tests/modules/os/test.lua +++ b/tests/modules/os/test.lua @@ -1,4 +1,6 @@ function main() + -- get mclock + local tm = os.mclock() -- test cpdir os.mkdir("test1") assert(os.exists("test1")) @@ -28,4 +30,9 @@ function main() assert(os.exists("test2/test1/test1")) os.rmdir("test2") assert(not os.exists("test2")) + -- test setenv + os.setenv("__AWD","DWA") + assert(os.getenv("__AWD")=="DWA") + -- assert mclock + assert(os.mclock()>=tm) end -- cgit v1.3.1