From a894313a4bf52f3640bbca945aef078b9a7d58c4 Mon Sep 17 00:00:00 2001 From: Micah Date: Tue, 23 Sep 2025 21:09:13 -0700 Subject: [PATCH] Make script exit with code 1 when tests fail --- .lune/test-plugin.luau | 11 ++++++++++- plugin/run-tests.server.lua | 10 +++++++++- plugin/src/runTests.lua | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.lune/test-plugin.luau b/.lune/test-plugin.luau index 7b8a46f5..88e660bd 100644 --- a/.lune/test-plugin.luau +++ b/.lune/test-plugin.luau @@ -88,9 +88,18 @@ for _, log in logs do stdio.write(`{stdio.color("reset")}\n`) end +local results = luau_execute.get_output(task)[1] +if not results then + error("plugin tests did not return any results") +end + local status = luau_execute.check_status(task) if status == "COMPLETE" then - process.exit(0) + if results.failureCount == 0 then + process.exit(0) + else + process.exit(1) + end else print() print("Task did not finish successfully") diff --git a/plugin/run-tests.server.lua b/plugin/run-tests.server.lua index 0ab3cc05..7afccc2c 100644 --- a/plugin/run-tests.server.lua +++ b/plugin/run-tests.server.lua @@ -8,4 +8,12 @@ local Settings = require(Rojo.Plugin.Settings) Settings:set("logLevel", "Trace") Settings:set("typecheckingEnabled", true) -require(Rojo.Plugin.runTests)(TestEZ) +local results = require(Rojo.Plugin.runTests)(TestEZ) + +-- Roblox's Luau execution gets mad about cyclical tables. +-- Rather than making TestEZ not do that, we just send back the important info. +return { + failureCount = results.failureCount, + successCount = results.successCount, + skippedCount = results.skippedCount, +} diff --git a/plugin/src/runTests.lua b/plugin/src/runTests.lua index b2c7e231..dbe63bfb 100644 --- a/plugin/src/runTests.lua +++ b/plugin/src/runTests.lua @@ -2,5 +2,5 @@ return function(TestEZ) local Rojo = script.Parent.Parent local Packages = Rojo.Packages - TestEZ.TestBootstrap:run({ Rojo.Plugin, Packages.Http, Packages.Log, Packages.RbxDom }) + return TestEZ.TestBootstrap:run({ Rojo.Plugin, Packages.Http, Packages.Log, Packages.RbxDom }) end