| | 1 | = CMake Macro Reference: `boost_test_run_fail` = |
| | 2 | The `boost_test_run_fail` macro creates a Boost regression test that will be built and executed. If |
| | 3 | the test can be built, executed, and exits with a return code that |
| | 4 | is not zero, it will be considered to have passed. |
| | 5 | |
| | 6 | {{{ |
| | 7 | boost_test_run_fail(testname |
| | 8 | [source1 source2 ...] |
| | 9 | [ARGS arg1 arg2... ] |
| | 10 | [COMPILE_FLAGS compileflags] |
| | 11 | [LINK_FLAGS linkflags] |
| | 12 | [LINK_LIBS linklibs] |
| | 13 | [DEPENDS libdepend1 libdepend2 ...]) |
| | 14 | }}} |
| | 15 | |
| | 16 | `testname` is the name of the test. `source1`, `source2`, etc. are the |
| | 17 | source files that will be built and linked into the test |
| | 18 | executable. If no source files are provided, the file "testname.cpp" |
| | 19 | will be used instead. |
| | 20 | |
| | 21 | There are several optional arguments to control how the regression |
| | 22 | test is built and executed: |
| | 23 | |
| | 24 | ARGS:: |
| | 25 | Provides additional arguments that will be passed to the |
| | 26 | test executable when it is run. |
| | 27 | |
| | 28 | COMPILE_FLAGS:: |
| | 29 | Provides additional compilation flags that will be |
| | 30 | used when building this test. For example, one might want to add |
| | 31 | "-DBOOST_SIGNALS_ASSERT=1" to turn on assertions within the library. |
| | 32 | |
| | 33 | LINK_FLAGS:: |
| | 34 | Provides additional flags that will be passed to the |
| | 35 | linker when linking the test excecutable. This option should not |
| | 36 | be used to link in additional libraries; see `LINK_LIBS` and |
| | 37 | `DEPENDS`. |
| | 38 | |
| | 39 | LINK_LIBS:: |
| | 40 | Provides additional libraries against which the test |
| | 41 | executable will be linked. For example, one might provide "expat" |
| | 42 | as options to `LINK_LIBS`, to state that this executable should be |
| | 43 | linked against the external "expat" library. Use `LINK_LIBS` for |
| | 44 | libraries external to Boost; for Boost libraries, use `DEPENDS`. |
| | 45 | |
| | 46 | DEPENDS:: |
| | 47 | States that this test executable depends on and links |
| | 48 | against another Boost library. The argument to `DEPENDS` should be |
| | 49 | the name of a particular variant of a Boost library, e.g., |
| | 50 | `boost_signals-static`. |
| | 51 | |
| | 52 | == Example == |
| | 53 | The following invocation of `boost_test_run_fail` creates an executable test `prg_exec_fail1`, linked against the static version of `boost_prg_exec_monitor`, which should return a non-zero exit code when run. |
| | 54 | |
| | 55 | {{{ |
| | 56 | boost_test_run_fail(prg_exec_fail1 DEPENDS boost_prg_exec_monitor-static) |
| | 57 | }}} |
| | 58 | |
| | 59 | This example is from [http://svn.boost.org/svn/boost/sandbox-branches/boost-cmake/boost_1_34_0/libs/test/test/CMakeLists.txt libs/test/test/CMakeLists.txt]. |
| | 60 | |
| | 61 | == Where Defined == |
| | 62 | This macro is defined in the Boost Testing module in [http://svn.boost.org/svn/boost/sandbox-branches/boost-cmake/boost_1_34_0/tools/build/CMake/BoostTesting.cmake tools/build/CMake/BoostTesting.cmake] |
| | 63 | |
| | 64 | |
| | 65 | == TODO == |
| | 66 | * Improve handling of `DEPENDS`, so that we can specify just the |
| | 67 | library's abstract target (e.g., "boost_signals"), and possibly |
| | 68 | some features required for building the test (e.g., |
| | 69 | `MULTI_THREADED`, `STATIC`). The test macros should then pick the |
| | 70 | best library variant available to meet those features and the |
| | 71 | current build variant (Debug or Release). |