diff --git a/.github/workflows/asdf_test.yml b/.github/workflows/asdf_test.yml index c535258..39cb2f5 100644 --- a/.github/workflows/asdf_test.yml +++ b/.github/workflows/asdf_test.yml @@ -9,24 +9,29 @@ on: - "**.md" jobs: - build: + plugin_test: + name: asdf plugin test strategy: matrix: - os: [ubuntu-latest, macOS-latest] - + os: + - ubuntu-latest + - macos-11 runs-on: ${{ matrix.os }} - steps: - - name: checkout - uses: actions/checkout@v2 - - - name: install asdf-vm - run: git clone https://github.com/asdf-vm/asdf.git $HOME/asdf - - - name: install bats and run test - run: . $HOME/asdf/asdf.sh + - name: Test OS + run: | + uname + uname -a + uname -s + - name: asdf_plugin_test + uses: asdf-vm/actions/plugin-test@v1 + with: + command: bats --version + - name: Run tests + run: | asdf plugin add bats $GITHUB_WORKSPACE asdf list all bats asdf install bats latest + asdf global bats latest bats --version - bats test/ + bats tests/ diff --git a/bin/download b/bin/download index 9b7a479..8c17e33 100755 --- a/bin/download +++ b/bin/download @@ -3,7 +3,6 @@ set -e set -o pipefail -export LATEST_BATS_VERSION="v1.2.0" export DEFAULT_BATS_REPO="https://github.com/bats-core/bats-core.git" fail() { @@ -17,6 +16,8 @@ download_bats() { local download_path=$2 local repo_url=$3 + version=$(echo "$version" | sed 's/^v\(.*\)/\1/') + ( echo "* Downloading Bats-core(version:$version) to $download_path" git clone --depth=1 -b "v$version" "$repo_url" "$download_path" >/dev/null @@ -29,17 +30,17 @@ download_bats() { } version=${1:-"$ASDF_INSTALL_VERSION"} -if [[ -z "$version" ]] ; then +if [[ -z "$version" ]]; then fail "Version is missing - specify 1st param or set \$ASDF_INSTALL_VERSION" fi download_path=${2:-"$ASDF_DOWNLOAD_PATH"} -if [[ -z "$download_path" ]] ; then +if [[ -z "$download_path" ]]; then fail "Download path is missing - specify 2nd param or set \$ASDF_DOWNLOAD_PATH" fi repo_url=${3:-"$DEFAULT_BATS_REPO"} -if [[ -z "$repo_url" ]] ; then +if [[ -z "$repo_url" ]]; then fail "repo_url is missing - specify 3rd param" fi diff --git a/tests/download.bats b/tests/download.bats index 141293b..0a599c9 100755 --- a/tests/download.bats +++ b/tests/download.bats @@ -2,7 +2,7 @@ setup() { export bin_path - bin_path=$(readlink -e "$BATS_TEST_DIRNAME/../bin") + bin_path=$(python -c "import os,sys; print(os.path.realpath(os.path.expanduser(sys.argv[1])))" "$BATS_TEST_DIRNAME/../bin") export cmd="download" export test_version="v1.2.0" diff --git a/tests/list-all.bats b/tests/list-all.bats index 690c7ad..e0d1087 100755 --- a/tests/list-all.bats +++ b/tests/list-all.bats @@ -1,7 +1,7 @@ #!/usr/bin/env bats setup() { - export bin_path=$(readlink -e "$BATS_TEST_DIRNAME/../bin") + export bin_path=$(python -c "import os,sys; print(os.path.realpath(os.path.expanduser(sys.argv[1])))" "$BATS_TEST_DIRNAME/../bin") export cmd="list-all" } @@ -17,11 +17,11 @@ main() { # check versions echo "$output" - [[ "$output" =~ "v0.1.0" ]] - [[ "$output" =~ "v0.2.0" ]] + [[ "$output" =~ "0.1.0" ]] + [[ "$output" =~ "0.2.0" ]] # check that versions are on same line - [[ "$output" =~ "v0.1.0 v0.2.0" ]] + [[ "$output" =~ "0.1.0 0.2.0" ]] } @test 'success if called with param' {