summaryrefslogtreecommitdiff
path: root/tests/plugins/project/test.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-22 22:34:42 +0800
committerruki <[email protected]>2024-03-22 22:34:42 +0800
commit6c3c781351f7f145a3c5524751705dcef4387e37 (patch)
treea6fb4769c1f3d88ec96e1bd53b7ab2137f2242cc /tests/plugins/project/test.lua
parent5f320b5a8c3e4ee411d602ac8cd43f2d2aca2563 (diff)
add generator test
Diffstat (limited to 'tests/plugins/project/test.lua')
-rw-r--r--tests/plugins/project/test.lua52
1 files changed, 51 insertions, 1 deletions
diff --git a/tests/plugins/project/test.lua b/tests/plugins/project/test.lua
index 0de70cdba..168e71f1a 100644
--- a/tests/plugins/project/test.lua
+++ b/tests/plugins/project/test.lua
@@ -15,7 +15,7 @@ function test_vsxmake(t)
os.cd(tempdir)
-- create project
- os.runv("xmake", {"create", projname})
+ os.vrunv("xmake", {"create", projname})
os.cd(projname)
-- set config
@@ -55,3 +55,53 @@ function test_vsxmake(t)
os.cd(os.scriptdir())
os.tryrm(tempdir)
end
+
+function test_compile_commands(t)
+ local projname = "testproj"
+ local tempdir = os.tmpfile()
+ os.mkdir(tempdir)
+ os.cd(tempdir)
+
+ -- create project
+ os.vrunv("xmake", {"create", projname})
+ os.cd(projname)
+
+ -- generate compile_commands
+ os.vrunv("xmake", {"project", "-k", "compile_commands"})
+
+ -- test autoupdate
+ io.insert("xmake.lua", 1, 'add_rules("plugin.compile_commands.autoupdate", {outputdir = ".vscode", lsp = "clangd"})')
+ os.vrun("xmake")
+
+ -- clean up
+ os.cd(os.scriptdir())
+ os.tryrm(tempdir)
+end
+
+function test_cmake(t)
+ local cmake = find_tool("cmake")
+ if not cmake then
+ return t:skip("cmake not found")
+ end
+ local projname = "testproj"
+ local tempdir = os.tmpfile()
+ os.mkdir(tempdir)
+ os.cd(tempdir)
+
+ -- create project
+ os.vrunv("xmake", {"create", projname})
+ os.cd(projname)
+
+ -- generate compile_commands
+ os.vrunv("xmake", {"project", "-k", "cmake"})
+
+ -- test build
+ os.mkdir("build")
+ os.cd("build")
+ os.vrunv(cmake.program, {".."})
+ os.vrunv(cmake.program, {"--build", "."})
+
+ -- clean up
+ os.cd(os.scriptdir())
+ os.tryrm(tempdir)
+end