diff options
| author | ruki <[email protected]> | 2023-10-29 21:13:50 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-29 21:13:50 -0500 |
| commit | 200ff1397695c0db71e71174a851b6ddc9f00aa4 (patch) | |
| tree | f2a47ac089ecbcd16c031dcf426a37bc08f17d02 | |
| parent | b2d7cbac430a9f3e4207956c6417e429b0d1c455 (diff) | |
| parent | f6b8b4611d94781afcf7ca945ae4cbfce6561455 (diff) | |
Merge pull request #4336 from mikezackles/test-compile-fail
Support testing for expected compilation failure instead of expected compilation success
| -rw-r--r-- | tests/actions/test/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/actions/test/main.lua | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/tests/actions/test/xmake.lua b/tests/actions/test/xmake.lua index 4823ca5da..641b4c764 100644 --- a/tests/actions/test/xmake.lua +++ b/tests/actions/test/xmake.lua @@ -17,4 +17,4 @@ target("test_10") set_kind("binary") set_default(false) add_files("src/compile.cpp") - add_tests("compile", {build_only = true}) + add_tests("compile", {build_should_fail = true}) diff --git a/xmake/actions/test/main.lua b/xmake/actions/test/main.lua index 56a52ad0b..5958325bc 100644 --- a/xmake/actions/test/main.lua +++ b/xmake/actions/test/main.lua @@ -35,8 +35,8 @@ import("actions.build.main", {rootdir = os.programdir(), alias = "build_action"} function _do_test_target(target, opt) opt = opt or {} - -- test build only - if opt.build_only then + -- early out: results were computed during build + if opt.build_should_fail then return opt.passed, opt.errors end @@ -384,10 +384,12 @@ function main() local targetnames = {} for _, testinfo in table.orderpairs(tests) do local targetname = testinfo.target:name() - if testinfo.build_only then - local passed, errors = _try_build_target(targetname) - testinfo.passed = passed - testinfo.errors = errors + if testinfo.build_should_fail then + local built, _ = _try_build_target(targetname) + testinfo.passed = not built + if built then + testinfo.errors = "Build succeeded when failure was expected" + end else table.insert(targetnames, targetname) end |
