Skip to content

Commit

Permalink
Merge pull request #405 from bats-core/martin-schulze-vireso-patch-1
Browse files Browse the repository at this point in the history
Add Github Actions for tests
  • Loading branch information
sublimino committed Feb 15, 2021
2 parents 2905040 + 1e12a80 commit 0d58a65
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 130 deletions.
16 changes: 0 additions & 16 deletions .appveyor.yml

This file was deleted.

91 changes: 91 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Tests

# Controls when the action will run.
on: [push, pull_request, workflow_dispatch]

jobs:
shellcheck:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Run shellcheck
run: |
sudo apt-get update -y
sudo apt-get install shellcheck
./shellcheck.sh
linux:
strategy:
matrix:
os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04']
env_vars:
- ''
# allow for some parallelity without GNU parallel, since it is not installed by default
- 'BATS_NO_PARALLELIZE_ACROSS_FILES=1 BATS_NUMBER_OF_PARALLEL_JOBS=2'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Run test on OS ${{ matrix.os }}
shell: 'script -q -e -c "bash {0}"' # work around tty issues
env:
TERM: linux # fix tput for tty issue work around
run: |
bash --version
bash -c "time ${{ matrix.env_vars }} bin/bats --formatter tap test"
windows:
strategy:
matrix:
os: ['windows-2019']
env_vars:
- ''
# allow for some parallelity without GNU parallel, since it is not installed by default
- 'BATS_NO_PARALLELIZE_ACROSS_FILES=1 BATS_NUMBER_OF_PARALLEL_JOBS=2'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Run test on OS ${{ matrix.os }}
run: |
bash --version
bash -c "time ${{ matrix.env_vars }} bin/bats --formatter tap test"
macos:
strategy:
matrix:
os: ['macos-10.15']
env_vars:
- ''
# allow for some parallelity without GNU parallel, since it is not installed by default
- 'BATS_NO_PARALLELIZE_ACROSS_FILES=1 BATS_NUMBER_OF_PARALLEL_JOBS=2'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install unbuffer via expect
run: brew install expect
- name: Run test on OS ${{ matrix.os }}
shell: 'unbuffer bash {0}' # work around tty issues
env:
TERM: linux # fix tput for tty issue work around
run: |
bash --version
bash -c "time ${{ matrix.env_vars }} bin/bats --formatter tap test"
bash-version:
strategy:
matrix:
version: ['3.2', '4.0', '4.1', '4.2', '4.3', '4.4', '4', '5.0', '5.1', '5', 'latest']
env_vars:
- ''
# also test running (recursively!) in parallel
- '-e BATS_NUMBER_OF_PARALLEL_JOBS=2'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run test on bash version ${{ matrix.version }}
shell: 'script -q -e -c "bash {0}"' # work around tty issues
run: |
set -e
docker build --build-arg bashver="${{ matrix.version }}" --tag "bats/bats:bash-${{ matrix.version }}" .
docker run -it "bash:${{ matrix.version }}" --version
time docker run -it ${{ matrix.env_vars }} "bats/bats:bash-${{ matrix.version }}" --tap /opt/bats/test
52 changes: 0 additions & 52 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions test/bats.bats
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ teardown() {

@test "summary passing tests" {
run filter_control_sequences bats -p "$FIXTURE_ROOT/passing.bats"
echo "$output"
[ $status -eq 0 ]
[ "${lines[1]}" = "1 test, 0 failures" ]
}
Expand Down
27 changes: 27 additions & 0 deletions test/fixtures/parallel/helper.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# block until at least <barrier-size> processes of this barrier group entered the barrier
# once this happened, all latecomers will go through immediately!
# WARNING: a barrier group consists of all processes with the same barrier name *and* size!
single-use-barrier() { # <barrier-name> <barrier-size> [<timeout-in-seconds> [<sleep-cycle-time>]]
local barrier_name="$1"
local barrier_size="$2"
local timeout_in_seconds="${3:-0}"
local sleep_cycle_time="${3:-1}"
# use name and size to distinguish between invocations
# this will block inconsistent sizes on the same name!
local BARRIER_SUFFIX=${barrier_name//\//_}-$barrier_size
local BARRIER_FILE="$BATS_RUN_TMPDIR/barrier-$BARRIER_SUFFIX"
# mark our entry for all others
echo "in-$$" >> "$BARRIER_FILE"
local start="$SECONDS"
# wait for others to enter
while [[ $(wc -l <"$BARRIER_FILE" ) -lt $barrier_size ]]; do
if [[ $timeout_in_seconds -ne 0 && $(( SECONDS - start )) -gt $timeout_in_seconds ]]; then
mv "$BARRIER_FILE" "$BARRIER_FILE-timeout"
printf "ERROR: single-use-barrier %s timed out\n" "$BARRIER_SUFFIX" >&2
return 1
fi
sleep "$sleep_cycle_time"
done
# mark our exit
echo "out-$$" >> "$BARRIER_FILE"
}
43 changes: 12 additions & 31 deletions test/fixtures/parallel/parallel.bats
Original file line number Diff line number Diff line change
@@ -1,39 +1,20 @@
@test "slow test 1" {
sleep 3s
}

@test "slow test 2" {
sleep 3s
}

@test "slow test 3" {
sleep 3s
}

@test "slow test 4" {
sleep 3s
setup() {
load 'helper'
echo "start $BATS_TEST_NAME $BATS_TEST_FILENAME" >> "$FILE_MARKER"
}

@test "slow test 5" {
sleep 3s
teardown() {
echo "stop $BATS_TEST_NAME $BATS_TEST_FILENAME" >> "$FILE_MARKER"
}

@test "slow test 6" {
sleep 3s
}

@test "slow test 7" {
sleep 3s
}

@test "slow test 8" {
sleep 3s
@test "slow test 1" {
single-use-barrier "parallel" $PARALLELITY
}

@test "slow test 9" {
sleep 3s
@test "slow test 2" {
single-use-barrier "parallel" $PARALLELITY
}

@test "slow test 10" {
sleep 3s
}
@test "slow test 3" {
single-use-barrier "parallel" $PARALLELITY
}
1 change: 1 addition & 0 deletions test/fixtures/parallel/setup_file/helper.bash
8 changes: 7 additions & 1 deletion test/fixtures/parallel/setup_file/setup_file.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
setup_file() {
sleep 3
load 'helper'
echo "start $BATS_TEST_FILENAME" >> "${FILE_MARKER?}"
single-use-barrier setup-file ${PARALLELITY?} 10
}

teardown_file() {
echo "stop $BATS_TEST_FILENAME" >> "$FILE_MARKER"
}

@test "nothing" {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/parallel/suite/helper.bash
2 changes: 1 addition & 1 deletion test/fixtures/suite/skip/skip-in-setup.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ setup() {
}

@test "skip in setup" {
true
false
}

@test "skip in setup and test" {
Expand Down

0 comments on commit 0d58a65

Please sign in to comment.