0

I'm trying to add a test that compare the output of two executable that I compiled.

set (TEST_PARAMETERS <(./${EXECUTABLE_ORIGINAL}) <(./${EXECUTABLE_TRANSFORMED}))    
add_test(NAME compare-output-${TEST_NAME} COMMAND "diff" ${TEST_PARAMETERS})

My problem is that CMake is inserting nasty double quotes everywhere and of course it makes some trouble with the redirection.

So the generated test command is the following

/usr/bin/diff "<" "(" "./original_code_array4" ")" "<" "(" "./transformed_code_array4" ")"

The working command should be

/usr/bin/diff <(./original_code_array4) <(./transformed_code_array4)

Is there a way to avoid this double quotes generation ? It's really annoying !

Valentin Clement
  • 241
  • 3
  • 13
  • If `diff` is anyway OS dependent, wouldn't it be enough to move the call to an external shell script? – Florian Apr 15 '16 at 07:13
  • Of course it would work, but I would like to know if there is a solution only using cmake – Valentin Clement Apr 15 '16 at 07:15
  • Yes I tried ... It doesn't work – Valentin Clement Apr 15 '16 at 07:25
  • See this answer for launching multiple commands in a single add_test call: http://stackoverflow.com/a/3071370/1465625 – hank Apr 15 '16 at 07:34
  • 1
    You [cannot use redirection with add_test](http://stackoverflow.com/questions/36304289/how-to-use-redirection-in-cmake-add-test/36305542#36305542). Possible solution would be creating wrapper script around of `diff` which accepts names of compared files as arguments. – Tsyvarev Apr 15 '16 at 07:42
  • Thanks, I have plenty of solution to run my case. The only thing I wanna know, is if it is possible to do it only with add_test ... so if it is not ok .. this is my answer – Valentin Clement Apr 15 '16 at 07:44
  • @ValentinClement I've done some testing. And since `add_test()` - as commented - does not run in any shell context, you could add the shell call yourself. Could you give `set (TEST_PARAMETERS "<(./${EXECUTABLE_ORIGINAL}) <(./${EXECUTABLE_TRANSFORMED})")` and `add_test(NAME compare-output-${TEST_NAME} COMMAND bash -c "diff ${TEST_PARAMETERS}")` a try? I used `bash`, but just insert whatever shell you use. And please be aware of the extra quotes I've added. Hope this helps. – Florian Apr 17 '16 at 18:57

0 Answers0