5

I'm trying to pass parameters to a gtest test suite from cmake:

add_test(NAME craft_test
         COMMAND craft --gtest_output='xml:report.xml')

The issue is that these parameters are being passed surrounded by quotes, why? It looks like a bug, is there a good way for avoiding it?

$ ctest -V
UpdateCTestConfiguration  from :/usr/local/src/craft/build-analyze/DartConfiguration.tcl
UpdateCTestConfiguration  from :/usr/local/src/craft/build-analyze/DartConfiguration.tcl
Test project /usr/local/src/craft/build-analyze
Constructing a list of tests
Done constructing a list of tests
Checking test dependency graph...
Checking test dependency graph end
test 1
    Start 1: craft_test

1: Test command: /usr/local/src/craft/build-analyze/craft "--gtest_output='xml:report.xml'"
1: Test timeout computed to be: 9.99988e+06
1: WARNING: unrecognized output format "'xml" ignored.
1: [==========] Running 1 test from 1 test case.
1: [----------] Global test environment set-up.
1: [----------] 1 test from best_answer_test
1: [ RUN      ] best_answer_test.test_sample
1: [       OK ] best_answer_test.test_sample (0 ms)
1: [----------] 1 test from best_answer_test (0 ms total)
1: 
1: [----------] Global test environment tear-down
1: [==========] 1 test from 1 test case ran. (0 ms total)
1: [  PASSED  ] 1 test.
1/1 Test #1: craft_test .......................   Passed    0.00 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.00 sec
oblitum
  • 11,380
  • 6
  • 54
  • 120

1 Answers1

9

It's not the quotes that CMake adds that is the problem here; it's the single quotes in 'xml:report.xml' that are at fault.

You should do:

add_test(NAME craft_test
     COMMAND craft --gtest_output=xml:report.xml)
Fraser
  • 74,704
  • 20
  • 238
  • 215
  • 1
    This does the trick, although when running the test outside ctest I passed args with the single or double quotes and it worked ok (as can be checked [here](http://code.google.com/p/googletest/wiki/AdvancedGuide#Generating_an_XML_Report) and [here](http://www.ibm.com/developerworks/aix/library/au-googletestingframework.html). I'm afraid I may stumble on such quoting problem when I'm required to use them for some reason. – oblitum Jun 23 '13 at 21:17
  • 2
    I agree that the quotes escaping is a bit of a pain in CMake, but I think in this case you should be OK. The only reason I can see you'd need quotes there is if your filename or path had spaces, and then you can do `COMMAND craft "--gtest_output=xml:rep ort.xml"` I think. – Fraser Jun 23 '13 at 21:31