[CMake] Possible set_tests_properties(ENVIRONMENT) bug?

Scott Gray sgray at inventa.com
Tue May 12 14:34:31 EDT 2009


While trying to research the answer to my question about how to make 
your test program locate its dependent DLL's (see my previous posting 
entitled "add_test and locating dependent DLL's on Windows"), I decided 
to try the recently added ENVIRONMENT property of set_tests_properties 
to set the PATH for the test program. I *think* I have found an issue 
with it, but before I open a bug, I wanted to check to see if this isn't 
operator error.

First, I created a very simple test program:

===== BEGIN: Env_test.cpp ======
#include <stdio.h>
#include <stdlib.h>

void main (int argc, char *argv[])
{
    char *p = getenv("PATH");
    fprintf(stdout, "PATH = %s\n", p);
}
===== END: Env_test.cpp ======

And then the CMakeLists.txt

===== BEGIN: CMakeLists.txt ======
cmake_minimum_required(VERSION 2.7)
enable_testing()

add_executable (Env_test Env_test.cpp)
add_test (Env_test Env_test)

if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
        set (NEWPATH "C:\\some_dir1;C:\\some_dir2;$ENV{PATH}")
        message("NEWPATH = ${NEWPATH}")
        set_tests_properties(Env_test PROPERTIES ENVIRONMENT 
"PATH=${NEWPATH}")
endif()
===== END: CMakeLists.txt ======

When I run 'cmake -G "Visual Studio 8 2005"', I get the message:

    NEWPATH = C:\some_dir1;C:\some_dir2;C:\Program Files\CollabNet...

And if I run Env_test.exe by hand, it properly prints out whatever my 
current PATH is.

However, when I run ctest, the output contained in the LastTest.log shows:

Start testing: May 12 14:03 Eastern Daylight Time
----------------------------------------------------------
Changing directory into: C:/cmake_bug
1/1 Testing: Env_test
1/1 Test: Env_test
Command: "C:/cmake_bug/debug/Env_test.exe"
Directory: C:/cmake_bug
"Env_test" start time: May 12 14:03 Eastern Daylight Time
Output:
----------------------------------------------------------
PATH = C:\some_dir1^M
----------------------------------------------------------
Test Passed.
"Env_test" end time: May 12 14:03 Eastern Daylight Time
"Env_test" time elapsed: 00:00:00
----------------------------------------------------------

End testing: May 12 14:03 Eastern Daylight Time


No matter what I set the PATH to in my CMakeLists.txt, the test program 
always dumps on the first component of the path leading up to the first 
semicolon in the path.

So, is this operator error or a bug in the new feature?  Oh, I'm running 
on last night's build of cmake (version 2.7.20090512).


Thanks,
-scott

-- 
Scott C. Gray
Chief Technologist
ANTs Software, Inc.
Inventa Technologies, Inc.
(W) 856-914-5212
(C) 609-304-3429



More information about the CMake mailing list