first commit

This commit is contained in:
Reid 2023-07-18 22:22:52 -07:00
commit 5302ecc6cc
43 changed files with 2530 additions and 0 deletions

View file

@ -0,0 +1,9 @@
/// <reference types="@rbxts/testez/globals" />
export = (): void => {
describe("Integration Test", () => {
it("should be true", () => {
expect(true).to.equal(true)
})
})
}

View file

@ -0,0 +1,5 @@
{
"properties": {
"Disabled": true
}
}

View file

@ -0,0 +1,12 @@
import { test } from "./util/tests"
import { roots } from "./util/roots"
const [completed, result] = test(roots)
if (completed) {
if (!result) {
error("Tests have failed.", 0)
}
} else {
error(result, 0)
}

View file

@ -0,0 +1,14 @@
{
"ReplicatedStorage": {
"goopler": {},
"tests": {}
},
"ServerScriptService": {
"goopler": {}
},
"StarterPlayer": {
"StarterPlayerScripts": {
"goopler": {}
}
}
}

View file

@ -0,0 +1,33 @@
import * as rootTree from "./rootTree.json"
type Node = { [key: string]: Node }
type RootNode = {
[key in keyof Services]?: Node;
}
function getRoots(node: Node, parent: Instance): Instance[] {
const roots: Instance[] = []
for (const [key, subNode] of pairs(node)) {
const subRoots = getRoots(
subNode,
parent.FindFirstChild(key) ?? error(`Could not find child ${key}`)
)
subRoots.move(0, subRoots.size(), roots.size(), roots)
}
if (roots.isEmpty()) {
roots.push(parent)
}
return roots
}
function getAllRoots(node: RootNode): Instance[] {
const roots: Instance[] = []
for (const [key, subNode] of pairs(node)) {
const subRoots = getRoots(subNode, game.GetService(key))
subRoots.move(0, subRoots.size(), roots.size(), roots)
}
return roots
}
export const roots = getAllRoots(rootTree)

View file

@ -0,0 +1,16 @@
import { TestBootstrap } from "@rbxts/testez"
export function test(
roots: Instance[]
): LuaTuple<[completed: true, result: boolean] | [completed: false, error: string]> {
print()
const call = xpcall(
() => {
const results = TestBootstrap.run(roots)
return results.failureCount === 0
},
(err) => debug.traceback(tostring(err))
)
print()
return call
}