From fea8ad3d654e497ba83315f26902647dd64f561e Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Apr 2026 21:52:57 +0800 Subject: add --dot output --- tests/plugins/show/xmake.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/plugins/show/xmake.lua (limited to 'tests/plugins/show/xmake.lua') diff --git a/tests/plugins/show/xmake.lua b/tests/plugins/show/xmake.lua new file mode 100644 index 000000000..7077424f3 --- /dev/null +++ b/tests/plugins/show/xmake.lua @@ -0,0 +1,15 @@ +add_rules("mode.debug", "mode.release") + +target("core") + set_kind("static") + add_files("src/core.c") + +target("ui") + set_kind("static") + add_deps("core") + add_files("src/ui.c") + +target("app") + set_kind("binary") + add_deps("core", "ui") + add_files("src/main.c") -- cgit v1.3.1 From 4e94d5537ac3673c353942d58535212968836d6d Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 18 Apr 2026 22:11:17 +0800 Subject: improve show test --- tests/plugins/show/src/net.c | 1 + tests/plugins/show/test.lua | 31 +++++++++++++++++++++++++++---- tests/plugins/show/xmake.lua | 7 ++++++- 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 tests/plugins/show/src/net.c (limited to 'tests/plugins/show/xmake.lua') diff --git a/tests/plugins/show/src/net.c b/tests/plugins/show/src/net.c new file mode 100644 index 000000000..abde7c554 --- /dev/null +++ b/tests/plugins/show/src/net.c @@ -0,0 +1 @@ +int net(void) { return 0; } diff --git a/tests/plugins/show/test.lua b/tests/plugins/show/test.lua index 4152338f3..3e360a4d6 100644 --- a/tests/plugins/show/test.lua +++ b/tests/plugins/show/test.lua @@ -5,7 +5,7 @@ function test_depgraph_json(t) local graph = json.decode(outdata) t:are_equal(graph.root_targets, {"app"}) - t:require(#graph.targets == 3) + t:require(#graph.targets == 4) local entries = {} for _, target in ipairs(graph.targets) do @@ -13,7 +13,8 @@ function test_depgraph_json(t) end t:are_equal(entries.core.deps, {}) t:are_equal(entries.ui.deps, {"core"}) - t:are_equal(entries.app.deps, {"core", "ui"}) + t:are_equal(entries["ext::net"].deps, {"core"}) + t:are_equal(entries.app.deps, {"core", "ui", "ext::net"}) end function test_depgraph_json_for_single_target(t) @@ -21,13 +22,32 @@ function test_depgraph_json_for_single_target(t) local graph = json.decode(outdata) t:are_equal(graph.root_targets, {"app"}) - t:require(#graph.targets == 3) + t:require(#graph.targets == 4) local names = {} for _, target in ipairs(graph.targets) do table.insert(names, target.name) end - t:are_equal(names, {"core", "ui", "app"}) + t:require(table.contains(names, "core")) + t:require(table.contains(names, "ui")) + t:require(table.contains(names, "ext::net")) + t:require(table.contains(names, "app")) +end + +function test_depgraph_json_namespace(t) + local outdata = os.iorunv("xmake", {"show", "--info=depgraph", "--target=ext::net", "--json"}) + local graph = json.decode(outdata) + + t:are_equal(graph.root_targets, {"ext::net"}) + t:require(#graph.targets == 2) + + local entries = {} + for _, target in ipairs(graph.targets) do + entries[target.name] = target + end + t:require(entries["ext::net"]) + t:are_equal(entries["ext::net"].deps, {"core"}) + t:are_equal(entries.core.deps, {}) end function test_depgraph_tree(t) @@ -35,6 +55,7 @@ function test_depgraph_tree(t) 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("ext::net", 1, true)) t:require(outdata:find("|-- ", 1, true)) t:require(outdata:find("\\-- ", 1, true)) end @@ -46,6 +67,8 @@ function test_depgraph_dot(t) 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('"ext::net" -> "core"', 1, true)) + t:require(outdata:find('"app" -> "ext::net"', 1, true)) t:require(outdata:find("}", 1, true)) end diff --git a/tests/plugins/show/xmake.lua b/tests/plugins/show/xmake.lua index 7077424f3..15344a72a 100644 --- a/tests/plugins/show/xmake.lua +++ b/tests/plugins/show/xmake.lua @@ -9,7 +9,12 @@ target("ui") add_deps("core") add_files("src/ui.c") +target("ext::net") + set_kind("static") + add_deps("core") + add_files("src/net.c") + target("app") set_kind("binary") - add_deps("core", "ui") + add_deps("core", "ui", "ext::net") add_files("src/main.c") -- cgit v1.3.1