Skip to content

Commit 319d5a4

Browse files
authored
HDDS-12773. bad substitution in bats test (#8290)
1 parent 6f5e02a commit 319d5a4

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

hadoop-ozone/dist/src/main/compose/testlib.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,23 @@ source "${_testlib_dir}/../smoketest/testlib.sh"
3131
: ${SECURITY_ENABLED:=false}
3232
: ${SCM:=scm}
3333

34-
# version is used in bucket name, which does not allow uppercase
35-
export OZONE_CURRENT_VERSION="$(echo "${ozone.version}" | sed -e 's/-SNAPSHOT//' | tr '[:upper:]' '[:lower:]')"
34+
# Check if running from output of Maven build or from source
35+
_is_build() {
36+
local file=""
37+
# Variable is replaced by Maven at build time,
38+
# so if it empty, we are running from source, if non-empty, then running in build output (target)
39+
[[ -n "${file}" ]]
40+
}
41+
42+
# Avoid `bad substitution` error
43+
if _is_build; then
44+
# version is used in bucket name, which does not allow uppercase
45+
# variable is replaced by Maven at build time
46+
OZONE_CURRENT_VERSION="$(echo "${ozone.version}" | sed -e 's/-SNAPSHOT//' | tr '[:upper:]' '[:lower:]')"
47+
else
48+
OZONE_CURRENT_VERSION=src
49+
fi
50+
export OZONE_CURRENT_VERSION
3651

3752
# create temp directory for test data; only once, even if testlib.sh is sourced again
3853
if [[ -z "${TEST_DATA_DIR:-}" ]] && [[ "${KEEP_RUNNING:-false}" == "false" ]]; then

0 commit comments

Comments
 (0)