chore(lune): fix test skipping

* Previously, skipping tests using arguments of selective files
  to include did not work correctly due to our directory structure.
  This has been fixed.
* On test skip, the reporter would tyr to get the style for the report
  with no timestamp argument, causing a string formatting with nil
  error. For skips, we force the timestamp to be zero now.
This commit is contained in:
Erica Marigold 2024-12-04 06:27:20 +00:00
parent b7ccc05702
commit 54a3f6869b
Signed by: DevComp
GPG key ID: 429EF1C337871656
2 changed files with 13 additions and 7 deletions

View file

@ -49,13 +49,19 @@ for _, test in discoverTests("src") do
-- we run all the tests
-- So, to include only a certain set of test files, you can provide either
-- the full path to the test file (with or without the extension) or the test
-- file name
local withoutExt = string.sub(test, 1, -6)
-- the full path of the test file or name of the test file, with or without
-- the `.spec.luau` extension
local baseName = string.match(test, "([^/\\]+)$")
local withoutExt = string.sub(test, 1, -11)
local baseNameWithoutExt = string.match(withoutExt, "([^/\\]+)$")
local isAllowed = #process.args == 0
or table.find(allowedTests, `tests/{test}`)
or table.find(allowedTests, test)
or table.find(allowedTests, withoutExt)
or table.find(allowedTests, `tests/{withoutExt}`)
or table.find(allowedTests, baseName)
or table.find(allowedTests, baseNameWithoutExt)
local constructors = {
case = frktest.test.case,

View file

@ -45,13 +45,13 @@ function ReporterExt.init()
if test.failed then "error" else "success",
-- Await receival of the timestamp and convert the difference to ms
(os.clock() - recv_ts()) * 1000
(os.clock() - recv_ts()) * 1000
)
)
end)
frktest.test.on_test_skipped(function(test)
print(STYLE.report(test.name, "skip"))
print(STYLE.report(test.name, "skip", 0))
end)
Reporter.init()