Skip to content

Commit

Permalink
Add test TribitsHelloWorld_config_git_version (#597)
Browse files Browse the repository at this point in the history
Added test TribitsHelloWorld_config_git_version that uses mockprogram.py as
git to generate and check git version info.

ToDo: We should also check the generated TribitsHelloWorldRepoVersion.txt file
  • Loading branch information
bartlettroscoe committed Jan 4, 2024
1 parent 685c8d5 commit 00b3c6f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(TribitsHelloWorld_COMMON_CONFIG_ARGS
${SERIAL_PASSTHROUGH_CONFIGURE_ARGS}
)


tribits_add_advanced_test( TribitsHelloWorld
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
Expand Down Expand Up @@ -36,6 +37,51 @@ tribits_add_advanced_test( TribitsHelloWorld
)


tribits_add_advanced_test( TribitsHelloWorld_config_git_version
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1

TEST_0
MESSAGE "Copy the project source so we can copy files into it."
CMND ${CMAKE_COMMAND}
ARGS -E copy_directory
${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsHelloWorld
TribitsHelloWorld

TEST_1
MESSAGE "Create a dummy .git directory so it will run git commands"
CMND ${CMAKE_COMMAND} ARGS -E make_directory TribitsHelloWorld/.git

TEST_2
CMND ${CMAKE_COMMAND} ARGS -E copy
${CMAKE_CURRENT_SOURCE_DIR}/configure_git_mockprogram_files/mockprogram_inout.single_version.txt
TribitsHelloWorld/.mockprogram_inout.txt

TEST_3
WORKING_DIRECTORY BUILD
CMND ${CMAKE_COMMAND}
ARGS
${TribitsHelloWorld_COMMON_CONFIG_ARGS}
-DTribitsHelloWorld_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-DTribitsHelloWorld_ENABLE_TESTS=ON
-DTribitsHelloWorld_GENERATE_REPO_VERSION_FILE=ON
-DGIT_EXECUTABLE=${${PROJECT_NAME}_TRIBITS_DIR}/python_utils/mockprogram.py
../TribitsHelloWorld
PASS_REGULAR_EXPRESSION_ALL
"a1234tgb .Thu Sep 21 19:19:18 2023 -0400. <[email protected]>"
"This is the git commit summary line"
ALWAYS_FAIL_ON_NONZERO_RETURN

)
# The above directory structure is:
#
# TribitsHelloWorld_config_git_version/
# TribitsHelloWorld/
# .git/
# .mockprogram_inout.txt
# BUILD/


tribits_add_advanced_test( TribitsHelloWorld_EXE_DISABLE
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%h [%ad] <%ae>
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: a1234tgb [Thu Sep 21 19:19:18 2023 -0400] <[email protected]>
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%s
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: This is the git commit summary line

0 comments on commit 00b3c6f

Please sign in to comment.