[CMake] piping commands to executable

Yngve Inntjore Levinsen yngve.levinsen at gmail.com
Wed May 18 13:46:37 EDT 2011


Dear developers,

I have a bit of an issue with ctest. In our project we usually generate a binary which we pipe in scripts with the commands we want to execute (some defined parser language). Now at first I would have liked to do something like
ADD_TEST(testsample "executable < script.txt") 
ADD_TEST(testsample executable < script.txt) 
or perhaps
ADD_TEST(testsample "executable" "< script.txt") 

The first one fails because "executable < script.txt" is not found anywhere. The second and third just hangs (the executable will enter interactive mode if it does not get anything piped in, much like how python behaves).

I solved this before by adding tests which were executing a simple bash script, where the command
executable < script.txt
was added. This works, but then when I want to do memory checks etc, that will not work since the memory check is done on the bash script and not the actual process (or so it seems to me). Is there any clever solution on how to pipe commands into an interpreter. As an example, you could show me how to do this test perhaps:
echo 'print "hello"' | python

I apologize if I am using wrong terms or if this is easily found in the documentation. My understanding of piping in and out and right and left is slightly limited...


Thanks,
Yngve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110518/1d06de80/attachment.htm>


More information about the CMake mailing list