The 'basic' test uses 'grep -q' to filter the resulting possible completion words while looking for the presence or absence of certain git commands, and relies on grep's exit status to indicate a failure. This works fine as long as there are no errors. However, in case of a failure it doesn't give any indication whatsoever about the reason of the failure, i.e. which condition failed. To make testers' life easier provide some output about the failed condition: store the results of the filtering in a file and compare its contents to the expected results by the good old test_cmp helper. However, to actually get output from test_cmp in case of an error we must make sure that test_cmp is always executed. Since in case of an error grep's exit code aborts the test immediately, before running the subsequent test_cmp, do the filtering using sed instead of grep. Signed-off-by: SZEDER Gábor <szeder@xxxxxxxxxx> --- t/t9902-completion.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 8fa025f9..b56759f7 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -158,14 +158,22 @@ test_expect_success '__gitcomp - suffix' ' test_expect_success 'basic' ' run_completion "git \"\"" && # built-in - grep -q "^add \$" out && + echo "add " >expected && + sed -n "/^add \$/p" out >out2 && + test_cmp expected out2 && # script - grep -q "^filter-branch \$" out && + echo "filter-branch " >expected && + sed -n "/^filter-branch \$/p" out >out2 && + test_cmp expected out2 && # plumbing - ! grep -q "^ls-files \$" out && + >expected && + sed -n "/^ls-files \$/p" out >out2 && + test_cmp expected out2 && run_completion "git f" && - ! grep -q -v "^f" out + >expected && + sed -n "/^[^f]/p" out >out2 && + test_cmp expected out2 ' test_expect_success 'double dash "git" itself' ' -- 1.8.0.220.g4d14ece -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html