local O=game:GetService("\084\101\115\116\083\101\114\118\105\099\101")local z=require(script.Parent.getEnv)local b=require(script.Parent.ModuleCache)local i=require(script.Parent.generateScriptHeader)return function()b.clear()local X=O:GetChildren()for X,y in ipairs(X)do local q=loadstring(i(y)..y.Source)local M=z(y)M.require=b.require setfenv(q,M)local h,o=pcall(q)if not h then local z=string.find(o,"\037\046\037\046\037\046\"\093")if z then o=string.sub(o,z+6)end O:Error(string.format("\069\114\114\111\114 \114\117\110\110\105\110\103\058 \037\115",o),y)end end end
local TestService = game:GetService("TestService")

local getEnv = require(script.Parent.getEnv)
local ModuleCache = require(script.Parent.ModuleCache)
local generateScriptHeader = require(script.Parent.generateScriptHeader)

return function()
    ModuleCache.clear()

    local scripts = TestService:GetChildren()

    for _, scriptObject in ipairs(scripts) do
        local scriptFn = loadstring(generateScriptHeader(scriptObject) .. scriptObject.Source)

        local env = getEnv(scriptObject)
        env.require = ModuleCache.require

        setfenv(scriptFn, env)

        local success, result = pcall(scriptFn)
        if not success then
            local found = string.find(result, "%.%.%.\"]")
            if found then
                result = string.sub(result, found + 6)
            end
            TestService:Error(string.format("Error running: %s", result), scriptObject)
        end
    end
end
