2013-12-16 14:35:43 +00:00
|
|
|
# /*-------------------------------------------------------------------------*\
|
2010-10-07 03:00:07 +00:00
|
|
|
# ========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
# \\ / F ield | foam-extend: Open Source CFD
|
2010-10-07 03:00:07 +00:00
|
|
|
# \\ / O peration |
|
2013-12-11 16:09:41 +00:00
|
|
|
# \\ / A nd | For copyright notice see file Copyright
|
2010-10-07 03:00:07 +00:00
|
|
|
# \\/ M anipulation |
|
2013-12-16 14:35:43 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
2010-10-07 03:00:07 +00:00
|
|
|
# License
|
2013-12-11 16:09:41 +00:00
|
|
|
# This file is part of foam-extend.
|
2010-10-07 03:00:07 +00:00
|
|
|
#
|
2013-12-11 16:09:41 +00:00
|
|
|
# foam-extend is free software: you can redistribute it and/or modify it
|
2010-10-07 03:00:07 +00:00
|
|
|
# under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
# Free Software Foundation, either version 3 of the License, or (at your
|
2010-10-07 03:00:07 +00:00
|
|
|
# option) any later version.
|
|
|
|
#
|
2013-12-11 16:09:41 +00:00
|
|
|
# foam-extend is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
2010-10-07 03:00:07 +00:00
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
# along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-10-07 03:00:07 +00:00
|
|
|
#
|
|
|
|
# Description
|
2013-12-16 14:35:43 +00:00
|
|
|
# CMake/CTest script for running the FOAM tutorials
|
2010-10-07 03:00:07 +00:00
|
|
|
#
|
|
|
|
# Author
|
|
|
|
# Martin Beaudoin, Hydro-Quebec, 2010. All rights reserved
|
|
|
|
#
|
2013-12-16 14:35:43 +00:00
|
|
|
# \*-------------------------------------------------------------------------*/
|
2010-10-07 03:00:07 +00:00
|
|
|
|
|
|
|
# Take care of tests specific variables
|
|
|
|
IF(NOT DEFINED testIdSuffix)
|
|
|
|
SET(testIdSuffix "_full")
|
|
|
|
ENDIF(NOT DEFINED testIdSuffix)
|
|
|
|
|
|
|
|
IF(NOT DEFINED testRunTimeDirectory)
|
|
|
|
SET(testRunTimeDirectory "tutorialsTestSuites${testIdSuffix}")
|
|
|
|
ENDIF(NOT DEFINED testRunTimeDirectory)
|
|
|
|
|
|
|
|
# Use the current directory for running the test cases
|
|
|
|
SET (TEST_CASE_DIR $ENV{PWD}/${testRunTimeDirectory}
|
2013-12-16 14:35:43 +00:00
|
|
|
CACHE INTERNAL "FOAM test case directory."
|
2010-10-07 03:00:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Create the runTime directory for the test cases
|
|
|
|
MESSAGE("Removing the old test directory: ${TEST_CASE_DIR}")
|
|
|
|
file(REMOVE_RECURSE ${TEST_CASE_DIR})
|
|
|
|
MESSAGE("Creation of the new test directory: ${TEST_CASE_DIR}")
|
|
|
|
file(COPY $ENV{FOAM_TUTORIALS}/ DESTINATION ${TEST_CASE_DIR})
|
|
|
|
|
|
|
|
# Add a default Allrun file for the cases that don't have one.
|
2013-07-18 01:02:34 +00:00
|
|
|
# The test harness relies on the presence of an Allrun file for
|
2010-10-07 03:00:07 +00:00
|
|
|
# running the case
|
|
|
|
MESSAGE("${testRunTimeDirectory}: Checking for missing Allrun file in tutorials")
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/addMissingAllrunFileToTutorial.sh ${TEST_CASE_DIR} $ENV{FOAM_TEST_HARNESS_DIR}/scripts/Allrun.default
|
|
|
|
WORKING_DIRECTORY .
|
|
|
|
)
|
|
|
|
|
|
|
|
# Iterate over each tutorial case:
|
|
|
|
# We are looking for tutorial cases with an Allrun file.
|
|
|
|
# If this file is present, (and it should), we add this case to the list of cases to run.
|
|
|
|
#
|
|
|
|
|
|
|
|
#First, add a global cleanup of the cases
|
2015-08-26 02:57:42 +00:00
|
|
|
#This will always run and complete first, even in paralel
|
|
|
|
SET(cleanCasesTestId "Allclean_cases${testIdSuffix}")
|
|
|
|
ADD_TEST(${cleanCasesTestId} bash -c "cd ${TEST_CASE_DIR}; ./Allclean")
|
|
|
|
|
|
|
|
# Add a dummy test (/bin/true, just for debugging)
|
|
|
|
SET(dummyTestId "foam-extend-$ENV{WM_PROJECT_VERSION}_Dummy_Test")
|
|
|
|
ADD_TEST(${dummyTestId} true)
|
|
|
|
|
|
|
|
# Add a dependency on the global clean-up target, even for the dummy test
|
|
|
|
SET_TESTS_PROPERTIES(${dummyTestId} PROPERTIES DEPENDS ${cleanCasesTestId})
|
|
|
|
|
2010-10-07 03:00:07 +00:00
|
|
|
|
|
|
|
# Next, recurse through the test cases root directory,
|
2013-07-18 01:02:34 +00:00
|
|
|
# find all the Allrun files, and add them as a new CTest test case
|
2010-10-07 03:00:07 +00:00
|
|
|
FILE(GLOB_RECURSE listofCasesWithAllrun ${TEST_CASE_DIR}/Allrun)
|
|
|
|
LIST(SORT listofCasesWithAllrun)
|
|
|
|
|
|
|
|
FOREACH(caseWithAllrun ${listofCasesWithAllrun})
|
|
|
|
#Grab the name of the directory containing the file Allrun
|
|
|
|
get_filename_component(thisCasePath ${caseWithAllrun} PATH)
|
|
|
|
|
|
|
|
# We need to skip the global Allrun file
|
|
|
|
IF(NOT ${thisCasePath} STREQUAL ${TEST_CASE_DIR})
|
|
|
|
MESSAGE("Found Allrun file in directory: ${thisCasePath}")
|
|
|
|
|
|
|
|
# Grab the parent name of the case directory
|
|
|
|
string(REPLACE ${TEST_CASE_DIR}/ "" caseParentPath ${caseWithAllrun})
|
|
|
|
|
|
|
|
# Construct the testId
|
|
|
|
string(REPLACE "/" "_" testId ${caseParentPath})
|
|
|
|
SET(testId ${testId}${testIdSuffix})
|
|
|
|
|
|
|
|
# Add the test to the test harness
|
|
|
|
MESSAGE("Adding test: ${testId}")
|
|
|
|
ADD_TEST(${testId} bash -c "cd ${thisCasePath}; ./Allrun")
|
2015-08-26 02:57:42 +00:00
|
|
|
|
2015-09-06 00:38:57 +00:00
|
|
|
# We extract a label name from the top level tutorial directories
|
|
|
|
# (eg: basic, incompressible, immersedBoundary, etc). We will use this
|
|
|
|
# label in order to categorize the various test cases under a more 'generic
|
|
|
|
# topic', so we can for instance limit the testharness to the
|
|
|
|
# 'incompressible' test cases, etc., simply by using the ctest -L command.
|
|
|
|
#
|
|
|
|
# ctest --print-labels will print the list of all available labels.
|
|
|
|
#
|
|
|
|
string(REPLACE ${TEST_CASE_DIR}/ "" tmpLabel ${caseWithAllrun})
|
|
|
|
string(FIND ${tmpLabel} "/" indexFirstSlash)
|
|
|
|
string(SUBSTRING ${tmpLabel} 0 ${indexFirstSlash} testLabel)
|
|
|
|
|
2015-08-26 02:57:42 +00:00
|
|
|
# Add a dependency on the global clean-up target
|
|
|
|
# When running in parallel, you need to wait for the cleanup to finish first
|
2015-09-06 00:38:57 +00:00
|
|
|
message(" This test case will have the following labels: Tutorials, ${testLabel}")
|
|
|
|
SET_TESTS_PROPERTIES(${testId} PROPERTIES DEPENDS ${cleanCasesTestId} LABELS "Tutorials;${testLabel}")
|
2015-08-26 02:57:42 +00:00
|
|
|
|
2010-10-07 03:00:07 +00:00
|
|
|
# Use this following entry instead for testing purpose
|
|
|
|
#ADD_TEST(${testId} bash -c "cd ${thisCasePath}; true")
|
|
|
|
|
|
|
|
ENDIF(NOT ${thisCasePath} STREQUAL ${TEST_CASE_DIR})
|
|
|
|
ENDFOREACH(caseWithAllrun)
|
|
|
|
|
|
|
|
# Modify the cases Allrun files to incorporate additional shell functions
|
|
|
|
MESSAGE("${testRunTimeDirectory}: Modifying the Allrun files for additional shell functions in directory: ${TEST_CASE_DIR}")
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForTestHarness.sh ${TEST_CASE_DIR} $ENV{FOAM_TEST_HARNESS_DIR}/scripts/AdditionalRunFunctions
|
|
|
|
WORKING_DIRECTORY .
|
|
|
|
)
|
|
|
|
|
2015-09-03 16:26:04 +00:00
|
|
|
# Configure the various ctest -S Dashboard drivers
|
|
|
|
|
|
|
|
# Driver for the tutorials
|
|
|
|
configure_file(
|
|
|
|
"$ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/Dashboard_Tutorials.cmake.in"
|
|
|
|
"$ENV{FOAM_TEST_HARNESS_DIR}/runDir/Dashboard_Tutorials.cmake"
|
|
|
|
@ONLY)
|
|
|
|
|
|
|
|
|
2015-08-26 02:57:42 +00:00
|
|
|
# That's it.
|