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
|
import("core.base.json")
function test_depgraph_json(t)
local outdata = os.iorunv("xmake", {"show", "--info=depgraph", "--json"})
local graph = json.decode(outdata)
t:are_equal(graph.root_targets, {"app"})
t:require(#graph.targets == 3)
local entries = {}
for _, target in ipairs(graph.targets) do
entries[target.name] = target
end
t:are_equal(entries.core.deps, {})
t:are_equal(entries.ui.deps, {"core"})
t:are_equal(entries.app.deps, {"core", "ui"})
end
function test_depgraph_json_for_single_target(t)
local outdata = os.iorunv("xmake", {"show", "--info=depgraph", "--target=app", "--json"})
local graph = json.decode(outdata)
t:are_equal(graph.root_targets, {"app"})
t:require(#graph.targets == 3)
local names = {}
for _, target in ipairs(graph.targets) do
table.insert(names, target.name)
end
t:are_equal(names, {"core", "ui", "app"})
end
function test_depgraph_tree(t)
local outdata = os.iorunv("xmake", {"show", "--info=depgraph"})
t:require(outdata:find("app", 1, true))
t:require(outdata:find("core", 1, true))
t:require(outdata:find("ui", 1, true))
t:require(outdata:find("├── ", 1, true) or outdata:find("+-- ", 1, true))
t:require(outdata:find("└── ", 1, true) or outdata:find("\\-- ", 1, true))
end
function test_depgraph_dot(t)
local outdata = os.iorunv("xmake", {"show", "--info=depgraph", "--dot"})
t:require(outdata:find("digraph {", 1, true))
t:require(outdata:find('"core"', 1, true))
t:require(outdata:find('"ui" -> "core"', 1, true))
t:require(outdata:find('"app" -> "core"', 1, true))
t:require(outdata:find('"app" -> "ui"', 1, true))
t:require(outdata:find("}", 1, true))
end
function test_depgraph_dot_for_single_target(t)
local outdata = os.iorunv("xmake", {"show", "--info=depgraph", "--target=ui", "--dot"})
t:require(outdata:find("digraph {", 1, true))
t:require(outdata:find('"core"', 1, true))
t:require(outdata:find('"ui" -> "core"', 1, true))
t:require(not outdata:find('"app"', 1, true))
end
|