mirror of
https://github.com/pesde-pkg/scripts.git
synced 2025-01-05 19:29:08 +00:00
style: apply stylua formatter
This commit is contained in:
parent
be2ae619c6
commit
0045c01c72
7 changed files with 383 additions and 385 deletions
|
@ -10,15 +10,15 @@ local reporter = require("./reporter")
|
|||
-- A more proper solution would be to use luau.load instead, but
|
||||
-- frktest requires its global state to be modified by test suites
|
||||
local require = require :: (
|
||||
path: string
|
||||
path: string
|
||||
) -> (
|
||||
test: typeof(setmetatable(
|
||||
{} :: {
|
||||
case: (name: string, fn: () -> nil) -> (),
|
||||
suite: (name: string, fn: () -> ()) -> (),
|
||||
},
|
||||
{ __index = frktest.test }
|
||||
))
|
||||
test: typeof(setmetatable(
|
||||
{} :: {
|
||||
case: (name: string, fn: () -> nil) -> (),
|
||||
suite: (name: string, fn: () -> ()) -> (),
|
||||
},
|
||||
{ __index = frktest.test }
|
||||
))
|
||||
) -> ()
|
||||
|
||||
local function discoverTests(dir: string)
|
||||
|
@ -45,35 +45,34 @@ end
|
|||
|
||||
local allowedTests = process.args
|
||||
for _, test in discoverTests("src") do
|
||||
-- If we are given any arguments, we only run those tests, otherwise,
|
||||
-- we run all the tests
|
||||
-- If we are given any arguments, we only run those tests, otherwise,
|
||||
-- we run all the tests
|
||||
|
||||
-- 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 `.spec.luau` extension
|
||||
local baseName = string.match(test, "([^/\\]+)$")
|
||||
-- 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 `.spec.luau` extension
|
||||
local baseName = string.match(test, "([^/\\]+)$")
|
||||
|
||||
local withoutExt = string.sub(test, 1, -11)
|
||||
local baseNameWithoutExt = string.match(withoutExt, "([^/\\]+)$")
|
||||
local withoutExt = string.sub(test, 1, -11)
|
||||
local baseNameWithoutExt = string.match(withoutExt, "([^/\\]+)$")
|
||||
|
||||
local isAllowed = #process.args == 0
|
||||
or table.find(allowedTests, test)
|
||||
or table.find(allowedTests, withoutExt)
|
||||
or table.find(allowedTests, baseName)
|
||||
or table.find(allowedTests, baseNameWithoutExt)
|
||||
local isAllowed = #process.args == 0
|
||||
or table.find(allowedTests, test)
|
||||
or table.find(allowedTests, withoutExt)
|
||||
or table.find(allowedTests, baseName)
|
||||
or table.find(allowedTests, baseNameWithoutExt)
|
||||
|
||||
local constructors = {
|
||||
case = frktest.test.case,
|
||||
suite = frktest.test.suite,
|
||||
}
|
||||
|
||||
local constructors = {
|
||||
case = frktest.test.case,
|
||||
suite = frktest.test.suite,
|
||||
}
|
||||
if not isAllowed then
|
||||
constructors.case = frktest.test.skip.case
|
||||
constructors.suite = frktest.test.skip.suite
|
||||
end
|
||||
|
||||
if not isAllowed then
|
||||
constructors.case = frktest.test.skip.case
|
||||
constructors.suite = frktest.test.skip.suite
|
||||
end
|
||||
|
||||
require(`../../{test}`)(setmetatable(constructors, { __index = frktest.test }))
|
||||
require(`../../{test}`)(setmetatable(constructors, { __index = frktest.test }))
|
||||
end
|
||||
|
||||
reporter.init()
|
||||
|
|
|
@ -11,7 +11,8 @@ local STYLE = table.freeze({
|
|||
end,
|
||||
|
||||
report = function(name: string, state: "success" | "error" | "skip", elapsed: number)
|
||||
local state_color: stdio.Color = if state == "success" then "green"
|
||||
local state_color: stdio.Color = if state == "success"
|
||||
then "green"
|
||||
elseif state == "error" then "red"
|
||||
elseif state == "skip" then "yellow"
|
||||
else error("Invalid test state")
|
||||
|
@ -39,15 +40,13 @@ function ReporterExt.init()
|
|||
end)
|
||||
|
||||
frktest.test.on_test_leave(function(test)
|
||||
print(
|
||||
STYLE.report(
|
||||
test.name,
|
||||
if test.failed then "error" else "success",
|
||||
print(STYLE.report(
|
||||
test.name,
|
||||
if test.failed then "error" else "success",
|
||||
|
||||
-- Await receival of the timestamp and convert the difference to ms
|
||||
(os.clock() - recv_ts()) * 1000
|
||||
)
|
||||
)
|
||||
-- Await receival of the timestamp and convert the difference to ms
|
||||
(os.clock() - recv_ts()) * 1000
|
||||
))
|
||||
end)
|
||||
|
||||
frktest.test.on_test_skipped(function(test)
|
||||
|
|
|
@ -5,12 +5,12 @@ local process = require("@lune/process")
|
|||
local CommandBuilder = require("./lib/exec")
|
||||
|
||||
process.exit(
|
||||
CommandBuilder.new("~/.rokit/bin/luau-lsp")
|
||||
:withArg("analyze")
|
||||
:withArgs({ "--settings", ".vscode/settings.json" })
|
||||
:withArgs({ "--ignore", "'**/.pesde/**'" })
|
||||
:withArgs({ "--ignore", "'./test-files/**'" })
|
||||
:withArg(".")
|
||||
:withStdioStrategy("forward")
|
||||
:exec().code
|
||||
CommandBuilder.new("~/.rokit/bin/luau-lsp")
|
||||
:withArg("analyze")
|
||||
:withArgs({ "--settings", ".vscode/settings.json" })
|
||||
:withArgs({ "--ignore", "'**/.pesde/**'" })
|
||||
:withArgs({ "--ignore", "'./test-files/**'" })
|
||||
:withArg(".")
|
||||
:withStdioStrategy("forward")
|
||||
:exec().code
|
||||
)
|
Loading…
Reference in a new issue