local c,M=pcall(game.GetService,game,"\080\114\111\099\101\115\115\083\101\114\118\105\099\101")local function n(c,M)M=M or{}for c,n in ipairs(c:GetChildren())do if n:IsA("\077\111\100\117\108\101\083\099\114\105\112\116")then table.insert(M,n)end end return M end local F,I=xpcall(function()local c=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local M=n(c.TestEZTests)local F=0 local I=0 local m=0 local H={}for c,M in ipairs(M)do local n=require(M)print(string.format("\037\115",M.Name))for c,M in pairs(n)do local n,C=pcall(M)F=F+1 if n then print(string.format("  \091\080\065\083\083\093 \037\115",c))m=m+1 else print(string.format("  \091\070\065\073\076\093 \037\115",c))I=I+1 local M=string.format("\084\101\115\116\058 \037\115\n\069\114\114\111\114\058 \037\115",c,C)table.insert(H,M)end end end print()print(string.format("\037\115 \116\101\115\116\115 \114\117\110\058 \037\115 \112\097\115\115\101\100\044 \037\115 \102\097\105\108\101\100",F,m,I))if#H>0 then print()print(table.concat(H,"\n\n"))end return I==0 and 0 or 1 end,debug.traceback)local m local H=nil if F then m=I else m=1 H=I end if __LEMUR__ then if H~=nil then print(H)end os.exit(m)elseif c then if H~=nil then print(H)end M:ExitAsync(m)else if H~=nil then error(H,0)end end
--[[
	This test runner is invoked in all the environments that we want to test our
	library in.

	We target Lemur, Roblox Studio, and Roblox-CLI.
]]

-- luacheck: globals __LEMUR__

local isRobloxCli, ProcessService = pcall(game.GetService, game, "ProcessService")

local function findUnitTests(container, foundTests)
	foundTests = foundTests or {}

	for _, child in ipairs(container:GetChildren()) do
		if child:IsA("ModuleScript") then
			table.insert(foundTests, child)
		end
	end

	return foundTests
end

local completed, result = xpcall(function()
	local ReplicatedStorage = game:GetService("ReplicatedStorage")

	local testModules = findUnitTests(ReplicatedStorage.TestEZTests)

	local totalCount = 0
	local failureCount = 0
	local successCount = 0
	local errorMessages = {}

	for _, testModule in ipairs(testModules) do
		local tests = require(testModule)

		print(string.format("%s", testModule.Name))

		for testName, testFunction in pairs(tests) do
			local success, message = pcall(testFunction)
			totalCount = totalCount + 1

			if success then
				print(string.format("  [PASS] %s", testName))
				successCount = successCount + 1
			else
				print(string.format("  [FAIL] %s", testName))
				failureCount = failureCount + 1

				local logMessage = string.format("Test: %s\nError: %s", testName, message)
				table.insert(errorMessages, logMessage)
			end
		end
	end

	print()
	print(string.format("%s tests run: %s passed, %s failed", totalCount, successCount, failureCount))

	if #errorMessages > 0 then
		print()
		print(table.concat(errorMessages, "\n\n"))
	end

	return failureCount == 0 and 0 or 1
end, debug.traceback)

local statusCode
local errorMessage = nil
if completed then
	statusCode = result
else
	statusCode = 1
	errorMessage = result
end

if __LEMUR__ then
	-- Lemur has access to normal Lua OS APIs

	if errorMessage ~= nil then
		print(errorMessage)
	end
	os.exit(statusCode)
elseif isRobloxCli then
	-- Roblox CLI has a special service to terminate the process

	if errorMessage ~= nil then
		print(errorMessage)
	end
	ProcessService:ExitAsync(statusCode)
else
	-- In Studio, we can just throw an error to get the user's attention

	if errorMessage ~= nil then
		error(errorMessage, 0)
	end
end
