diff options
| author | ruki <[email protected]> | 2024-03-22 10:58:58 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-22 10:58:58 +0800 |
| commit | c6528086f3815263f2d9c88bdae4f687609d0f51 (patch) | |
| tree | b8dd474d03df0bc4d45539960074af7b18ad598d | |
| parent | 79c2f18baaa956c6a39888916993265184217f41 (diff) | |
| parent | 6c3c781351f7f145a3c5524751705dcef4387e37 (diff) | |
Merge pull request #4863 from xmake-io/generator
add generator test
| -rw-r--r-- | tests/plugins/project/test.lua | 52 |
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 |
