Skip to content

Commit

Permalink
Merge pull request #724 from rolandwalker/test-timeout-followups
Browse files Browse the repository at this point in the history
Test timeout followups
  • Loading branch information
jonas authored Aug 12, 2017
2 parents f7b4319 + 585cf8b commit 3a1d502
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
10 changes: 6 additions & 4 deletions test/status/on-branch-test
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,17 @@ add_exec_prefix()
}

tig_script "all" "
$(cat < test-cases | while read -r name; do
$(while read -r name; do
add_exec_prefix "$name-before"
printf ':save-display all-%s.screen\n' "$name"
add_exec_prefix "$name-after"
done)
done < test-cases)
"

test_timeout 60

test_tig status

cat < test-cases | while read -r name; do
while read -r name; do
assert_equals "all-$name.screen" < "$name.expected"
done
done < test-cases
10 changes: 6 additions & 4 deletions test/status/on-branch-tracking-info-test
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,17 @@ add_exec_prefix()
}

tig_script "all" "
$(cat < test-cases | while read -r name; do
$(while read -r name; do
add_exec_prefix "$name-before"
printf ':save-display all-%s.screen\n' "$name"
add_exec_prefix "$name-after"
done)
done < test-cases)
"

test_timeout 60

test_tig status

cat < test-cases | while read -r name; do
while read -r name; do
assert_equals "all-$name.screen" < "$name.expected"
done
done < test-cases
15 changes: 14 additions & 1 deletion test/tools/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ trace=
todos=
valgrind=
timeout=10
vlg_timeout_bonus=60

ORIG_IFS="$IFS"
IFS=" "
Expand Down Expand Up @@ -315,7 +316,7 @@ assert_vars()
die "Test must supply the expected count of assertions to assert_vars()"
fi

grep -c . "$vars_file" | assert_equals "$vars_count_file" strict "$*"
grep -c . < "$vars_file" | assert_equals "$vars_count_file" strict "$*"

if [ -e "$expected_vars_file" ]; then
assert_equals "$vars_file" strict "$*" < "$expected_vars_file"
Expand Down Expand Up @@ -388,6 +389,15 @@ test_todo()
test_todo_message "$*" >> .test-skipped
}

test_timeout()
{
if [ -z "${1:-}" ]; then
die 'test_timeout requires an argument'
fi

timeout="${1:-}"
}

require_git_version()
{
git_version="$(git version | sed 's/git version \([0-9\.]*\).*/\1/')"
Expand Down Expand Up @@ -540,6 +550,9 @@ test_tig()
runner=exec
if [ "$expected_status_code" = 0 ] && [ -n "$valgrind" ]; then
runner=valgrind_exec
if [ "$timeout" -gt 0 ]; then
timeout="$((timeout + vlg_timeout_bonus))"
fi
fi
if [ -s "$HOME/${prefix}stdin" ]; then
exec 4<"$HOME/${prefix}stdin"
Expand Down

0 comments on commit 3a1d502

Please sign in to comment.