summaryrefslogtreecommitdiff
path: root/tests/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins')
-rw-r--r--tests/plugins/show/src/core.c1
-rw-r--r--tests/plugins/show/src/main.c1
-rw-r--r--tests/plugins/show/src/net.c1
-rw-r--r--tests/plugins/show/src/ui.c1
-rw-r--r--tests/plugins/show/test.lua81
-rw-r--r--tests/plugins/show/xmake.lua20
6 files changed, 105 insertions, 0 deletions
diff --git a/tests/plugins/show/src/core.c b/tests/plugins/show/src/core.c
new file mode 100644
index 000000000..87a413095
--- /dev/null
+++ b/tests/plugins/show/src/core.c
@@ -0,0 +1 @@
+int core(void) { return 0; }
diff --git a/tests/plugins/show/src/main.c b/tests/plugins/show/src/main.c
new file mode 100644
index 000000000..78f2de106
--- /dev/null
+++ b/tests/plugins/show/src/main.c
@@ -0,0 +1 @@
+int main(void) { return 0; }
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/src/ui.c b/tests/plugins/show/src/ui.c
new file mode 100644
index 000000000..c15794f4d
--- /dev/null
+++ b/tests/plugins/show/src/ui.c
@@ -0,0 +1 @@
+int ui(void) { return 0; }
diff --git a/tests/plugins/show/test.lua b/tests/plugins/show/test.lua
new file mode 100644
index 000000000..dea98c204
--- /dev/null
+++ b/tests/plugins/show/test.lua
@@ -0,0 +1,81 @@
+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 == 4)
+
+ 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["ext::net"].deps, {"core"})
+ t:are_equal(entries.app.deps, {"core", "ui", "ext::net"})
+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 == 4)
+
+ local names = {}
+ for _, target in ipairs(graph.targets) do
+ table.insert(names, target.name)
+ end
+ 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)
+ 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("ext::net", 1, true))
+ t:require(outdata:find("|-- ", 1, true))
+ t:require(outdata:find("\\-- ", 1, true))
+end
+
+function test_depgraph_dot(t)
+ local outdata = os.iorunv("xmake", {"show", "--info=depgraph", "--format=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('"ext::net" -> "core"', 1, true))
+ t:require(outdata:find('"app" -> "ext::net"', 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", "--format=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
diff --git a/tests/plugins/show/xmake.lua b/tests/plugins/show/xmake.lua
new file mode 100644
index 000000000..15344a72a
--- /dev/null
+++ b/tests/plugins/show/xmake.lua
@@ -0,0 +1,20 @@
+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("ext::net")
+ set_kind("static")
+ add_deps("core")
+ add_files("src/net.c")
+
+target("app")
+ set_kind("binary")
+ add_deps("core", "ui", "ext::net")
+ add_files("src/main.c")