Skip to content

Commit

Permalink
Allow / in test name for TAAT()
Browse files Browse the repository at this point in the history
This is needed for SPARC

Build/Test Cases Summary
Enabled Packages:
Enabled all Packages
0) MPI_DEBUG => passed: passed=265,notpassed=0 (0.73 min)
1) SERIAL_RELEASE => passed: passed=265,notpassed=0 (0.58 min)
2) MPI_DEBUG_CMAKE-3.6.2 => passed: passed=286,notpassed=0 (0.56 min)
3) SERIAL_RELEASE_CMAKE-3.6.2 => passed: passed=286,notpassed=0 (0.50 min)
Other local commits for this build/test group: 1dfc788
  • Loading branch information
bartlettroscoe committed Dec 20, 2017
1 parent 1dfc788 commit bc894de
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TRIBITS_ADD_ADVANCED_TEST( TestingFunctionMacro_UnitTests
-D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestingFunctionMacro_UnitTests.cmake"
PASS_REGULAR_EXPRESSION_ALL
"Final UnitTests Result: num_run = 515"
"Final UnitTests Result: num_run = 522"
"Final UnitTests Result: PASSED"
)

Expand Down
28 changes: 27 additions & 1 deletion test/core/TestingFunctionMacro_UnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,32 @@ FUNCTION(UNITEST_TRIBITS_ADD_ADVANCED_TEST_BASIC)
"SET[(]SHOW_MACHINE_LOAD ON[)]"
)

MESSAGE("***\n*** Use a test name with '/' in the name\n***")
TRIBITS_ADD_ADVANCED_TEST_UNITTEST_RESET()
SET(${PROJECT_NAME}_SHOW_TEST_START_END_DATE_TIME OFF) # Above test was ON
SET(${PROJECT_NAME}_SHOW_MACHINE_LOAD_IN_TEST ON) # Above test was OFF
TRIBITS_ADD_ADVANCED_TEST( TAAT_basic/exec/1_args_0
OVERALL_WORKING_DIRECTORY TEST_NAME
TEST_0 EXEC ${EXEN}
)
UNITTEST_COMPARE_CONST(
TRIBITS_ADD_ADVANCED_TEST_CMND_ARRAY_0
"\"${CMAKE_CURRENT_BINARY_DIR}/${PACKEXEN}\""
)
UNITTEST_COMPARE_CONST(
TRIBITS_ADD_ADVANCED_TEST_NUM_CMNDS
1
)
UNITTEST_FILE_REGEX(
"${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_TAAT_basic__exec__1_args_0.cmake"
REGEX_STRINGS
"OVERALL_WORKING_DIRECTORY \"${PACKAGE_NAME}_TAAT_basic__exec__1_args_0\""
"TEST_0_CMND \"${CMAKE_CURRENT_BINARY_DIR}/${PACKEXEN}\""
"NUM_CMNDS 1"
"SET[(]SHOW_START_END_DATE_TIME OFF[)]"
"SET[(]SHOW_MACHINE_LOAD ON[)]"
)

MESSAGE("***\n*** Add a single basic command with two arguments\n***")
TRIBITS_ADD_ADVANCED_TEST_UNITTEST_RESET()
SET(${PROJECT_NAME}_SHOW_TEST_START_END_DATE_TIME OFF)
Expand Down Expand Up @@ -3425,4 +3451,4 @@ MESSAGE("*** Determine final result of all unit tests")
MESSAGE("***\n")

# Pass in the number of expected tests that must pass!
UNITTEST_FINAL_RESULT(515)
UNITTEST_FINAL_RESULT(522)
28 changes: 18 additions & 10 deletions tribits/core/package_arch/TribitsAddAdvancedTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,23 @@ INCLUDE(PrintVar)
# The base name of the test (which will have ``${PACKAGE_NAME}_``
# prepended to the name, see <testName> below) that will be used to name
# the output CMake script file as well as the CTest test name passed into
# ``ADD_TEST()``. This must be the first argument to this function.
# ``ADD_TEST()``. This must be the first argument to this function. The
# name is allowed to contain '/' chars but these will be replaced with
# '__' in the overall working directory name and the ctest -P script
# (`Debugging and Examining Test Generation
# (TRIBITS_ADD_ADVANCED_TEST())`_).
#
# ``OVERALL_WORKING_DIRECTORY <overallWorkingDir>``
#
# If specified, then the working directory ``<overallWorkingDir>``
# (relative or absolute path) will be created and all of the test commands
# by default will be run from within this directory. If the value
# ``<overallWorkingDir>=TEST_NAME`` is given, then the working directory
# will be given the name ``<testName>``. By default, if the directory
# ``<overallWorkingDir>`` exists before the test runs, it will be deleted
# and created again. If one wants to preserve the contents of this
# directory between test runs then set
# ``SKIP_CLEAN_OVERALL_WORKING_DIRECTORY``. Using a separate test
# will be given the name ``<testName>`` where any '/' chars are replaced
# with '__'. By default, if the directory ``<overallWorkingDir>`` exists
# before the test runs, it will be deleted and created again. If one
# wants to preserve the contents of this directory between test runs then
# set ``SKIP_CLEAN_OVERALL_WORKING_DIRECTORY``. Using a separate test
# directory is a good option to use if the commands create intermediate
# files and one wants to make sure they get deleted before the test cases
# are run again. It is also important to create a separate test directory
Expand Down Expand Up @@ -662,8 +666,8 @@ INCLUDE(PrintVar)
#
# Since raw CTest does not support the features provided by this function, the
# way an advanced test is implemented is that a ``cmake -P`` script with the
# name ``<testName>.cmake`` gets created in the current binary directory that
# then gets added to CTest using::
# name ``<testName>.cmake`` (with any '/' replaced with '__') gets created in
# the current binary directory that then gets added to CTest using::
#
# ADD_TEST(<testName> cmake [other options] -P <testName>.cmake)
#
Expand Down Expand Up @@ -852,10 +856,14 @@ FUNCTION(TRIBITS_ADD_ADVANCED_TEST TEST_NAME_IN)
SET(${PARSE_ADDED_TEST_NAME_OUT} "" PARENT_SCOPE )
ENDIF()

# Set the name of the cmake -P script.
STRING(REPLACE "/" "__" NORMALIZED_TEST_NAME "${TEST_NAME}")
SET(TEST_SCRIPT_FILE_NAME "${NORMALIZED_TEST_NAME}.cmake")

# Set the relative overall working directory and abs working directory
IF (PARSE_OVERALL_WORKING_DIRECTORY)
IF ("${PARSE_OVERALL_WORKING_DIRECTORY}" STREQUAL "TEST_NAME")
SET(PARSE_OVERALL_WORKING_DIRECTORY ${TEST_NAME})
SET(PARSE_OVERALL_WORKING_DIRECTORY ${NORMALIZED_TEST_NAME})
ENDIF()
# Test will run in created working subdir
SET(ABS_OVERALL_WORKING_DIRECTORY
Expand Down Expand Up @@ -1348,7 +1356,7 @@ FUNCTION(TRIBITS_ADD_ADVANCED_TEST TEST_NAME_IN)
# F.1) Call ADD_TEST() and set the test properties
#

SET(TEST_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.cmake")
SET(TEST_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SCRIPT_FILE_NAME}")

IF(NOT TRIBITS_ADD_TEST_ADD_TEST_UNITTEST)
# Tell CTest to run our script for this test. Pass the test-type
Expand Down

0 comments on commit bc894de

Please sign in to comment.