Skip to content

Commit 99f104f

Browse files
committed
Set env and workdir w/ cmake for script tests
- Don't create a harness with `INSTALL()` as it won't get created until `make install` - Call the test scripts directly with CMake/CTest, and set WORKING_DIRECTORY and OPENCOARRAYS_SRC_DIR via test properties
1 parent 2e585b4 commit 99f104f

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

AddInstallationScriptTest.cmake

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
macro(add_installation_script_test name path)
22

3-
# Copy the source to the binary tree
3+
# Copy the source to the binary tree
44
configure_file(
55
${CMAKE_CURRENT_SOURCE_DIR}/${path}/${name}
66
${CMAKE_CURRENT_BINARY_DIR}/${path}/${name}
@@ -11,15 +11,7 @@ macro(add_installation_script_test name path)
1111
${CMAKE_CURRENT_BINARY_DIR}/${path}/${name}-usage
1212
COPYONLY
1313
)
14-
set(harness "${CMAKE_BINARY_DIR}/staging/test-${name}.sh")
15-
install(
16-
FILES "${harness}"
17-
PERMISSIONS WORLD_EXECUTE WORLD_READ WORLD_WRITE OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ GROUP_WRITE
18-
DESTINATION ${CMAKE_BINARY_DIR}/${path}
19-
)
20-
file(WRITE "${harness}" "#!/bin/bash\n")
21-
file(APPEND "${harness}" "cd ${CMAKE_BINARY_DIR}/${path}\n")
22-
file(APPEND "${harness}" "OPENCOARRAYS_SRC_DIR=${CMAKE_SOURCE_DIR} ./${name}\n")
23-
add_test(NAME ${name} COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${path}/test-${name}.sh")
24-
#set_property(TEST ${name} PROPERTY PASS_REGULAR_EXPRESSION "Test passed.")
14+
add_test(NAME test-${name} COMMAND "${CMAKE_BINARY_DIR}/${path}/${name}")
15+
set_property(TEST test-${name} PROPERTY WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${path}")
16+
set_property(TEST test-${name} PROPERTY ENVIRONMENT "OPENCOARRAYS_SRC_DIR=${CMAKE_SOURCE_DIR}")
2517
endmacro(add_installation_script_test)

src/tests/installation/installation-scripts.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
9191
echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path."
9292
exit 2
9393
else
94-
# shellcheck source=./prerequisites/use-case/bootstrap.sh
94+
# shellcheck source=../../../prerequisites/use-case/bootstrap.sh
9595
source "${B3B_USE_CASE}/bootstrap.sh" "$@"
9696
fi
9797
### End of boilerplate -- start user edits below #########################
@@ -109,6 +109,7 @@ trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, S
109109

110110
pushd "${OPENCOARRAYS_SRC_DIR}"/src/tests/installation
111111

112+
# shellcheck source=../../../prerequisites/stack.sh
112113
source "${OPENCOARRAYS_SRC_DIR}"/prerequisites/stack.sh
113114
source test-stack.sh
114115
test_stack

src/tests/installation/test-stack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,6 @@ test_stack()
153153
# Verify that push, peek, and pop yield correct size changes or lack thereof:
154154
verify_stack_size_changes
155155

156-
debug "test-stack.sh: All tests passed."
156+
info "test-stack.sh: All tests passed."
157157

158158
}

0 commit comments

Comments
 (0)