[CMake] add_test WORKING_DIRECTORY option

David Cole david.cole at kitware.com
Mon Mar 14 17:34:30 EDT 2011


What is the cwd when your test starts?

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...)

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


> 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.


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



On Mon, Mar 14, 2011 at 5:19 PM, Belcourt, Kenneth <kbelco at sandia.gov> wrote:
> Hi,
>
> The documentation states that the add_test() WORKING_DIRECTORY option will
> run the test in the given directory.  This add_test rule in my
> CMakeLists.txt file:
>
> add_test(
>  NAME bwr_melgen
>  WORKING_DIRECTORY ${Bwr_Dir}
>  COMMAND melgen.x ${Bwr_Dir}/_BWR_v2-0.inp
> )
>
> with ${Bwr_Dir} == /scratch/trunk_tests/_ShorterRuns/Plant_Decks/BWR
>
> results in this command line.
>
> 1: Test command: /scratch/trunk/tools/melgen.x
> /scratch/trunk_tests/_ShorterRuns/Plant_Decks/BWR/_BWR_v2-0.inp
>  Test #1: bwr_melgen
>
> Due to problems in the code base, the output is not generated in the test
> directory and this is a known code problem.
>
> Is there an easy way to change the WORKING_DIRECTORY behavior to have it
> always cd to the working directory beforehand, then run the test, (pushd /
> popd behavior) etc..., rather than making, in our case the unsafe
> assumption, that the program correctly writes the files where they should
> be?  Frankly, if ctest would always cd into the test directory, then we'd
> never have a problem though we would never uncover the incorrect file
> handling behavior either.
>
> Anyone know of a way to change the working directory behavior?
>
> -- Noel
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list