Skip to content

Commit

Permalink
fix: handle relative path from parent call to run_bats_tests_in_docke…
Browse files Browse the repository at this point in the history
…r.bash

- Add visual separators for enhanced readability.
- Move variable initialization for N2ST_VERSION to a common script.
- Reorganize TeamCity environment message logging.

Issue NMO-571
  • Loading branch information
RedLeader962 committed Aug 6, 2024
1 parent ad1105e commit 838b226
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions import_norlab_shell_script_tools_lib.bash
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ function n2st::source_lib(){
# cd "${N2ST_ROOT_DIR}/src/utility_scripts"
# PATH=$PATH:${N2ST_ROOT_DIR}/src/utility_scripts

N2ST_VERSION="$(cat "${N2ST_PATH}"/version.txt)"
export N2ST_VERSION

# ....Teardown...................................................................................
popd >/dev/null || exit 1
}
Expand Down
11 changes: 6 additions & 5 deletions tests/bats_testing_tools/run_bats_tests_in_docker.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
#
# =================================================================================================
# Execute bats unit test in a docker container with bats-core support including several helper libraries
#
# Usage:
Expand All @@ -12,6 +12,7 @@
# run all bats file in the test directory
# - ['<image-distro>'] ubuntu or alpine (default ubuntu)
#
# =================================================================================================

RUN_TESTS_IN_DIR=${1:-'tests'}
BATS_DOCKERFILE_DISTRO=${2:-'ubuntu'}
Expand All @@ -25,14 +26,14 @@ REPO_ROOT=$(pwd)
N2ST_BATS_TESTING_TOOLS_ABS_PATH="$( cd "$( dirname "${0}" )" &> /dev/null && pwd )"

# ToDo: assessment › harccoding the relative path is more robust. Since the location wont change anymore, the version with string substitution is irelevant.
#N2ST_BATS_TESTING_TOOLS_RELATIVE_PATH=".${N2ST_BATS_TESTING_TOOLS_ABS_PATH/$REPO_ROOT/}"
N2ST_BATS_TESTING_TOOLS_RELATIVE_PATH="tests/bats_testing_tools"
N2ST_BATS_TESTING_TOOLS_RELATIVE_PATH=".${N2ST_BATS_TESTING_TOOLS_ABS_PATH/$REPO_ROOT/}"
#N2ST_BATS_TESTING_TOOLS_RELATIVE_PATH="tests/bats_testing_tools"

#N2ST_PATH=$( git rev-parse --show-toplevel )
N2ST_PATH="${N2ST_BATS_TESTING_TOOLS_ABS_PATH}/../.."
test -d "${N2ST_PATH}" || exit 1
#tree -a -L 1 ${N2ST_PATH}
N2ST_VERSION="$(cat "${N2ST_PATH}"/version.txt)"


# ....Source project shell-scripts dependencies....................................................
pushd "$(pwd)" >/dev/null || exit 1
Expand All @@ -58,12 +59,12 @@ test -f "${N2ST_BATS_TESTING_TOOLS_RELATIVE_PATH}/bats_helper_functions.bash" ||

# ====Begin========================================================================================
n2st::set_is_teamcity_run_environment_variable
n2st::print_msg "IS_TEAMCITY_RUN=${IS_TEAMCITY_RUN} ${TC_VERSION}"
if [[ ${IS_TEAMCITY_RUN} != true ]] && [[ -z ${BUILDX_BUILDER} ]]; then
n2st::norlab_splash "${PROJECT_PROMPT_NAME}" "${PROJECT_GIT_REMOTE_URL}"
fi
n2st::print_formated_script_header "$(basename $0) ${MSG_END_FORMAT}on device ${MSG_DIMMED_FORMAT}$(hostname -s)" "${MSG_LINE_CHAR_BUILDER_LVL2}"

n2st::print_msg "IS_TEAMCITY_RUN=${IS_TEAMCITY_RUN} ${TC_VERSION}"
if [[ -z ${BUILDX_BUILDER} ]]; then
# Note: Default to default buildx builder (ie native host architecture) so that the build img
# be available in the local image store and that tests executed via docker run doesn't
Expand Down

0 comments on commit 838b226

Please sign in to comment.