diff --git a/tests/test_version-lookup.bats b/tests/test_version-lookup.bats index b0864e8..86cc114 100644 --- a/tests/test_version-lookup.bats +++ b/tests/test_version-lookup.bats @@ -5,6 +5,15 @@ load helper_print-info export repo=".tmp_testing/repo" +setup() { + # get the containing directory of this file + # use $BATS_TEST_FILENAME instead of ${BASH_SOURCE[0]} or $0, + # as those will point to the bats executable's location or the preprocessed file respectively + DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" + # make executables in src/ visible to PATH + PATH="$DIR/../:$PATH" +} + function init_repo { rm -rf "${repo}" && mkdir -p "${repo}" && @@ -22,7 +31,7 @@ function init_repo { export scheme="foover" - run ../../version-lookup.sh + run version-lookup.sh print_run_info [ "$status" -eq 8 ] && @@ -30,7 +39,7 @@ function init_repo { } @test "no deprecated set-output calls made" { - run grep -q "::set-output" version-lookup.sh + run grep -q "::set-output" ../version-lookup.sh print_run_info [ "$status" -eq 1 ] @@ -43,7 +52,7 @@ function init_repo { git tag 0.1.1 git tag 0.1.2 - run ../../version-lookup.sh + run version-lookup.sh print_run_info [ "$status" -eq 0 ] && @@ -55,7 +64,7 @@ function init_repo { git tag 0.1.2 - run ../../version-lookup.sh + run version-lookup.sh print_run_info [ "$status" -eq 0 ] && @@ -69,7 +78,7 @@ function init_repo { git tag 1.2.300 git tag 1.2.301-dev.234 - run ../../version-lookup.sh + run version-lookup.sh print_run_info [ "$status" -eq 0 ] && @@ -79,7 +88,7 @@ function init_repo { @test "returns 0.0.0 if no normal version detected" { init_repo - run ../../version-lookup.sh + run version-lookup.sh print_run_info [ "$status" -eq 0 ] && @@ -91,7 +100,7 @@ function init_repo { git tag 0.0.1-dev.999 - run ../../version-lookup.sh + run version-lookup.sh print_run_info [ "$status" -eq 0 ] && @@ -103,7 +112,7 @@ function init_repo { export scheme="calver" - run ../../version-lookup.sh + run version-lookup.sh print_run_info [ "$status" -eq 0 ] && @@ -115,7 +124,7 @@ function init_repo { git tag v3.4.5 - run ../../version-lookup.sh + run version-lookup.sh print_run_info [ "$status" -eq 0 ] && diff --git a/version-lookup.sh b/version-lookup.sh index 6a4d170..1780cc9 100755 --- a/version-lookup.sh +++ b/version-lookup.sh @@ -50,7 +50,7 @@ if [[ -z "${current_version:-}" ]] ; then current_version="0.0.0" ;; calver) - current_version="$(date '+%Y.%-m.1')" + current_version="$(date '+%Y.%-m.0')" ;; esac fi