-
Notifications
You must be signed in to change notification settings - Fork 616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve test suite portability #609
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
262ac2a
recast GNU sed constructs per POSIX
rolandwalker 2c7b324
remove unused %s
rolandwalker 9109dc4
give default values for vars
rolandwalker 0202ff6
quote "$@" to avoid double-splitting
rolandwalker e6c6968
defensive driving: quote unless split is wanted
rolandwalker 0088549
remove non-POSIX quoting construct $''
rolandwalker 389b052
defensive quoting inside $()
rolandwalker 2e5eab0
POSIX nit: prefer && to -a
rolandwalker 9be2c83
add block to quote $runner
rolandwalker 549a4cd
alternate path for diff-highlight
rolandwalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ tig_script() { | |
# Ensure that the steps finish by quitting | ||
printf '%s\n:quit\n' "$@" \ | ||
| sed -e 's/^[ ]*//' -e '/^$/d' \ | ||
| sed "s|:save-display\s\+\(\S*\)|:save-display $HOME/\1|" \ | ||
| sed "s|:save-display[ ]\{1,\}\([^ ]\{1,\}\)|:save-display $HOME/\1|" \ | ||
> "$TIG_SCRIPT" | ||
} | ||
|
||
|
@@ -166,7 +166,7 @@ gitconfig() { | |
|
||
in_work_dir() | ||
{ | ||
(cd "$work_dir" && $@) | ||
(cd "$work_dir" && "$@") | ||
} | ||
|
||
auto_detect_debugger() { | ||
|
@@ -195,7 +195,7 @@ debugger= | |
trace= | ||
valgrind= | ||
|
||
set -- $TIG_TEST_OPTS $TEST_OPTS | ||
set -- ${TIG_TEST_OPTS:-} ${TEST_OPTS:-} | ||
|
||
while [ $# -gt 0 ]; do | ||
arg="$1"; shift | ||
|
@@ -283,10 +283,10 @@ show_test_results() | |
sed "s/^/$indent[skipped] /" < .test-skipped | ||
return | ||
fi | ||
if [ -n "$trace" -a -n "$TIG_TRACE" -a -e "$TIG_TRACE" ]; then | ||
if [ -n "$trace" ] && [ -n "$TIG_TRACE" ] && [ -e "$TIG_TRACE" ]; then | ||
sed "s/^/$indent[trace] /" < "$TIG_TRACE" | ||
fi | ||
if [ -n "$valgrind" -a -e "$valgrind" ]; then | ||
if [ -n "$valgrind" ] && [ -e "$valgrind" ]; then | ||
sed "s/^/$indent[valgrind] /" < "$valgrind" | ||
fi | ||
if [ ! -d "$HOME" ] || [ ! -e .test-result ]; then | ||
|
@@ -299,7 +299,7 @@ show_test_results() | |
failed="$(grep FAIL < .test-result | wc -l)" | ||
count="$(sed -n '/\(FAIL\|OK\)/p' < .test-result | wc -l)" | ||
|
||
printf "Failed %d out of %d test(s)%s\n" $failed $count | ||
printf "Failed %d out of %d test(s)\n" "$failed" "$count" | ||
|
||
# Show output from stderr if no output is expected | ||
if [ -e stderr ]; then | ||
|
@@ -311,7 +311,7 @@ show_test_results() | |
tr '\r' '\n' < .test-result | ||
elif [ "$verbose" ]; then | ||
count="$(sed -n '/\(OK\)/p' < .test-result | wc -l)" | ||
printf "Passed %d assertions\n" $count | ||
printf "Passed %d assertions\n" "$count" | ||
fi | sed "s/^/$indent| /" | ||
} | ||
|
||
|
@@ -355,6 +355,10 @@ test_require() | |
;; | ||
diff-highlight) | ||
diff_highlight_path="$(git --exec-path)/../../share/git-core/contrib/diff-highlight/diff-highlight" | ||
if [ ! -e "$diff_highlight_path" ]; then | ||
# alt path | ||
diff_highlight_path="$(git --exec-path)/../../share/git/contrib/diff-highlight/diff-highlight" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
fi | ||
if [ ! -e "$diff_highlight_path" ]; then | ||
test_skip "The test requires diff-highlight, usually found in share/git-core-contrib" | ||
fi | ||
|
@@ -443,18 +447,26 @@ test_tig() | |
if [ "$#" -gt 0 ]; then | ||
echo "*** - This test expects the following arguments: $@" | ||
fi | ||
(cd "$work_dir" && $debugger tig "$@") | ||
(cd "$work_dir" && "$debugger" tig "$@") | ||
else | ||
set +e | ||
runner= | ||
# FIXME: Tell Valgrind to forward status code | ||
if [ "$expected_status_code" = 0 -a -n "$valgrind" ]; then | ||
if [ "$expected_status_code" = 0 ] && [ -n "$valgrind" ]; then | ||
runner=valgrind_exec | ||
fi | ||
if [ -s "${prefix}stdin" ]; then | ||
(cd "$work_dir" && $runner tig "$@") < "${prefix}stdin" > "${prefix}stdout" 2> "${prefix}stderr.orig" | ||
if [ -n "$runner" ]; then | ||
if [ -s "${prefix}stdin" ]; then | ||
(cd "$work_dir" && "$runner" tig "$@") < "${prefix}stdin" > "${prefix}stdout" 2> "${prefix}stderr.orig" | ||
else | ||
(cd "$work_dir" && "$runner" tig "$@") > "${prefix}stdout" 2> "${prefix}stderr.orig" | ||
fi | ||
else | ||
(cd "$work_dir" && $runner tig "$@") > "${prefix}stdout" 2> "${prefix}stderr.orig" | ||
if [ -s "${prefix}stdin" ]; then | ||
(cd "$work_dir" && tig "$@") < "${prefix}stdin" > "${prefix}stdout" 2> "${prefix}stderr.orig" | ||
else | ||
(cd "$work_dir" && tig "$@") > "${prefix}stdout" 2> "${prefix}stderr.orig" | ||
fi | ||
fi | ||
status_code="$?" | ||
if [ "$status_code" != "$expected_status_code" ]; then | ||
|
@@ -482,7 +494,7 @@ test_tig() | |
|
||
test_graph() | ||
{ | ||
test-graph $@ > stdout 2> stderr.orig | ||
test-graph "$@" > stdout 2> stderr.orig | ||
} | ||
|
||
test_case() | ||
|
@@ -526,7 +538,7 @@ run_test_cases() | |
work_dir="$work_dir/$(cat "$name-cwd")" | ||
fi | ||
ORIG_IFS="$IFS" | ||
IFS=$' ' | ||
IFS=' ' | ||
test_tig $(if [ -e "$name-args" ]; then cat "$name-args"; fi) | ||
IFS="$ORIG_IFS" | ||
work_dir="$old_work_dir" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch.