mirror of
https://github.com/0x5eal/luau-unzip.git
synced 2025-04-10 17:20:53 +01:00
chore(tests): fix filtering in test runner
This commit is contained in:
parent
6daf378492
commit
89ee51874b
1 changed files with 11 additions and 16 deletions
|
@ -21,7 +21,6 @@ local require = require :: (
|
||||||
))
|
))
|
||||||
) -> ()
|
) -> ()
|
||||||
|
|
||||||
|
|
||||||
local function discoverTests(dir: string): { string }
|
local function discoverTests(dir: string): { string }
|
||||||
local tests = {}
|
local tests = {}
|
||||||
|
|
||||||
|
@ -29,7 +28,7 @@ local function discoverTests(dir: string): { string }
|
||||||
for _, entry in entries do
|
for _, entry in entries do
|
||||||
local path = `{dir}/{entry}`
|
local path = `{dir}/{entry}`
|
||||||
|
|
||||||
-- Look for files ending in `.spec.luau` as tests
|
-- Look for files ending in `.luau` as tests
|
||||||
if fs.isFile(path) and string.match(entry, "%.luau$") then
|
if fs.isFile(path) and string.match(entry, "%.luau$") then
|
||||||
table.insert(tests, path)
|
table.insert(tests, path)
|
||||||
continue
|
continue
|
||||||
|
@ -52,18 +51,16 @@ for _, test in discoverTests("tests") do
|
||||||
-- we run all the tests
|
-- we run all the tests
|
||||||
|
|
||||||
-- So, to include only a certain set of test files, you can provide either
|
-- So, to include only a certain set of test files, you can provide either
|
||||||
-- the full path of the test file or name of the test file, with or without
|
-- the full path to the test file (with or without the extension) or the test
|
||||||
-- the `.luau` extension
|
-- file name
|
||||||
local baseName = string.match(test, "([^/\\]+)$")
|
local basename = string.match(test, "([^/\\]+)$") :: string
|
||||||
|
local basenameWithoutExt = string.gsub(basename, "%.luau$", "")
|
||||||
local withoutExt = string.sub(test, 1, -11)
|
local testPath = string.gsub(test, "%.luau$", "")
|
||||||
local baseNameWithoutExt = string.match(withoutExt, "([^/\\]+)$")
|
|
||||||
|
|
||||||
local isAllowed = #process.args == 0
|
local isAllowed = #process.args == 0
|
||||||
or table.find(allowedTests, test)
|
or table.find(allowedTests, test)
|
||||||
or table.find(allowedTests, withoutExt)
|
or table.find(allowedTests, testPath)
|
||||||
or table.find(allowedTests, baseName)
|
or table.find(allowedTests, basename)
|
||||||
or table.find(allowedTests, baseNameWithoutExt)
|
or table.find(allowedTests, basenameWithoutExt)
|
||||||
|
|
||||||
local constructors = {
|
local constructors = {
|
||||||
case = frktest.test.case,
|
case = frktest.test.case,
|
||||||
|
@ -75,10 +72,8 @@ for _, test in discoverTests("tests") do
|
||||||
constructors.suite = frktest.test.skip.suite
|
constructors.suite = frktest.test.skip.suite
|
||||||
end
|
end
|
||||||
|
|
||||||
require(`../../{test}`)(
|
require(`../../{test}`)(setmetatable(constructors, { __index = frktest.test }))
|
||||||
setmetatable(constructors, { __index = frktest.test })
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
reporter.init()
|
reporter.init()
|
||||||
process.exit(tonumber(frktest.run()))
|
process.exit(tonumber(frktest.run()))
|
||||||
|
|
Loading…
Add table
Reference in a new issue