View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001786CMakeCTestpublic2005-04-21 14:032008-10-08 16:33
Reportermaik 
Assigned ToBrad King 
PrioritylowSeverityfeatureReproducibilityalways
StatusclosedResolutionwon't fix 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001786: CMake asserts
DescriptionI would like to have some kind of Assert function
that integrates with CTest in some way. For most of my libraries, I just make my own as follows:

#define Assert(pred, message) { \
    if(!(pred)) { \
        cerr << "Assert failed in " << __FILE__ << " line : "<< __LINE__ << endl; \
        cerr << (message) << endl; \
        return -1; \
    } \
}

This works for the most part since it stops execution and returns -1, thus failing the test.

If CMake could generate an include file (something like CREATE_TEST_SOURCELIST) that contained an assert function that integrates with ctest, test could be written to use these asserts. This would provide a great deal of flexibility for testing error management. For example, error messages would show up in the a visual studio test run. Also, command line tests could print the test message and its result together and wait until after all tests are finished to print out error messages. Better yet, an error log could be generated from the accumulated error messages.

All sorts of possibilites emerge with an integrated assert function. I think with this added feature CMake's testing would be on par with
Junit or python's unittest module.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0013775)
Brad King (manager)
2008-10-08 16:32

I don't think this belongs in CTest proper. CTest by default uses the program return value to determine pass/fail status. Test properties may be set to check the output text with regular expressions:

http://www.cmake.org/cmake/help/cmake2.6docs.html#section_Properties%20on%20Tests [^]

A project is free to define its own helper macro and define corresponding regular expressions.

 Issue History
Date Modified Username Field Change
2007-08-31 11:28 Alex Neundorf Assigned To System Admin => David Cole
2008-10-08 16:23 David Cole Assigned To David Cole => Brad King
2008-10-08 16:32 Brad King Note Added: 0013775
2008-10-08 16:33 Brad King Status assigned => closed
2008-10-08 16:33 Brad King Resolution open => won't fix


Copyright © 2000 - 2018 MantisBT Team