CTest support design issue

Sergey Vidyuk sir.vestnik at gmail.com
Sat Dec 22 20:29:31 UTC 2012


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 
--- 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> 
with check.sh like
--- check.sh ---
#!/bin/bash -e
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?

Sergey Vidyuk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20121223/71bb54e5/attachment.sig>

More information about the KDevelop-devel mailing list