From ce27b8d4dfae08a01f473e7a5cfbb94f6e79c967 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 20 May 2017 00:42:05 +0800 Subject: improve test script --- tests/test.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/test.lua (limited to 'tests/test.lua') diff --git a/tests/test.lua b/tests/test.lua new file mode 100644 index 000000000..2f67ba416 --- /dev/null +++ b/tests/test.lua @@ -0,0 +1,45 @@ +-- imports +import("core.project.task") + +-- run test with the given name +function _run_test(name) + + -- find the test script + for _, script in ipairs(os.files(path.join(os.scriptdir(), "**", name, "test.lua"))) do + + -- trace + print("testing %s ...", script) + + -- enter script directory + os.cd(path.directory(script)) + + -- run test + task.run("lua", {script = path.filename(script)}) + break + end +end + +-- main entry +function main(name) + + -- run the given test + if name then + return _run_test(name) + end + + -- run all tests + for _, script in ipairs(os.files(path.join(os.scriptdir(), "**", "test.lua"))) do + + -- trace + print("testing %s ...", script) + + -- enter script directory + local oldir = os.cd(path.directory(script)) + + -- run test + task.run("lua", {script = path.filename(script)}) + + -- leave script directory + os.cd(oldir) + end +end -- cgit v1.3.1