From 838b226b07cd53645bda2707fecdb1c7113cd336 Mon Sep 17 00:00:00 2001 From: RedLeaderOne Date: Tue, 6 Aug 2024 08:02:20 -0400 Subject: [PATCH 1/2] fix: handle relative path from parent call to run_bats_tests_in_docker.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 --- import_norlab_shell_script_tools_lib.bash | 3 +++ .../bats_testing_tools/run_bats_tests_in_docker.bash | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/import_norlab_shell_script_tools_lib.bash b/import_norlab_shell_script_tools_lib.bash index e1949f5..e79c7e3 100644 --- a/import_norlab_shell_script_tools_lib.bash +++ b/import_norlab_shell_script_tools_lib.bash @@ -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 } diff --git a/tests/bats_testing_tools/run_bats_tests_in_docker.bash b/tests/bats_testing_tools/run_bats_tests_in_docker.bash index d7cd6ad..0d3efa8 100644 --- a/tests/bats_testing_tools/run_bats_tests_in_docker.bash +++ b/tests/bats_testing_tools/run_bats_tests_in_docker.bash @@ -1,5 +1,5 @@ #!/bin/bash -# +# ================================================================================================= # Execute bats unit test in a docker container with bats-core support including several helper libraries # # Usage: @@ -12,6 +12,7 @@ # run all bats file in the test directory # - [''] ubuntu or alpine (default ubuntu) # +# ================================================================================================= RUN_TESTS_IN_DIR=${1:-'tests'} BATS_DOCKERFILE_DISTRO=${2:-'ubuntu'} @@ -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 @@ -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 From 60bb4c4ec9f94da7a9e114536834292da3c80fc1 Mon Sep 17 00:00:00 2001 From: RedLeaderOne Date: Tue, 6 Aug 2024 08:11:01 -0400 Subject: [PATCH 2/2] style: comment clean up [skip release] --- tests/bats_testing_tools/run_bats_tests_in_docker.bash | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/bats_testing_tools/run_bats_tests_in_docker.bash b/tests/bats_testing_tools/run_bats_tests_in_docker.bash index 0d3efa8..2ce47ce 100644 --- a/tests/bats_testing_tools/run_bats_tests_in_docker.bash +++ b/tests/bats_testing_tools/run_bats_tests_in_docker.bash @@ -24,16 +24,10 @@ BATS_DOCKERFILE_DISTRO=${2:-'ubuntu'} # ....N2ST root logic.............................................................................. 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_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} - # ....Source project shell-scripts dependencies.................................................... pushd "$(pwd)" >/dev/null || exit 1