first commit
This commit is contained in:
commit
5302ecc6cc
43 changed files with 2530 additions and 0 deletions
9
tests/integration/integration.spec.ts
Normal file
9
tests/integration/integration.spec.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/// <reference types="@rbxts/testez/globals" />
|
||||
|
||||
export = (): void => {
|
||||
describe("Integration Test", () => {
|
||||
it("should be true", () => {
|
||||
expect(true).to.equal(true)
|
||||
})
|
||||
})
|
||||
}
|
5
tests/runners/run.meta.json
Normal file
5
tests/runners/run.meta.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"properties": {
|
||||
"Disabled": true
|
||||
}
|
||||
}
|
12
tests/runners/run.server.ts
Normal file
12
tests/runners/run.server.ts
Normal 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)
|
||||
}
|
14
tests/runners/util/rootTree.json
Normal file
14
tests/runners/util/rootTree.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ReplicatedStorage": {
|
||||
"goopler": {},
|
||||
"tests": {}
|
||||
},
|
||||
"ServerScriptService": {
|
||||
"goopler": {}
|
||||
},
|
||||
"StarterPlayer": {
|
||||
"StarterPlayerScripts": {
|
||||
"goopler": {}
|
||||
}
|
||||
}
|
||||
}
|
33
tests/runners/util/roots.ts
Normal file
33
tests/runners/util/roots.ts
Normal 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)
|
16
tests/runners/util/tests.ts
Normal file
16
tests/runners/util/tests.ts
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue