Skip to content

Commit

Permalink
Make timing more robust against slow CI runners
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-schulze-vireso committed Jul 25, 2022
1 parent c5881d0 commit 97d0d2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/fixtures/timeout/sleep2.bats
@@ -1,5 +1,5 @@

@test "my sleep 2" {
sleep 2
@test "my sleep ${SLEEP:-2}" {
sleep ${SLEEP:-2}
}

4 changes: 2 additions & 2 deletions test/timeout.bats
Expand Up @@ -4,14 +4,14 @@ fixtures timeout
bats_require_minimum_version 1.5.0

@test "test faster than timeout" {
run -0 env BATS_TIMEOUT=3 bats "$FIXTURE_ROOT"
run -0 env BATS_TIMEOUT=3 SLEEP=2 bats "$FIXTURE_ROOT"
[ "${lines[0]}" == '1..1' ]
[ "${lines[1]}" == 'ok 1 my sleep 2' ]
[ "${#lines[@]}" -eq 2 ]
}

@test "test longer than timeout" {
run ! env BATS_TIMEOUT=1 bats "$FIXTURE_ROOT"
run ! env BATS_TIMEOUT=1 SLEEP=10 bats "$FIXTURE_ROOT"
[ "${lines[0]}" == '1..1' ]
[ "${lines[1]}" == 'not ok 1 my sleep 2 # timeout after 1s' ]
[ "${lines[2]}" == '# (in test file test/fixtures/timeout/sleep2.bats, line 3)' ]
Expand Down

0 comments on commit 97d0d2c

Please sign in to comment.