Avoid globbing target dir every test
This commit is contained in:
parent
3a7f2366e4
commit
eb7b05d07a
@ -31,7 +31,7 @@ dev.panic = "abort"
|
|||||||
release.panic = "abort"
|
release.panic = "abort"
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "main"
|
name = "test"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
if (...) ~= nil and (...).type == "group" then return end -- prevent recursive main call
|
if (...) ~= nil and (...).type == "group" then return end -- prevent recursive harness call
|
||||||
local fs = require("lb:fs")
|
|
||||||
|
local ok = pcall(require, "lb:task")
|
||||||
|
if not ok then error("lua test harness requires lb:task module") end
|
||||||
|
local ok, fs = pcall(require, "lb:fs")
|
||||||
|
if not ok then error("lua test harness requires lb:fs module") end
|
||||||
|
|
||||||
local global = _G
|
local global = _G
|
||||||
local colors = {
|
local colors = {
|
||||||
reset = "\x1b[0m",
|
reset = "\x1b[0m",
|
||||||
@ -88,10 +93,15 @@ local function run(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return run(create_group("", function()
|
return run(create_group("", function()
|
||||||
for entry in fs:glob("{tests,crates/*/tests}/**/*.lua") do
|
local function glob(path, pat)
|
||||||
local path = entry:path():sub(3)
|
for entry in fs:glob_dir(path, pat) do
|
||||||
local f, err = loadfile(path)
|
local path = entry:path()
|
||||||
if not f then error(err) end
|
local f, err = loadfile(path)
|
||||||
describe(path, f)
|
if not f then error(err) end
|
||||||
|
describe(path, f)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
glob("tests", "**/*.lua")
|
||||||
|
glob("crates", "*/tests/**/*.lua")
|
||||||
end))
|
end))
|
@ -13,7 +13,7 @@ fn main() -> ExitCode {
|
|||||||
rt.unhandled_error(error_cb).build().unwrap()
|
rt.unhandled_error(error_cb).build().unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let path = "tests/main.lua";
|
let path = "tests/test.lua";
|
||||||
let main = lua.spawn(async move |s| {
|
let main = lua.spawn(async move |s| {
|
||||||
if let Err(ref err) = s.load(Chunk::new(fs::read(path).unwrap()).path(path)) {
|
if let Err(ref err) = s.load(Chunk::new(fs::read(path).unwrap()).path(path)) {
|
||||||
s.report_error(err);
|
s.report_error(err);
|
Loading…
x
Reference in New Issue
Block a user