[cmake-developers] [CMake 0011734]: Regression from 2.8.3 : add_test in subdir incorrectly keeps cwd at top level CMAKE_BINARY_DIR
Mantis Bug Tracker
mantis at public.kitware.com
Thu Jan 20 13:31:54 EST 2011
The following issue has been SUBMITTED.
======================================================================
http://public.kitware.com/Bug/view.php?id=11734
======================================================================
Reported By: David Cole
Assigned To:
======================================================================
Project: CMake
Issue ID: 11734
Category: CTest
Reproducibility: always
Severity: major
Priority: high
Status: new
Target Version: CMake 2.8.4
======================================================================
Date Submitted: 2011-01-20 13:31 EST
Last Modified: 2011-01-20 13:31 EST
======================================================================
Summary: Regression from 2.8.3 : add_test in subdir
incorrectly keeps cwd at top level CMAKE_BINARY_DIR
Description:
The code in the "Steps to Reproduce" section, after running:
cmake
cmake --build . --config Debug
ctest -C Debug
...produces files ending in ".args.txt" as follows:
dir /s /b *.args.txt
C:\...\echoargs-test0.args.txt
C:\...\echoargs-test1.args.txt
C:\...\echoargs-test3.args.txt
C:\...\sub\echoargs-test2.args.txt
Actual:
"echoargs-test3.args.txt" is in the top level directory
Expected:
The file "echoargs-test3.args.txt" should be in the "sub" subdir... Just like
the corresponding file for test2.
Apparently, only the NAME/COMMAND signature of add_test is affected by this bug.
Thanks to Andy Bauer for the bug report.
I reproduced this using the attached code on Windows 7 with Visual Studio 2010.
Andy originally discovered this on a Linux box.
Steps to Reproduce:
# top level "CMakeLists.txt"
cmake_minimum_required(VERSION 2.8)
project(SmallAndFast)
include(CTest)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_executable(echoargs echoargs.c)
add_test(test0 echoargs test0)
add_test(NAME test1 COMMAND echoargs test1 1 $<CONFIGURATION>)
add_subdirectory(sub)
# subdir "sub/CMakeLists.txt"
add_executable(echoargsSub ../echoargs.c)
add_test(test2 echoargsSub test2 1 2)
add_test(NAME test3 COMMAND echoargsSub test3 1 2 3 $<CONFIGURATION>)
// top level "echoargs.c"
#include <direct.h>
#include <stdio.h>
int main(int argc, const char* argv[])
{
int i = 0;
FILE *fp = (FILE *) 0;
char buf[4096];
char filename[256];
const char *cwd = _getcwd(buf, 4095);
const char *name = argc>1 ? argv[1] : "unknown";
for (; i<argc; ++i)
{
fprintf(stdout, "%s\n", argv[i]);
}
if (cwd != NULL)
{
fprintf(stdout, "cwd='%s'\n", cwd);
}
// When this test is over, there should be an "echoargs.txt" left in the
// current working directory (the one that was current when the test was
// run...)
sprintf(filename, "echoargs-%s.args.txt", name);
fp = fopen(filename, "w");
if (NULL != fp)
{
i = 0;
for (; i<argc; ++i)
{
fprintf(fp, "%s\n", argv[i]);
}
if (cwd != NULL)
{
fprintf(fp, "cwd='%s'\n", cwd);
}
fclose(fp);
}
return 0;
}
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2011-01-20 13:31 David Cole New Issue
======================================================================
More information about the cmake-developers
mailing list