<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">My guess is that the command prompt is seeing the .py extension and automatically invoking the python interpreter for you. On other platforms it looks for the #!/usr/bin/env python which won’t work on windows.What you should do is use the FindPythonInterp cmake module to find your python executable and specify the interpreter to execute in your add test line. https://cmake.org/cmake/help/v3.3/module/FindPythonInterp.html</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Something like the following should work (I have not tested so the syntax might need some slight tweaks).</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">include(FindPythonInterp)</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">add_test(NAME sample_test COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/sample_test.py WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} )</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <div id="bloop_sign_1456324285098635008" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Matthew Keeler<br></div></div><p class="airmail_on">On February 24, 2016 at 09:15:10, George Ryan (<a href="mailto:george.ryan@geospectrum.ca">george.ryan@geospectrum.ca</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>Hi,
<br>
<br>I am having difficulty getting a python script to run a C++ subprocess
<br>on Window 7 using VS2013. On Linux, the following code works fine, but
<br>on Windows, from the command line I get the following output:
<br>
<br>Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
<br>Copyright (C) Microsoft Corporation.  All rights reserved.
<br>
<br>Running tests...
<br>Test project C:/work/s/sandbox/ctestpy/b
<br>    Start 1: sample_test
<br>1/1 Test #1: sample_test ......................***Not Run   0.00 sec
<br>
<br>0% tests passed, 1 tests failed out of 1
<br>
<br>Total Test time (real) =   0.06 sec
<br>
<br>The following tests FAILED:
<br>          1 - sample_test (BAD_COMMAND)
<br>Errors while running CTest
<br>NMAKE : fatal error U1077: 'echo' : return code '0x8'
<br>Stop.
<br>
<br>No matter what options I supply to ctest, I can't seem to get any
<br>additional insight. I am assuming that for some reason the
<br>WORKING_DIRECTORY isn't being obeyed on Windows?
<br>
<br>If I run the python script manually from the command prompt, it works
<br>fine. The python executable is in my $PATH.On Linux I am using CMake
<br>3.3.1, and on Windows I have CMake 3.2.3.
<br>
<br>----
<br>
<br>sample.cpp
<br>
<br>int main()
<br>{
<br>  return 0;
<br>}
<br>
<br>--------------
<br>
<br>sample_test.py
<br>
<br>#!/usr/bin/env python
<br>import sys
<br>import subprocess
<br>
<br>sample = subprocess.Popen("./sample")
<br>sample.wait()
<br>if sample.returncode != 0:
<br>    sys.exit(1)
<br>else:
<br>    sys.exit(0)
<br>~
<br>------------------------
<br>
<br>CMakeLists.txt
<br>
<br>cmake_minimum_required(VERSION 3.0)
<br>project(sampleprg)
<br>
<br>enable_testing()
<br>
<br>add_executable( sample sample.cpp )
<br>
<br>add_test(NAME sample_test
<br>         COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/sample_test.py
<br>         WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} )
<br>
<br>
<br>
<br>
<br>--  
<br>
<br>Powered by www.kitware.com
<br>
<br>Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
<br>
<br>Kitware offers various services to support the CMake community. For more information on each offering, please visit:
<br>
<br>CMake Support: http://cmake.org/cmake/help/support.html
<br>CMake Consulting: http://cmake.org/cmake/help/consulting.html
<br>CMake Training Courses: http://cmake.org/cmake/help/training.html
<br>
<br>Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
<br>
<br>Follow this link to subscribe/unsubscribe:
<br>http://public.kitware.com/mailman/listinfo/cmake
<br></div></div></span></blockquote></body></html>