mirror of
https://code.forgejo.org/actions/cascading-pr.git
synced 2025-06-27 20:33:44 +00:00
simplify the retry implementation and tests
This commit is contained in:
parent
9d138db73c
commit
15dc3ec7a7
4 changed files with 29 additions and 18 deletions
28
tests/run.sh
28
tests/run.sh
|
@ -171,17 +171,27 @@ function unit_retry() {
|
|||
# Succeeds after two tries
|
||||
#
|
||||
echo 2 > $TMPDIR/unit_retry_two
|
||||
RETRY_DELAYS='1 1 1 1' retry unit_retry_fail $two > $TMPDIR/retry.test-result 2> $TMPDIR/retry.test-log
|
||||
if ! RETRY_DELAYS='1 1 1 1' retry unit_retry_fail $two > $TMPDIR/retry.test-result 2> $TMPDIR/retry.test-log ; then
|
||||
cat $TMPDIR/retry.test-result $TMPDIR/retry.test-log
|
||||
return 1
|
||||
fi
|
||||
test "$(cat $TMPDIR/retry.test-result)" = "RESULT"
|
||||
cat $TMPDIR/retry.test-log
|
||||
test "$(grep -c 'waiting 1 unit_retry_fail' $TMPDIR/retry.test-log)" = 2
|
||||
|
||||
if test "$(grep -c '^waiting 1 unit_retry_fail' $TMPDIR/retry.test-log)" != 2 ; then
|
||||
cat $TMPDIR/retry.test-log
|
||||
return 1
|
||||
fi
|
||||
#
|
||||
# Succeeds immediately
|
||||
#
|
||||
RETRY_DELAYS='1' retry unit_retry_fail $two > $TMPDIR/retry.test-result 2> $TMPDIR/retry.test-log
|
||||
if ! RETRY_DELAYS='1' retry unit_retry_fail $two > $TMPDIR/retry.test-result 2> $TMPDIR/retry.test-log ; then
|
||||
cat $TMPDIR/retry.test-result $TMPDIR/retry.test-log
|
||||
return 1
|
||||
fi
|
||||
test "$(cat $TMPDIR/retry.test-result)" = "RESULT"
|
||||
test "$(grep -c 'waiting 1 unit_retry_fail' $TMPDIR/retry.test-log)" = 0
|
||||
if test "$(grep -c 'waiting 1 unit_retry_fail' $TMPDIR/retry.test-log)" != 0 ; then
|
||||
cat $TMPDIR/retry.test-log
|
||||
return 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Verify the output is only the output of the last run and is not polluted by
|
||||
|
@ -194,7 +204,8 @@ function unit_retry() {
|
|||
# Fails after one try
|
||||
#
|
||||
echo 2 > $TMPDIR/unit_retry_two
|
||||
if RETRY_DELAYS='1' retry unit_retry_fail $two |& tee $TMPDIR/retry.test-log ; then
|
||||
if RETRY_DELAYS='1' retry unit_retry_fail $two > $TMPDIR/retry.test-result 2> $TMPDIR/retry.test-log ; then
|
||||
cat $TMPDIR/retry.test-result $TMPDIR/retry.test-log
|
||||
return 1
|
||||
fi
|
||||
grep --quiet 'retry failed' $TMPDIR/retry.test-log
|
||||
|
@ -368,8 +379,7 @@ function integration() {
|
|||
}
|
||||
|
||||
function unit() {
|
||||
# do not run in debug mode, it will polute the output and fail
|
||||
${BASH_SOURCE[0]} --verbose unit_retry
|
||||
unit_retry
|
||||
}
|
||||
|
||||
function run_tests() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue