1 # /*---------------------------------------------------------------------------*\
3 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / A nd | For copyright notice see file Copyright
7 # -------------------------------------------------------------------------------
9 # This file is part of foam-extend.
11 # foam-extend 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 3 of the License, or (at your
14 # option) any later version.
16 # foam-extend is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 # General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 # CMake/CTest script for running the Turbomachinery OSIG testsuites
26 # for the tutorials directory
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 SET(testRunTimeDirectory "TurbomachineryTestSuites${testIdSuffix}/tutorials")
40 # Use the current directory for running the test cases
41 SET (TEST_CASE_DIR $ENV{PWD}/${testRunTimeDirectory}
42 CACHE INTERNAL "Turbo OSIG tutorials directory."
45 # Create the runTime test cases
46 MESSAGE("Removing the old test directory: ${TEST_CASE_DIR}")
47 file(REMOVE_RECURSE ${TEST_CASE_DIR})
48 MESSAGE("Creation of the new test directory: ${TEST_CASE_DIR}")
49 file(COPY ${TURBOMACHINERY_OSIG_ROOT}/tutorials DESTINATION ${TEST_CASE_DIR}/..)
51 # Iterate over each case:
52 # We are looking for a tutorial with an Allrun case.
53 # If this file is present, we add this case to the list of cases to run.
56 # Subdirectory for the test cases
57 SET(TESTCASES_SUBDIR ".")
59 # No need for a global Allclean script, we will invoke the Allclean command before each
61 #SET(testId "TUT_Allclean_cases${testIdSuffix}")
62 #ADD_TEST(${testId} bash -c "cd ${TEST_CASE_DIR}/${TESTCASES_SUBDIR}; ./Allclean")
64 # Next, recurse through the case root directory,
65 # find all the Allrun files, and execute them
66 FILE(GLOB_RECURSE listofCasesWithAllrun ${TEST_CASE_DIR}/${TESTCASES_SUBDIR}/Allrun*)
67 LIST(SORT listofCasesWithAllrun)
69 FOREACH(caseWithAllrun ${listofCasesWithAllrun})
70 #Grab the name of the directory containing the file Allrun
71 get_filename_component(thisCasePath ${caseWithAllrun} PATH)
72 get_filename_component(thisCaseAllrunName ${caseWithAllrun} NAME)
74 # We need to skip the .svn files
75 IF(NOT ${thisCasePath} MATCHES .svn)
76 MESSAGE("Found Allrun file in directory: ${thisCasePath}")
78 # Grab the parent name of the case directory
79 string(REPLACE ${TEST_CASE_DIR}/ "" caseParentPath ${caseWithAllrun})
81 # Construct the testId
82 string(REPLACE "/" "_" testId ${caseParentPath})
83 SET(testId TUT_${testId}${testIdSuffix})
85 # Add the test to the test harness
86 MESSAGE("Adding test: ${testId}")
87 ADD_TEST(${testId} bash -c "cd ${thisCasePath}; ./Allclean; ./${thisCaseAllrunName}")
88 # Use this entry instead for testing
89 #ADD_TEST(${testId} bash -c "cd ${thisCasePath}; true")
91 ENDIF(NOT ${thisCasePath} MATCHES .svn)
92 ENDFOREACH(caseWithAllrun)
94 # Modify the cases Allrun file for additional shell functions
95 MESSAGE("${testRunTimeDirectory}: Modifying the Allrun files for additional shell functions in directory: ${TEST_CASE_DIR}/${TESTCASES_SUBDIR}")
97 COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForTestHarness.sh ${TEST_CASE_DIR}/${TESTCASES_SUBDIR} $ENV{FOAM_TEST_HARNESS_DIR}/scripts/AdditionalRunFunctions