Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/allow v in version #10

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions .github/workflows/asdf_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
9 changes: 5 additions & 4 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/download.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better solution that does not use python ?

maybe smt like this would work:

parent_dir=$(dirname "$BATS_TEST_DIRNAME")
bin_path="${parent_dir}/bin"

export cmd="download"
export test_version="v1.2.0"

Expand Down
8 changes: 4 additions & 4 deletions tests/list-all.bats
Original file line number Diff line number Diff line change
@@ -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"
}

Expand 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' {
Expand Down