-# Source the generated environment file if it's present
-if [ -f "${BT_TESTS_BUILDDIR}/utils/env.sh" ]; then
- # shellcheck disable=SC1091
- . "${BT_TESTS_BUILDDIR}/utils/env.sh"
-fi
+ # Base build directory of tests
+ if [[ -z "${BT_TESTS_BUILDDIR:-}" ]]; then
+ BT_TESTS_BUILDDIR="$testsdir"
+ fi
+ export BT_TESTS_BUILDDIR
+}
+
+_set_vars_srcdir_builddir
+unset -f _set_vars_srcdir_builddir
+
+# Sources the generated environment file (`env.sh`) if it exists.
+_source_env_sh() {
+ local -r env_sh_path="$BT_TESTS_BUILDDIR/utils/env.sh"
+
+ if [[ -f "${env_sh_path}" ]]; then
+ # shellcheck disable=SC1090,SC1091
+ . "${env_sh_path}"
+ fi
+}
+
+_source_env_sh
+unset -f _source_env_sh