[CMake] Boost.Test, cmake, and visual studio
Steve M. Robbins
steve at sumost.ca
Tue Aug 28 22:04:29 EDT 2007
Hi,
Anyone out there with advice for writing test cases with Boost.Test
under windows / msvc ?
My first trial was, following the advice of the Boost.Test authors
(http://www.boost.org/libs/test/doc/usage/msvc_net.html), to create a
custom build step in visual studio. This produces output that visual
studio can parse and display as a list of errors to step through.
Such rules, of course, get blown away each time CMake runs.
So I cracked the CMake book and started learning about
ADD_CUSTOM_TARGET. After some struggle I learned about
ENABLE_TESTING / ADD_TEST and tried that route instead.
I got as far as the following:
ENABLE_TESTING()
ADD_TEST( runTestSuite
${EXECUTABLE_OUTPUT_PATH}/testSuite --report_level=no
)
This creates a "RUN_TESTS" rule that I can "build" to run the tests --
just what I was after. However, ctest swallows all the output from
testSuite so I don't know which test failed nor which line.
Therefore, I don't have the nice error list. If I could run ctest
with the --verbose option, I think it would be perfect, but I don't
know how to convince cmake to pass --verbose to ctest. I looked in
vain for a variable to set. Any idea?
Reluctantly, I gave up and went back to ADD_CUSTOM_TARGET. The
following gives me exactly what I want:
PROJECT(examples)
[...]
ADD_EXECUTABLE( testSuite ${testSuite_SRCS} )
set( testSuite_EXE C:/blah/examples/debug/testSuite.exe )
ADD_CUSTOM_TARGET( RUN_TESTS
${testSuite_EXE} --report_level=no
# ${examples_BINARY_DIR}/testSuite.exe --report_level=no
# ${PROJECT_BINARY_DIR}/testSuite.exe --report_level=no
# ${EXECUTABLE_OUTPUT_PATH}/testSuite --report_level=no
DEPENDS ${testSuite_EXE}
)
But there are two flaws that I need help with.
1. I need a better way to find the test binary. The three
commented-out lines are things I tried but none worked. There must be
a variable that tells me where testSuite.exe is, but I can't find it.
Note that EXECUTABLE_OUTPUT_PATH is not set; however, the analogous
usage in ADD_TEST (see above) *did* work!
2. The dependency on testSuite_EXE doesn't work: if I modify one of
the testSuite sources, running the custom target doesn't rebuild
testSuite.exe. Maybe this is a symptom of #1?
Thanks for reading this far.
Any suggestions welcome.
-Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://public.kitware.com/pipermail/cmake/attachments/20070828/e492da31/attachment.pgp
More information about the CMake
mailing list