Skip to content

Commit

Permalink
fix: tests: detect definition errors in modules
Browse files Browse the repository at this point in the history
  • Loading branch information
speed47 committed Apr 9, 2024
1 parent d576d83 commit 414e023
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
25 changes: 19 additions & 6 deletions tests/functional/launch_tests_on_instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ fi
mytmpdir=$(mktemp -d -t bastiontest.XXXXXX)
tmp_a=$(mktemp -t bastiontest.XXXXXX)
tmp_b=$(mktemp -t bastiontest.XXXXXX)
trap 'echo CLEANING UP ; rm -rf "$mytmpdir" ; rm -f "$tmp_a" "$tmp_b" ; exit 255' EXIT
source_stderr=$(mktemp -t bastiontest.XXXXXX)
trap 'echo CLEANING UP ; rm -rf "$mytmpdir" ; rm -f "$tmp_a" "$tmp_b" "$source_stderr"; exit 255' EXIT
account0key1file="$mytmpdir/account0key1file"
account1key1file="$mytmpdir/account1key1file"
account1key2file="$mytmpdir/account1key2file"
Expand Down Expand Up @@ -701,12 +702,24 @@ runtests()

dump_vars_and_funcs > "$tmp_a"
module_ret=0
# as this is a loop, we do the shellcheck in a reversed way, see any included module for more info:
# shellcheck disable=SC1090
if source "$module"; then
module_ret=0
if [ "$COUNTONLY" = 0 ]; then
# as this is a loop, we do the shellcheck in a reversed way, see any included module for more info:
# shellcheck disable=SC1090
source "$module" || module_ret=$?
else
module_ret=$?
# take the opportunity to ensure there's nothing in stderr, or there might be
# errors in the module we're sourcing by capturing 2>
# shellcheck disable=SC1090
source "$module" 2>"$source_stderr" || module_ret=$?
if [ -s "$source_stderr" ]; then
echo
echo "DEFINITION ERROR in module $module, aborting:"
echo "-----"
cat "$source_stderr"
echo "-----"
echo
exit 1
fi
fi
dump_vars_and_funcs > "$tmp_b"
success module_postrun test "$module_ret" = 0
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/tests.d/350-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ EOS
json .error_code ERR_INCOMPATIBLE_PARAMETERS

success a1_add_access_force_key_g1 $a1 --osh groupAddServer --host 127.1.2.3 --user 'ar@base' --port-any --force --force-key "$key1fp" --group $group1
.value.user 'ar@base'
json .value.user 'ar@base'

success a1_list_servers_check_force_key_g1 $a1 --osh groupListServers --group $group1
json '.value|.[]|select(.ip=="127.1.2.3")|.forceKey' "$key1fp"
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/tests.d/380-config-options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ testsuite_config_options()
configchg 's=^\\\\x22dnsSupportLevel\\\\x22.+=\\\\x22dnsSupportLevel\\\\x22:0,='

run a1_connect_nodns $a0 localhost
retvalmustbe 102
retvalshouldbe 102
json .error_code KO_HOST_NOT_FOUND
contain 'DNS resolving is disabled'
}
Expand Down

0 comments on commit 414e023

Please sign in to comment.