Skip to content

Commit cfdac1b

Browse files
committed
feature: lute test runs all the tests
1 parent 27aa3e3 commit cfdac1b

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
run: rm .luaurc && mv .luaurc.ci .luaurc
4444

4545
- name: Run Luau Tests
46-
run: find tests -name "*.test.luau" | xargs -I {} ${{ steps.build_lute.outputs.exe_path }} run {}
46+
run: ${{ steps.build_lute.outputs.exe_path }} test
4747

4848
run-lute-cxx-unittests:
4949
runs-on: ${{ matrix.os }}

lute/cli/commands/test/init.luau

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
local finder = require("@self/finder")
22
local luau = require("@std/luau")
33
local path = require("@std/path")
4+
local ps = require("@std/process")
5+
local testtypes = require("@std/test/types")
6+
local runner = require("@std/test/runner")
7+
local reporter = require("@std/test/reporter")
48
local test = require("@std/test")
59

610
local function printHelp()
@@ -85,6 +89,15 @@ local function listtests()
8589
end
8690
end
8791

92+
local function runtests(env: testtypes.testenvironment, runner: testtypes.testrunner, reporter: testtypes.testreporter)
93+
local result = runner(env)
94+
reporter(result)
95+
if result.failed ~= 0 then
96+
ps.exit(1)
97+
end
98+
ps.exit(0)
99+
end
100+
88101
local function main(...: string)
89102
local args = { ... }
90103
local testPaths = {}
@@ -105,6 +118,9 @@ local function main(...: string)
105118

106119
if isListMode then
107120
listtests()
121+
else
122+
local env = test._registered()
123+
runtests(env, runner.run, reporter.simple)
108124
end
109125
end
110126

tests/cli/test.test.luau

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ test.suite("lute test", function(suite)
2626
assert.neq(result.stdout:find("Usage:", 1, true), nil)
2727
end)
2828

29-
suite:case("lute test runs successfully", function(assert)
30-
-- Run lute test without arguments
31-
local result = process.run({ lutePath, "test" })
29+
suite:case("lute test runs tests in discovery folder", function(assert)
30+
-- Run lute test on tests/cli/discovery folder
31+
local result = process.run({ lutePath, "test", "tests/cli/discovery" })
3232

33-
-- Check that it succeeds
33+
-- Check that it runs tests and succeeds
3434
assert.eq(result.exitcode, 0)
3535
end)
3636

0 commit comments

Comments
 (0)