Skip to content

Commit

Permalink
testing.sh: use ERRORINERROR testing
Browse files Browse the repository at this point in the history
* Test that jj-fzf describe does not continue with $EDITOR
  once an invalid change_id has been encountered.
* Use the string 'ERRORINERROR' to catch $EDITOR invocations

Signed-off-by: Tim Janik <[email protected]>
  • Loading branch information
tim-janik committed Dec 1, 2024
1 parent b5038bc commit 108a96c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jj-fzf()
}
assert1error()
{
local L="$(wc -l <<<"$*")"
test "$L" == 1 ||
die $'output exceeds one line: \\\n' "$*"
grep -Eq '\bERROR:' <<<"$*" ||
die "output contains no ERROR message: $*"
}
Expand All @@ -41,6 +38,11 @@ assert0error()
! grep -Eq '\bERROR:' <<<"$*" ||
die "output contains an ERROR message: $*"
}
assert0errorinerror()
{
! grep -Eq 'ERRORINERROR' <<<"$*" ||
die "output contains an ERRORINERROR message: $*"
}
assert_zero()
{
test "$1" == 0 ||
Expand Down Expand Up @@ -84,10 +86,13 @@ clear_repo()
TEST='jj-fzf-functions-fail-early'
clear_repo
( set -e
export JJ_CONFIG='' EDITOR=false
# Test that jj-fzf describe does not continue with $EDITOR
# once an invalid change_id has been encountered.
export JJ_CONFIG='' EDITOR='echo ERRORINERROR'
OUT="$(set +x; jj-fzf describe 'zzzzaaaa' 2>&1)" && E=$? || E=$?
assert_nonzero $E
assert1error "$OUT"
assert0errorinerror "$OUT"
); TEST_OK "$TEST"

TEST='jj-fzf-new'
Expand Down

0 comments on commit 108a96c

Please sign in to comment.