Skip to content

Commit 72c5188

Browse files
authored
Merge pull request #86 from ilrudie/i64-descriptive-test-names
Updating run-functional-tests.sh to allow descriptive names
2 parents 95d2427 + 4b17507 commit 72c5188

File tree

1 file changed

+51
-8
lines changed

1 file changed

+51
-8
lines changed

hack/run-functional-tests.sh

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ run_resource_tests() {
9090

9191
test_type=$(yq read "${TESTS_MANIFEST}" "resources.[${resource_index}].desired")
9292

93-
# grab local list of test manifests to use
94-
local manifest_list
93+
# grab local length of the list of test manifests to use
94+
local manifest_array_length
9595

96-
manifest_list=$(yq read -P "${TESTS_MANIFEST}" "resources.[${resource_index}].manifests" | sed 's/^-[ ]*//')
96+
manifest_array_length=$(yq read -l "${TESTS_MANIFEST}" "resources.[${resource_index}].manifests")
9797

9898
# grab local user_script specified for pre/post/between running
9999
local user_script
@@ -103,7 +103,7 @@ run_resource_tests() {
103103
# full path to the user specified script associate with this stanza in the manifest
104104
local user_script_path="testing/${resource}/scripts/${user_script}"
105105

106-
if [ "${manifest_list}" == "" ]; then
106+
if (( manifest_array_length == 0 )); then
107107

108108
echo "[WARN] No \"${test_type}\" tests for \"${resource}\". Skipping..."
109109
echo "============================================================================"
@@ -124,13 +124,53 @@ run_resource_tests() {
124124

125125
fi
126126

127-
for testfile in ${manifest_list}; do
127+
for ((manifest_index = 0 ; manifest_index < manifest_array_length ; manifest_index++)); do
128128

129-
local test_file_path="testing/${resource}/${testfile}"
129+
# declare testfile as local
130+
local testfile
131+
132+
# try getting the name of the file using the new style 'file' map key
133+
testfile=$(yq read -P "${TESTS_MANIFEST}" "resources.[${resource_index}].manifests.[${manifest_index}].file")
134+
135+
# declare file_description as local
136+
local file_description
137+
138+
# get the file_description with 'name 'map key
139+
file_description=$(yq read -P "${TESTS_MANIFEST}" "resources.[${resource_index}].manifests.[${manifest_index}].name")
140+
141+
# declare test_file_path as local
142+
local test_file_path
143+
144+
# create the relative path to the test file (from 'file' map key)
145+
test_file_path="testing/${resource}/${testfile}"
146+
147+
# check if the file exists at the correct relative path;
148+
# if it doesn't try falling back to the legacy style where the array index contains the filename instead of a map
149+
if [[ -z "${testfile}" ]]; then
150+
151+
testfile=$(yq read -P "${TESTS_MANIFEST}" "resources.[${resource_index}].manifests.[${manifest_index}]")
152+
153+
fi
130154

155+
# declare test_file_path as local
156+
local test_file_path
157+
158+
# create the relative path to the test file (from 'file' map key)
159+
test_file_path="testing/${resource}/${testfile}"
160+
161+
# make sure the file exists using the legacy style name; if it doesn't then we're skipping this file
131162
if [ -f "${test_file_path}" ]; then
132163

133-
echo "[INFO] ${action}: \"${testfile}\""
164+
# check if file_description is empty, if it is fall back to the older output
165+
if [ -z "${file_description}" ]; then
166+
167+
echo "[INFO] ${action}: \"${testfile}\""
168+
169+
else
170+
171+
echo "[INFO] ${file_description}"
172+
173+
fi
134174

135175
if [ "${action}" == "delete" ]; then
136176

@@ -172,7 +212,10 @@ run_resource_tests() {
172212

173213
else
174214

175-
echo "[WARN] File \"${test_file_path}\" not found. Skipping..."
215+
# try to warn that the functional test manifest has a problem with one of the file definitions
216+
echo "[WARN] File \"${testfile}\" not found in directory \"testing/${resource}/\". Functional Testing Failed..."
217+
218+
exit 1
176219

177220
fi
178221

0 commit comments

Comments
 (0)