diff options
| author | ruki <[email protected]> | 2017-05-20 00:42:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-05-20 00:42:05 +0800 |
| commit | ce27b8d4dfae08a01f473e7a5cfbb94f6e79c967 (patch) | |
| tree | 76cb0f63a16787f920c3dac016ad7b6f5c2d7250 /tests/test.lua | |
| parent | c6876982657c8bf65b7e2a05fc1206b3aacc0ff8 (diff) | |
improve test script
Diffstat (limited to 'tests/test.lua')
| -rw-r--r-- | tests/test.lua | 45 |
1 files changed, 45 insertions, 0 deletions
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 |
