MantisBT - CMake
View Issue Details
0009647CMakeCTestpublic2009-10-02 11:322016-06-10 14:31
Derek Bruening 
Zach Mullen 
normalminoralways
closedmoved 
CMake-2-6 
 
0009647: bogus errors from ctest when using extended scripting with settings inside a function
When using a ctest script that uses extended scripting (ctest_start(), ctest_configure(), etc.) where variables are set inside a function but not at global scope, everything works fine except that at the end of the run ctest prints out a bogus error:

  CMake Error: Some required settings in the configuration file were missing:
  CTEST_SOURCE_DIRECTORY = /work/dr/win32/internal/clients/drmemory/tests/..
  CTEST_BINARY_DIRECTORY = (Null)
  CTEST_COMMAND = /usr/bin/ctest

Presumably this is due to those settings being inside a function and ctest is looking for them at the global level.

You can see an example ctest file that produces this kind of error here:

  http://code.google.com/p/dynamorio/source/browse/trunk/suite/runsuite.cmake [^]
No tags attached.
tgz bug9647.tgz (905) 2009-10-06 23:12
https://public.kitware.com/Bug/file/2536/bug9647.tgz
Issue History
2009-10-02 11:32Derek BrueningNew Issue
2009-10-02 11:51Bill HoffmanNote Added: 0017901
2009-10-02 11:51Bill HoffmanStatusnew => assigned
2009-10-02 11:51Bill HoffmanAssigned To => Zach Mullen
2009-10-02 11:55Derek BrueningNote Added: 0017902
2009-10-02 19:06Derek BrueningNote Added: 0017917
2009-10-06 23:12Derek BrueningFile Added: bug9647.tgz
2009-10-06 23:14Derek BrueningNote Added: 0018002
2009-10-08 14:38Zach MullenNote Added: 0018039
2009-12-07 14:02Zach MullenNote Added: 0018714
2009-12-07 14:02Zach MullenStatusassigned => resolved
2009-12-07 14:02Zach MullenResolutionopen => no change required
2009-12-07 14:47Derek BrueningNote Added: 0018716
2009-12-07 14:47Derek BrueningStatusresolved => feedback
2009-12-07 14:47Derek BrueningResolutionno change required => reopened
2009-12-07 15:41Zach MullenNote Added: 0018717
2009-12-07 15:45Zach MullenNote Edited: 0018717
2009-12-07 16:34Derek BrueningNote Added: 0018718
2011-01-18 11:16David ColeNote Added: 0024858
2011-01-21 19:06David ColeStatusfeedback => assigned
2016-06-10 14:27Kitware RobotNote Added: 0041602
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionreopened => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0017901)
Bill Hoffman   
2009-10-02 11:51   
I think ctest still needs those variables, and they can not be in a function scope, you can promote them up.
(0017902)
Derek Bruening   
2009-10-02 11:55   
The variables are set in the same function scope as the ctest_build(), ctest_test(), etc. commands are issued. It all works fine, so they must not be required to be in global scope.

I tried cmake-2.8.0-rc2-Linux-i386 and it has the same behavior.
(0017917)
Derek Bruening   
2009-10-02 19:06   
Further explanation of why checking for a global value of CTEST_BINARY_DIRECTORY is nonsensical for my usage:

My ctest -S script configures, builds, and tests many different build configurations, invoking ctest_test(), etc. for each of many different values for CTEST_BINARY_DIRECTORY. ctest handles this just fine (including ctest_submit()) except at the very end of the script, after successfully building and running tests for all those configurations, it issues this warning.
(0018002)
Derek Bruening   
2009-10-06 23:14   
I attached a sample project that shows the error w/ cmake built from cvs TOT:

% tar xzf ../bug9647.tgz
% mkdir suite
% cd suite
% /extsw/pkgs/cmake/exports/bin/ctest -S ../src/runtests.cmake
CMake Error: Some required settings in the configuration file were missing:
CTEST_SOURCE_DIRECTORY = /work/bugs-cmake/bug9647/foo/src
CTEST_BINARY_DIRECTORY = (Null)
CTEST_COMMAND = /extsw/pkgs/cmake/exports/bin/ctest

if you run with -V you'll see that everything works as expected and this is a superfluous error at the end:

