[CMake] Test properties
Belcourt, Kenneth
kbelco at sandia.gov
Tue Mar 15 14:44:57 EDT 2011
Hi,
Another add_test() question. I reuse the same test directory because
I run both Fortran and C executables on the same test and the input
files are so large that I don't want to replicate the entire test
hierarchy. The problem is that I need to remove files both before I
run the first Fortran tests (this assumes I've done a previous run)
and then remove files again before I run the C executable tests. I
have CMake code (below) but the remove files only happens once before
the first Fortran tests run even though I have the remove files in
there twice.
Is there any way to add a pre or post per test hook where I can remove
files or run other commands (or perhaps there's undocumented test
properties that I can use to do this)?
-- Noel
Here's what I mean.
# list of files I need to remove
set(Bwr_Files ...)
# remove the files
file(REMOVE ${Bwr_Files})
# Fortran executable
add_test(
NAME bwr_fmelcor
WORKING_DIRECTORY ${Bwr_Dir}
COMMAND fmelcor.x BWR_v2-0.inp
)
# remove the output files before running C executable
# this remove never happens
file(REMOVE ${Bwr_Files})
# C executables
add_test(
NAME bwr_melcor
WORKING_DIRECTORY ${Bwr_Dir}
COMMAND melcor.x BWR_v2-0.inp
)
# Make C executables run after Fortran does
SET_TESTS_PROPERTIES (bwr_melcor PROPERTIES DEPENDS bwr_fmelcor)
More information about the CMake
mailing list