forked from Roblox/roact-rodux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.lua
71 lines (55 loc) · 1.7 KB
/
spec.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--[[
Loads our library and all of its dependencies, then runs tests using TestEZ.
]]
-- If you add any dependencies, add them to this table so they'll be loaded!
local LOAD_MODULES = {
{"lib", "Library"},
{"modules/rodux/lib", "Rodux"},
{"modules/roact/lib", "Roact"},
{"modules/testez/lib", "TestEZ"},
}
-- This makes sure we can load Lemur and other libraries that depend on init.lua
package.path = package.path .. ";?/init.lua"
-- If this fails, make sure you've run `lua bin/install-dependencies.lua` first!
local lemur = require("modules.lemur")
--[[
Collapses ModuleScripts named 'init' into their parent folders.
This is the same behavior as the collapsing mechanism from rbxpacker.
]]
local function collapse(root)
local init = root:FindFirstChild("init")
if init then
init.Name = root.Name
init.Parent = root.Parent
for _, child in ipairs(root:GetChildren()) do
child.Parent = init
end
root:Destroy()
root = init
end
for _, child in ipairs(root:GetChildren()) do
if child:IsA("Folder") then
collapse(child)
end
end
return root
end
-- Create a virtual Roblox tree
local habitat = lemur.Habitat.new()
-- We'll put all of our library code and dependencies here
local Root = lemur.Instance.new("Folder")
Root.Name = "Root"
-- Load all of the modules specified above
for _, module in ipairs(LOAD_MODULES) do
local container = lemur.Instance.new("Folder", Root)
container.Name = module[2]
habitat:loadFromFs(module[1], container)
end
collapse(Root)
-- Load TestEZ and run our tests
local TestEZ = habitat:require(Root.TestEZ)
local results = TestEZ.TestBootstrap:run(Root.Library, TestEZ.Reporters.TextReporter)
-- Did something go wrong?
if results.failureCount > 0 then
os.exit(1)
end