% /extsw/pkgs/cmake/exports/bin/ctest -V -S ../src/runtests.cmake
Run dashboard with model Experimental
   Source directory: /work/bugs-cmake/bug9647/foo/src
   Build directory: /work/bugs-cmake/bug9647/foo/suite/build_build1
   Cannot locate CTest configuration: /work/bugs-cmake/bug9647/foo/src/CTestConfig.cmake
   Delay the initialization of CTest
   Site:
   Build name: build1
   Use Experimental tag: 20091007-0314
Configure project
   Each . represents 1024 bytes of output
    . Size of output: 0K
Build project
   Each symbol represents 1024 bytes of output.
   '!' represents an error and '*' a warning.
    . Size of output: 0K
   0 Compiler errors
   0 Compiler warnings
Test project /work/bugs-cmake/bug9647/foo/suite/build_build1
    Start 1: main_success
1/2 Test #1: main_success ..................... Passed 0.00 sec
    Start 2: main_fail
2/2 Test 0000002: main_fail ........................***Failed 0.00 sec

50% tests passed, 1 tests failed out of 2

Total Test time (real) = 0.01 sec

The following tests FAILED:
          2 - main_fail (Failed)
CMake Error: Some required settings in the configuration file were missing:
CTEST_SOURCE_DIRECTORY = /work/bugs-cmake/bug9647/foo/src
CTEST_BINARY_DIRECTORY = (Null)
CTEST_COMMAND = /extsw/pkgs/cmake/exports/bin/ctest
(0018039)
Zach Mullen   
2009-10-08 14:38   
The cmCTestScriptHandler expects the CTEST_BINARY_DIRECTORY variable to be set at global scope, independent of what scope the other handlers are invoked in.


// make sure the required info is here
  if (this->SourceDir.empty() ||
      this->BinaryDir.empty() ||
      this->CTestCmd.empty())
    {
    std::string msg = "CTEST_SOURCE_DIRECTORY = ";
    msg += (!this->SourceDir.empty()) ? this->SourceDir.c_str() : "(Null)";
    msg += "\nCTEST_BINARY_DIRECTORY = ";
    msg += (!this->BinaryDir.empty()) ? this->BinaryDir.c_str() : "(Null)";
    msg += "\nCTEST_COMMAND = ";
    msg += (!this->CTestCmd.empty()) ? this->CTestCmd.c_str() : "(Null)";
    cmSystemTools::Error(
      "Some required settings in the configuration file were missing:\n",
      msg.c_str());
    return 4;
    }

The CTEST_BINARY_DIRECTORY is referenced many times in the script handler code.
(0018714)
Zach Mullen   
2009-12-07 14:02   
These variables are needed at global scope in our current logic.
(0018716)
Derek Bruening   
2009-12-07 14:47   
Can you elaborate on why they are needed at global scope? Because they sure don't
seem to be needed at global scope.
I set them inside functions extensively in multiple projects' uses of CMake
and, like in the example above, everything works fine: configuring, building,
testing, and submitting results. Is there some functionality I'm not exercising that is not going to work right when these vars are not at global scope?
(0018717)
Zach Mullen   
2009-12-07 15:41   
(edited on: 2009-12-07 15:45)
When the script handler is invoked on the current script, it calls the RunConfigurationDashboard function if all three of the variables mentioned here have been set to a non-empty string. If they are not set, the configuration dashboard is not run. This function performs any required cleaning of the binary directory, source checkouts/update, and runs ctest on the directory.

(0018718)
Derek Bruening   
2009-12-07 16:34   
But cleaning of the binary directory and running ctest works just fine when these are set at local scope, as evidenced by my own usage and the sample I posted above. So I have yet to see evidence that these are needed at global level. What I see is that they only need to be set at the scope in which the ctest commands are executed. So far I still believe that CTest has a bug where an incorrect assumption is made that these settings must be set at global level, even when there are no ctest commands at the global level.
(0024858)
David Cole   
2011-01-18 11:16   
Looking at "older" "feedback" status bugs today... is this still an issue that we want to address moving forward? If so, please remove the "feedback" status and just set it to "assigned"... If not, please resolve it.

Thanks.
(0041602)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.