From 2977b60e567922969e54ee19f1fb5115510755f5 Mon Sep 17 00:00:00 2001 From: V1K1NGbg Date: Thu, 22 Aug 2024 17:48:58 -0300 Subject: Teal: convert luarocks.test.busted --- src/luarocks/test/busted.lua | 53 ------------------------------------------ src/luarocks/test/busted.tl | 55 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 53 deletions(-) delete mode 100644 src/luarocks/test/busted.lua create mode 100644 src/luarocks/test/busted.tl (limited to 'src') diff --git a/src/luarocks/test/busted.lua b/src/luarocks/test/busted.lua deleted file mode 100644 index c73909cf..00000000 --- a/src/luarocks/test/busted.lua +++ /dev/null @@ -1,53 +0,0 @@ - -local busted = {} - -local fs = require("luarocks.fs") -local deps = require("luarocks.deps") -local path = require("luarocks.path") -local dir = require("luarocks.dir") -local queries = require("luarocks.queries") - -local unpack = table.unpack or unpack - -function busted.detect_type() - if fs.exists(".busted") then - return true - end - return false -end - -function busted.run_tests(test, args) - if not test then - test = {} - end - - local ok, bustedver, where = deps.fulfill_dependency(queries.new("busted"), nil, nil, nil, "test_dependencies") - if not ok then - return nil, bustedver - end - - local busted_exe - if test.busted_executable then - busted_exe = test.busted_executable - else - busted_exe = dir.path(path.root_dir(where), "bin", "busted") - - -- Windows fallback - local busted_bat = dir.path(path.root_dir(where), "bin", "busted.bat") - - if not fs.exists(busted_exe) and not fs.exists(busted_bat) then - return nil, "'busted' executable failed to be installed" - end - end - - local err - ok, err = fs.execute(busted_exe, unpack(args)) - if ok then - return true - else - return nil, err or "test suite failed." - end -end - - -return busted diff --git a/src/luarocks/test/busted.tl b/src/luarocks/test/busted.tl new file mode 100644 index 00000000..832a81b7 --- /dev/null +++ b/src/luarocks/test/busted.tl @@ -0,0 +1,55 @@ + +local record busted +end + +local fs = require("luarocks.fs") +local deps = require("luarocks.deps") +local path = require("luarocks.path") +local dir = require("luarocks.dir") +local queries = require("luarocks.queries") +local install = require("luarocks.cmd.install") + +local type Test = require("luarocks.core.types.rockspec").Test + +function busted.detect_type(): boolean + if fs.exists(".busted") then + return true + end + return false +end + +function busted.run_tests(test: Test, args: {string}): boolean, string + if not test then + test = {} + end + + local ok, bustedver, where = deps.fulfill_dependency(queries.new("busted"), nil, nil, nil, "test_dependencies") + if not ok then + return nil, bustedver + end + + local busted_exe: string + if test.busted_executable then + busted_exe = test.busted_executable + else + busted_exe = dir.path(path.root_dir(where), "bin", "busted") + + -- Windows fallback + local busted_bat = dir.path(path.root_dir(where), "bin", "busted.bat") + + if not fs.exists(busted_exe) and not fs.exists(busted_bat) then + return nil, "'busted' executable failed to be installed" + end + end + + local err: string + ok, err = fs.execute(busted_exe, table.unpack(args)) + if ok then + return true + else + return nil, err or "test suite failed." + end +end + + +return busted -- cgit v1.2.3-55-g6feb