Skip to content

Commit

Permalink
Merge pull request #44 from buildkite-plugins/toote_fix_tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
pzeballos authored Sep 27, 2022
2 parents 961c843 + 00c623a commit 3b0de92
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
steps:
- label: run bats tests
plugins:
- docker-compose#v3.9.0:
- docker-compose#v3.13.0:
run: tests

- label: run shellcheck
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '2'
services:
tests:
image: buildkite/plugin-tester
image: buildkite/plugin-tester:v3.0.1
volumes:
- .:/plugin
3 changes: 2 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": [
"config:base"
"config:base",
":disableDependencyDashboard"
],
"docker-compose": {
"digest": {
Expand Down
14 changes: 10 additions & 4 deletions tests/run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ load '/usr/local/lib/bats/load.bash'
assert_success
assert_output --partial "Running shellcheck on 1 files"
assert_output --partial "testing test.sh"
assert_output --partial "Files are ok"

unstub docker
}
Expand All @@ -25,13 +26,14 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_PLUGIN_SHELLCHECK_FILES_2="missing"

stub docker \
"run --rm -v $PWD:/mnt --workdir /mnt koalaman/shellcheck:stable --color=always \"tests/testdata/test.sh tests/testdata/subdir/llamas.sh tests/testdata/subdir/shell with space.sh\"' : echo testing test.sh llamas.sh shell with space.sh"
"run --rm -v $PWD:/mnt --workdir /mnt koalaman/shellcheck:stable --color=always tests/testdata/test.sh tests/testdata/subdir/llamas.sh tests/testdata/subdir/shell\ with\ a\ space.sh : echo testing test.sh llamas.sh shell with space.sh"

run "$PWD/hooks/command"

assert_success
assert_output --partial "Running shellcheck on 3 files"
assert_output --partial "testing test.sh llamas.sh shell with space.sh"
assert_output --partial "Files are ok"

unstub docker
}
Expand All @@ -48,6 +50,7 @@ load '/usr/local/lib/bats/load.bash'
assert_success
assert_output --partial "Running shellcheck on 1 files"
assert_output --partial "testing llamas.sh"
assert_output --partial "Files are ok"

unstub docker
}
Expand All @@ -66,6 +69,7 @@ load '/usr/local/lib/bats/load.bash'
assert_success
assert_output --partial "Running shellcheck on 1 files"
assert_output --partial "testing llamas.sh"
assert_output --partial "Files are ok"

unstub docker
}
Expand All @@ -79,13 +83,14 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_PLUGIN_SHELLCHECK_OPTIONS_2="-x"

stub docker \
"run --rm -v $PWD:/mnt --workdir /mnt koalaman/shellcheck:stable --color=always --exclude=SC2086 --format=gcc -x \"tests/testdata/test.sh tests/testdata/subdir/llamas.sh tests/testdata/subdir/shell with space.sh\"' : echo testing test.sh llamas.sh shell with space.sh"
"run --rm -v $PWD:/mnt --workdir /mnt koalaman/shellcheck:stable --color=always --exclude=SC2086 --format=gcc -x tests/testdata/test.sh tests/testdata/subdir/llamas.sh tests/testdata/subdir/shell\ with\ a\ space.sh : echo testing test.sh llamas.sh shell with space.sh"

run "$PWD/hooks/command"

assert_success
assert_output --partial "Running shellcheck on 3 files"
assert_output --partial "testing test.sh llamas.sh shell with space.sh"
assert_output --partial "Files are ok"

unstub docker
}
Expand All @@ -94,13 +99,14 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_PLUGIN_SHELLCHECK_FILES_0="tests/testdata/subdir/llamas.sh"

stub docker \
"run --rm -v $PWD:/mnt --workdir /mnt koalaman/shellcheck:stable --color=always tests/testdata/test.sh tests/testdata/subdir/llamas.sh tests/testdata/subdir/shell\ with\ space.sh' : echo shellcheck failed; exit 1"
"run --rm -v $PWD:/mnt --workdir /mnt koalaman/shellcheck:stable --color=always tests/testdata/subdir/llamas.sh : echo shellcheck failed; exit 1"

run "$PWD/hooks/command"

assert_failure
assert_failure 1
assert_output --partial "Running shellcheck on 1 files"
assert_output --partial "shellcheck failed"
refute_output --partial "Files are ok"

unstub docker
}

0 comments on commit 3b0de92

Please sign in to comment.