CTest support design issue
Andreas Pakulat
apaku at gmx.de
Sat Dec 22 21:36:30 UTC 2012
Hi,
On Sat, Dec 22, 2012 at 9:29 PM, Sergey Vidyuk <sir.vestnik at gmail.com> wrote:
> I really dislike one place in the
> CMakeProjectVisitor::visit( const AddTestAst * test)
> function and want to change it. It's "else" statement which handles
> kde4_add_unit_test macro specific situation. This code looks like kludge,
> smells like kludge, probably it is a kludge :)
>
> The worst in this code is: there is a path to a test which is correctly
> calculated using some logick. Kdevelop drops the directory and calculates the
> path again in CTestUtils::createTestSuites using actually wrong logick.
>
> For example one can imagine the situation with a command line calculator
> project:
> --- CMakeLists.txt ---
> add_executable(calc calc.cpp)
> add_test(NAME multiply COMMAND ${CMAKE_SOURCE_DIR}/check.sh 4
> $<TARGET_FILE:calc> 2*2)
> add_test(NAME add COMMAND ${CMAKE_SOURCE_DIR}/check.sh 5 $<TARGET_FILE:calc>
> 3+2)
> ---
> with check.sh like
> --- check.sh ---
> #!/bin/bash -e
> EXPECTED=$1
> shift
> test ${EXPECTED} -eq $($@)
> ---
> Directory ommited in a visitor function will be impossible to calculate later.
>
> I see two differen approaches to fix it:
> 1. Track stack trace in a macro call or function call visitor function in
> order to be able to check if add_test is called from within kde4_add_unit_test
> and apply the logick to extract target name from executable passed.
> 2. Create Ast for kde4_add_unit_test macro and handle it as builtin cmake
> function. By adding target and test.
>
> From my point of view the second way is much better since there will be no
> indirect target name extraction. What do you think about it?
Without having looked at the code itself, why does the cmake plugin
actually require to handle something specially for kde4_add_unit_test?
Its a normal cmake macro so the parser should be able to understand
it. It might be useful to do something special for it on a higher
layer, but I guess thats a general problem in the cmake plugin there
is no layering.
Andreas
More information about the KDevelop-devel
mailing list