diff options
| author | ruki <[email protected]> | 2023-10-29 10:56:33 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-10-29 15:36:07 +0800 |
| commit | 9998f1b9a224068fde448052758bc23e2150745f (patch) | |
| tree | 08b44bf0e13fc510efced7065678f1d594429908 | |
| parent | 042c51144c1a918d75493a94094e29aeafd924ff (diff) | |
test compile
| -rw-r--r-- | tests/actions/test/src/compile.cpp | 7 | ||||
| -rw-r--r-- | tests/actions/test/xmake.lua | 5 | ||||
| -rw-r--r-- | xmake/actions/test/main.lua | 25 |
3 files changed, 36 insertions, 1 deletions
diff --git a/tests/actions/test/src/compile.cpp b/tests/actions/test/src/compile.cpp new file mode 100644 index 000000000..a65e463c4 --- /dev/null +++ b/tests/actions/test/src/compile.cpp @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char** argv) +{ + static_assert(0, "error"); + return 0; +} diff --git a/tests/actions/test/xmake.lua b/tests/actions/test/xmake.lua index 5369ee0a4..9af72dbfe 100644 --- a/tests/actions/test/xmake.lua +++ b/tests/actions/test/xmake.lua @@ -13,3 +13,8 @@ for _, file in ipairs(os.files("src/test_*.cpp")) do add_tests("fail_output", {fail_outputs = {"hello2 .*", "hello xmake"}}) end +target("test_compile") + set_kind("binary") + set_default(false) + add_files("src/compile.cpp") + add_tests("compile", {build_only = true}) diff --git a/xmake/actions/test/main.lua b/xmake/actions/test/main.lua index bea5f5ba2..1b046fcee 100644 --- a/xmake/actions/test/main.lua +++ b/xmake/actions/test/main.lua @@ -30,11 +30,32 @@ import("async.runjobs") import("private.action.run.runenvs") import("private.service.remote_build.action", {alias = "remote_build_action"}) import("actions.build.main", {rootdir = os.programdir(), alias = "build_action"}) +import("actions.build.build", {rootdir = os.programdir(), alias = "build_target"}) -- test target function _do_test_target(target, opt) opt = opt or {} + -- TODO + if opt.build_only then + local errors + local passed = try { + function () + print("build...") + build_target(target:name()) + return true + end, + catch { + function (errs) + errors = tostring(errs) + print("xxxx") + end + } + } + print("ssssssssssssss") + return passed, errors + end + -- get run environments local envs = opt.runenvs if not envs then @@ -361,7 +382,9 @@ function main() -- build targets with the given tests first local targetnames = {} for _, testinfo in table.orderpairs(tests) do - table.insert(targetnames, testinfo.target:name()) + if not testinfo.build_only then + table.insert(targetnames, testinfo.target:name()) + end end build_action.build_targets(targetnames) |
