[CMake] Establishing TDD workflow
Alexander Neundorf
a.neundorf-work at gmx.net
Sun Nov 30 11:35:11 EST 2008
On Sunday 30 November 2008, Slava Tutushkin wrote:
> Hi all,
>
> I'm only starting with cmake, so my question can be quite lame.
> However, I have read the "Mastering Cmake" and googled a lot about it
> already.
>
> I have executable running the tests built with cmake. Now I need to
> execute it as a part of build process.
>
> I'm building the exec with the following:
>
> add_executable(ut TestUnittest.cpp stdafx.cpp SomeSuite.cpp
> SecondSuite.cpp) target_link_libraries(ut UnitTest++.vsnet2008)
>
> In the search for solution I have tried two approaches:
> 1. Adding
> add_custom_command(TARGET ut POST_BUILD COMMAND ut COMMENT Testing)
> As a result, command runs after succesfull build. Problem here is if
> the test fails, they are not runs again after next build (since the
> executable is not changed and rebuild). But I need it to run each
> build until the tests are succesfull.
>
> 2. When I add
> add_custom_target(ut_test ALL DEPENDS ut COMMAND ut)
> The tests starts running all time, even if previous run was successful
> and the exec was not rebuilt. If I'm not adding "ALL", it is not
> running at all.
> It's ok for now, but it unacceptable in the long term.
>
>
> So, to sum up, what I need:
> 1. If exec dependencies was changed, rebuild exec
> 2. If exec was changed, run exec. If exec was not changed, but last
> exec run was failed, run exec. If exec was not changed and exec
> during last built was successful, don't run exec.
Usually you do:
add_executable(ut TestUnittest.cpp stdafx.cpp SomeSuite.cpp
SecondSuite.cpp)
target_link_libraries(ut UnitTest++.vsnet2008)
add_test(ut_test ut)
And then expect the developer to do a "make test" or "ctest" after building
the project. So there is some manual work involved.
Alex
More information about the CMake
mailing list