[CMake] add_test WORKING_DIRECTORY option

Belcourt, Kenneth kbelco at sandia.gov
Mon Mar 14 18:19:54 EDT 2011


Hi David,

On Mar 14, 2011, at 3:34 PM, David Cole wrote:

> What is the cwd when your test starts?

The directory where the executable runs from (/scratch/trunk/tools),  
not the directory containing the test input.

> It should be ${Bwr_Dir} according to your email's WORKING_DIRECTORY  
> arg.
> (write a little code that prints it out right at the top of the
> program's main before doing anything else...)

I've confirmed with a getcwd() call at the top of the program.

> What version of ctest is this? (I assume 2.8.4?)

Yes.

> always cd to the working directory beforehand, then run the test,  
> (pushd /
>> popd behavior) etc...
>
> It sets the WorkingDirectory in the process execution data structures
> before launching the process. How this translates into process
> launching behavior varies from platform to platform, but it should be
> working essentially the same way as what you suggest.

No, doesn't seem to be.

> Perhaps: are you also setting the WORKING_DIRECTORY test property? Is
> that being set to a different value?

Don't think so, here's what CMake is writing to the CTestTestfile.cmake

ADD_TEST(bwr_melgen "/scratch/trunk/tools/melgen.x" "/scratch/ 
trunk_tests/_ShorterRuns/Plant Decks/BWR/_BWR_v2-0.inp")

SET_TESTS_PROPERTIES(bwr_melgen PROPERTIES  WORKING_DIRECTORY "/ 
scratch/trunk_tests/_ShorterRuns/Plant Decks/BWR")

-- Noel


Here's the expected output when I cd to the input test directory and  
run the executable.

[kbelco at wsblade001 BWR]$ /scratch/trunk/tools/melgen.x  _BWR_v2-0.inp
cwd = /scratch/trunk_tests/_ShorterRuns/Plant Decks/BWR



Here's what I get when I run ctest.

[kbelco at wsblade001 tools]$ ctest --verbose
UpdateCTestConfiguration  from :/scratch/trunk/tools/ 
DartConfiguration.tcl
UpdateCTestConfiguration  from :/scratch/trunk/tools/ 
DartConfiguration.tcl
Test project /scratch/trunk/tools
Constructing a list of tests
Done constructing a list of tests
Checking test dependency graph...
test 1
     Start 1: bwr_melgen

1: Test command: /scratch/trunk/tools/melgen.x /scratch/trunk_tests/ 
_ShorterRuns/Plant\ Decks/BWR/_BWR_v2-0.inp
1: Test timeout computed to be: 9.99988e+06
1: cwd = /scratch/trunk/tools




More information about the CMake mailing list