From 46c2b559e9eff1a3a553844bbf450e5214d6f5a6 Mon Sep 17 00:00:00 2001 From: V1K1NGbg Date: Thu, 22 Aug 2024 17:49:01 -0300 Subject: Teal: convert luarocks.cmd.test --- src/luarocks/cmd/test.lua | 48 ------------------------------------------ src/luarocks/cmd/test.tl | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 48 deletions(-) delete mode 100644 src/luarocks/cmd/test.lua create mode 100644 src/luarocks/cmd/test.tl diff --git a/src/luarocks/cmd/test.lua b/src/luarocks/cmd/test.lua deleted file mode 100644 index b353bd80..00000000 --- a/src/luarocks/cmd/test.lua +++ /dev/null @@ -1,48 +0,0 @@ - ---- Module implementing the LuaRocks "test" command. --- Tests a rock, compiling its C parts if any. -local cmd_test = {} - -local util = require("luarocks.util") -local test = require("luarocks.test") - -function cmd_test.add_to_parser(parser) - local cmd = parser:command("test", [[ -Run the test suite for the Lua project in the current directory. - -If the first argument is a rockspec, it will use it to determine the parameters -for running tests; otherwise, it will attempt to detect the rockspec. - -Any additional arguments are forwarded to the test suite. -To make sure that test suite flags are not interpreted as LuaRocks flags, use -- -to separate LuaRocks arguments from test suite arguments.]], - util.see_also()) - :summary("Run the test suite in the current directory.") - - cmd:argument("rockspec", "Project rockspec.") - :args("?") - cmd:argument("args", "Test suite arguments.") - :args("*") - cmd:flag("--prepare", "Only install dependencies needed for testing only, but do not run the test") - - cmd:option("--test-type", "Specify the test suite type manually if it was ".. - "not specified in the rockspec and it could not be auto-detected.") - :argname("") -end - -function cmd_test.command(args) - if args.rockspec and args.rockspec:match("rockspec$") then - return test.run_test_suite(args.rockspec, args.test_type, args.args, args.prepare) - end - - table.insert(args.args, 1, args.rockspec) - - local rockspec, err = util.get_default_rockspec() - if not rockspec then - return nil, err - end - - return test.run_test_suite(rockspec, args.test_type, args.args, args.prepare) -end - -return cmd_test diff --git a/src/luarocks/cmd/test.tl b/src/luarocks/cmd/test.tl new file mode 100644 index 00000000..b1189d47 --- /dev/null +++ b/src/luarocks/cmd/test.tl @@ -0,0 +1,53 @@ + +--- Module implementing the LuaRocks "test" command. +-- Tests a rock, compiling its C parts if any. +local record cmd_test +end + +local util = require("luarocks.util") +local test = require("luarocks.test") + +local type Parser = require("luarocks.vendor.argparse").Parser + +local type Args = require("luarocks.core.types.args").Args + +function cmd_test.add_to_parser(parser: Parser) + local cmd = parser:command("test", [[ +Run the test suite for the Lua project in the current directory. + +If the first argument is a rockspec, it will use it to determine the parameters +for running tests; otherwise, it will attempt to detect the rockspec. + +Any additional arguments are forwarded to the test suite. +To make sure that test suite flags are not interpreted as LuaRocks flags, use -- +to separate LuaRocks arguments from test suite arguments.]], + util.see_also()) + :summary("Run the test suite in the current directory.") + + cmd:argument("rockspec", "Project rockspec.") + :args("?") + cmd:argument("args", "Test suite arguments.") + :args("*") + cmd:flag("--prepare", "Only install dependencies needed for testing only, but do not run the test") + + cmd:option("--test-type", "Specify the test suite type manually if it was ".. + "not specified in the rockspec and it could not be auto-detected.") + :argname("") +end + +function cmd_test.command(args: Args): boolean, string, string --! + if args.rockspec and args.rockspec:match("rockspec$") then + return test.run_test_suite(args.rockspec, args.test_type, args.args, args.prepare) + end + + table.insert(args.args, 1, args.rockspec) + + local rockspec, err = util.get_default_rockspec() + if not rockspec then + return nil, err + end + + return test.run_test_suite(rockspec, args.test_type, args.args, args.prepare) +end + +return cmd_test -- cgit v1.2.3-55-g6feb