View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0011734CMakeCTestpublic2011-01-20 13:312011-05-02 14:46
ReporterDavid Cole 
Assigned ToBen Boeckel 
PriorityhighSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 2.8.4 
Target VersionCMake 2.8.4Fixed in VersionCMake 2.8.4 
Summary0011734: Regression from 2.8.3 : add_test in subdir incorrectly keeps cwd at top level CMAKE_BINARY_DIR
DescriptionThe 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;
}
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0024974)
David Cole (manager)
2011-01-20 16:37

Fix pushed to 'next'
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d94f9c6487b324e7453deff15c8968acba23d98f [^]
(0026372)
David Cole (manager)
2011-05-02 14:46

Closing resolved issues that have not been updated in more than 3 months.

 Issue History
Date Modified Username Field Change
2011-01-20 13:31 David Cole New Issue
2011-01-20 13:55 David Cole Assigned To => Ben Boeckel
2011-01-20 13:55 David Cole Status new => assigned
2011-01-20 16:37 David Cole Note Added: 0024974
2011-01-20 16:37 David Cole Status assigned => resolved
2011-01-20 16:37 David Cole Fixed in Version => CMake 2.8.4
2011-01-20 16:37 David Cole Resolution open => fixed
2011-05-02 14:46 David Cole Note Added: 0026372
2011-05-02 14:46 David Cole Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team