1 # /*---------------------------------------------------------------------------*\
3 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / A nd | Copyright held by original author
7 # -------------------------------------------------------------------------------
9 # This file is part of OpenFOAM.
11 # OpenFOAM is free software; you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License as published by the
13 # Free Software Foundation; either version 2 of the License, or (at your
14 # option) any later version.
16 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 # You should have received a copy of the GNU General Public License
22 # along with OpenFOAM; if not, write to the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 # CMake/CTest script for running the OpenFOAM tutorials
29 # Martin Beaudoin, Hydro-Quebec, 2010. All rights reserved
31 # \*---------------------------------------------------------------------------*/
33 # Take care of tests specific variables
34 IF(NOT DEFINED testIdSuffix)
35 SET(testIdSuffix "_full")
36 ENDIF(NOT DEFINED testIdSuffix)
38 IF(NOT DEFINED testRunTimeDirectory)
39 SET(testRunTimeDirectory "tutorialsTestSuites${testIdSuffix}")
40 ENDIF(NOT DEFINED testRunTimeDirectory)
42 # Use the current directory for running the test cases
43 SET (TEST_CASE_DIR $ENV{PWD}/${testRunTimeDirectory}
44 CACHE INTERNAL "OpenFOAM test case directory."
47 # Create the runTime directory for the test cases
48 MESSAGE("Removing the old test directory: ${TEST_CASE_DIR}")
49 file(REMOVE_RECURSE ${TEST_CASE_DIR})
50 MESSAGE("Creation of the new test directory: ${TEST_CASE_DIR}")
51 file(COPY $ENV{FOAM_TUTORIALS}/ DESTINATION ${TEST_CASE_DIR})
53 # Add a default Allrun file for the cases that don't have one.
54 # The test harness relies on the presence of an Allrun file for
56 MESSAGE("${testRunTimeDirectory}: Checking for missing Allrun file in tutorials")
58 COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/addMissingAllrunFileToTutorial.sh ${TEST_CASE_DIR} $ENV{FOAM_TEST_HARNESS_DIR}/scripts/Allrun.default
62 # Iterate over each tutorial case:
63 # We are looking for tutorial cases with an Allrun file.
64 # If this file is present, (and it should), we add this case to the list of cases to run.
67 #First, add a global cleanup of the cases
68 SET(testId "Allclean_cases${testIdSuffix}")
69 ADD_TEST(${testId} bash -c "cd ${TEST_CASE_DIR}; ./Allclean")
71 # Next, recurse through the test cases root directory,
72 # find all the Allrun files, and add them as a new CTest test case
73 FILE(GLOB_RECURSE listofCasesWithAllrun ${TEST_CASE_DIR}/Allrun)
74 LIST(SORT listofCasesWithAllrun)
76 FOREACH(caseWithAllrun ${listofCasesWithAllrun})
77 #Grab the name of the directory containing the file Allrun
78 get_filename_component(thisCasePath ${caseWithAllrun} PATH)
80 # We need to skip the global Allrun file
81 IF(NOT ${thisCasePath} STREQUAL ${TEST_CASE_DIR})
82 MESSAGE("Found Allrun file in directory: ${thisCasePath}")
84 # Grab the parent name of the case directory
85 string(REPLACE ${TEST_CASE_DIR}/ "" caseParentPath ${caseWithAllrun})
87 # Construct the testId
88 string(REPLACE "/" "_" testId ${caseParentPath})
89 SET(testId ${testId}${testIdSuffix})
91 # Add the test to the test harness
92 MESSAGE("Adding test: ${testId}")
93 ADD_TEST(${testId} bash -c "cd ${thisCasePath}; ./Allrun")
94 # Use this following entry instead for testing purpose
95 #ADD_TEST(${testId} bash -c "cd ${thisCasePath}; true")
97 ENDIF(NOT ${thisCasePath} STREQUAL ${TEST_CASE_DIR})
98 ENDFOREACH(caseWithAllrun)
100 # Modify the cases Allrun files to incorporate additional shell functions
101 MESSAGE("${testRunTimeDirectory}: Modifying the Allrun files for additional shell functions in directory: ${TEST_CASE_DIR}")
103 COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForTestHarness.sh ${TEST_CASE_DIR} $ENV{FOAM_TEST_HARNESS_DIR}/scripts/AdditionalRunFunctions