View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010065CMakeModulespublic2009-12-18 11:482015-05-04 10:06
Reporterrtward 
Assigned ToPhilip Lowman 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake-2-8 
Target VersionFixed in Version 
Summary0010065: FindGTest.cmake doesn't handle spaces around arguments to TEST / TEST_F macro
DescriptionThe FindGTest.cmake module expects the GTest macro to have the format:

TEST(test_case,test_name)

or

TEST_F(test_case,test_name)

and it fails if there is any space padding between the arguments like this:

TEST( test_case, test_name )

or

TEST_F( test_case, test_name )

I've provided a patch that I believe fixes the problem. It changes line 79 of FindGTest.cmake from:

string(REGEX REPLACE ".*\\(([A-Za-z_0-9]+)[, ]*([A-Za-z_0-9]+)\\).*" "\\1.\\2" test_name ${hit})

to

string(REGEX REPLACE ".*\\(( *[A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit})

adding in regex elements that will catch leading and trailing spaces that pad the macro arguments.
TagsNo tags attached.
Attached Filesdiff file icon FindGTest_fix.diff [^] (234 bytes) 2009-12-18 11:48 [Show Content]

 Relationships
related to 0015553closed FindGTest.cmake doesn't handle all spaces in TEST / TEST_F macro 

  Notes
(0018949)
rtward (reporter)
2009-12-18 17:50

Noticed a bug, the corrected line should be:
string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit})
(0019031)
Philip Lowman (developer)
2010-01-05 00:17

Thanks for the patch, fixed in CVS. Also documented the fact that CMake must be manually rerun after adding/removing tests as part of the source file.

 Issue History
Date Modified Username Field Change
2009-12-18 11:48 rtward New Issue
2009-12-18 11:48 rtward File Added: FindGTest_fix.diff
2009-12-18 17:50 rtward Note Added: 0018949
2010-01-05 00:17 Philip Lowman Note Added: 0019031
2010-01-05 00:17 Philip Lowman Assigned To => Philip Lowman
2010-01-05 00:17 Philip Lowman Status new => resolved
2010-01-05 00:17 Philip Lowman Resolution open => fixed
2010-01-05 01:00 Philip Lowman Status resolved => feedback
2010-01-05 01:00 Philip Lowman Resolution fixed => reopened
2010-01-05 01:01 Philip Lowman Status feedback => resolved
2010-01-05 01:01 Philip Lowman Resolution reopened => fixed
2010-01-05 01:01 Philip Lowman Category CMake => Modules
2010-09-01 00:13 Philip Lowman Status resolved => closed
2015-05-04 10:06 Brad King Relationship added related to 0015553


Copyright © 2000 - 2018 MantisBT Team