From 3fcfe89c193e0f4503aa31a2cc6a937d6f2f6836 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Tue, 22 Mar 2022 10:54:22 +0100 Subject: [PATCH] Use released rdlink for testing and build it if missing --- test/test_rdlink.sh | 22 ++++++++++++---------- test/totest.sh | 8 ++++---- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/test/test_rdlink.sh b/test/test_rdlink.sh index baab27b..e9c059a 100755 --- a/test/test_rdlink.sh +++ b/test/test_rdlink.sh @@ -17,8 +17,9 @@ # Internal tests will be executed if no arguments are found readonly test_dir="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -readonly tool_rdlink="${test_dir}/../rdlink.sh" +readonly tool_rdlink="${test_dir}/../release/rdlink.sh" readonly tool_readlink="$(command -v readlink) -f --" +readonly build_cmd="${test_dir}/../build.sh" readonly config_path_width=45 @@ -163,6 +164,8 @@ rl::test() { esac done + [[ ! -e "${tool_rdlink}" ]] && "${build_cmd}" + # Cmd line arguments (( ! flag_onlycompete )) && [[ ! "$@" ]] && toassert_init @@ -183,13 +186,12 @@ rl::test() { # Save first element for string compare firstelement="${path}" - # Check for excludes elif excludemsg="$(toexclude "${firstelement}")"; then + # Current path is excluded (( tests_skipped++ )) rl::printPath "$(( i/2 ))" "${firstelement}" && printf " %b skip (%s)\n" "🛇" "${excludemsg}" - # Execute tests else - # Do the compare between two following elements + # Execute test case if ! rl::testcmp "$(( i/2 ))" "${firstelement}" \ "${path}" "$($tool_rdlink -- "${firstelement}")"; then (( tests_failed++ )) @@ -206,16 +208,16 @@ rl::test() { (( testend )) && break done (( testend )) && rl::printTestSummary $tests_success $tests_failed $tests_skipped && return 1 - + # Initialize competition tests (( ! flag_onlyassert )) && tocompete_init - + # Only run `compete_args` if arguments are available if [[ "$@" ]]; then compete_args=( "Tests from command line" "$@" ) tocompete=(compete_args) fi - + # Compare output of rdlink and readlink -f if (( ${#tocompete[@]} )) ; then printf "\n# Competition tests (readlink -f == rdlink)\n" @@ -231,13 +233,13 @@ rl::test() { (( ! flag_extendedOutput )) && printf "%${config_path_width}s %s %s\n" "" "" "✗ [ACTUAL]" else - # Check for excludes if excludemsg="$(toexclude "${path}")" ; then + # Current path is excluded (( tests_skipped++ )) rl::printPath "${i}" "${path}" && printf " %b skip (%s)\n" "🛇" "${excludemsg}" - # Execute tests elif ! rl::testcmp "${i}" "${path}" \ "$(${tool_readlink} "$path")" "$(${tool_rdlink} -- "$path")"; then + # Test case failed (( tests_failed++ )) # Run all tests if option -a is pressend (( ! $flag_runall )) && testend=1 && break @@ -250,7 +252,7 @@ rl::test() { done (( testend )) && break done - + rl::printTestSummary $tests_success $tests_failed $tests_skipped (( testend )) && return 1 || return 0 } diff --git a/test/totest.sh b/test/totest.sh index d6fe2b8..f26be7a 100644 --- a/test/totest.sh +++ b/test/totest.sh @@ -30,7 +30,7 @@ compete_relative=( "Resolving of relative links" # Valid "dir_1/file" # Valid relative link to path with relative element ) - + compete_all=( "Test - everything starting from /" /**/* ) @@ -51,7 +51,7 @@ tocompete_init() { touch "dir_2/dir_22/file" ln -s "dir_2/dir_22" "dir_3_l" ln -s "../dir_3_l/file" "dir_1/file" - + # compete_no_permission mkdir -p "${_tc_tmp}/noperm" chmod 400 "${_tc_tmp}/noperm" @@ -62,11 +62,11 @@ tocompete_init() { # compete_relative ln -s "../nofile" "${_tc_tmp}/nofile_l" ln -s "../nodir/nofile" "${_tc_tmp}/nopath_l" - + #echo "rl: " && readlink "${_tc_tmp}/lnoperm" #ls -l "${_tc_tmp}" } - + # Base directory for the test cd "${_tc_tmp}"