summaryrefslogtreecommitdiff
path: root/tests/plugins/show/test.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2026-04-18 21:52:57 +0800
committerruki <[email protected]>2026-04-20 09:35:36 +0800
commitfea8ad3d654e497ba83315f26902647dd64f561e (patch)
tree7576a6c7b0005da49bc381769af96fabb038f11c /tests/plugins/show/test.lua
parent51be800bddfa199774206393cb8d7e0749f59756 (diff)
add --dot output
Diffstat (limited to 'tests/plugins/show/test.lua')
-rw-r--r--tests/plugins/show/test.lua58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/plugins/show/test.lua b/tests/plugins/show/test.lua
new file mode 100644
index 000000000..451b13ade
--- /dev/null
+++ b/tests/plugins/show/test.lua
@@ -0,0 +1,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