From: James Cook Subject: [patch] regress/cmdline: fix handling of unexpected success To: gameoftrees@openbsd.org Date: Sat, 17 Jun 2023 19:05:35 +0000 There are many places in the regress/cmdline scripts where a result of "0" is passed to test_done when a command succeeded unexpectedly. For example: if [ $ret -eq 0 ]; then echo "got merge succeeded unexpectedly" >&2 test_done "$testroot" "$ret" return 1 fi The below patch is intended to fix those. Note that I barely tested this patch: (a) verified the scripts all still pass, and (b) introduced one bug and verified the test script responded appropriately, saying "leaving test data in ..." instead of "ok" as it did before. -- James diff 2f3ccc5ff648594ff13619e304c2a139a917f2d2 0f8f0b5ce24f77c3feec3195d065d668288281d3 commit - 2f3ccc5ff648594ff13619e304c2a139a917f2d2 commit + 0f8f0b5ce24f77c3feec3195d065d668288281d3 blob - eb1ede54ba534e112737b56c1fb19c02b9d70ddb blob + 69a9a2773510acc956e60ec5b87ae8aad43b8d8c --- regress/cmdline/commit.sh +++ regress/cmdline/commit.sh @@ -321,7 +321,7 @@ test_commit_rejects_conflicted_file() { ret=$? if [ $ret -eq 0 ]; then echo "got commit succeeded unexpectedly" - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi @@ -1339,7 +1339,7 @@ test_commit_symlink() { ret=$? if [ $ret -eq 0 ]; then echo "got commit succeeded unexpectedly" >&2 - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected @@ -1417,7 +1417,7 @@ test_commit_symlink() { ret=$? if [ $ret -eq 0 ]; then echo "got commit succeeded unexpectedly" >&2 - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected blob - 79f558cff6a61109fdd1089a30e941fcf382b49d blob + bdd7571df06f3c7d45127433eabfcdc76e0e94ed --- regress/cmdline/fetch.sh +++ regress/cmdline/fetch.sh @@ -1380,7 +1380,7 @@ test_fetch_delete_remote_refs() { ret=$? if [ $ret -eq 0 ]; then echo "got fetch command succeeded unexpectedly" >&2 - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi blob - 6080151a8a3e5c278b52bd1288edfdf4aa4383fb blob + 2850c77ea9f07c4d604211acb189455b07692252 --- regress/cmdline/histedit.sh +++ regress/cmdline/histedit.sh @@ -1426,7 +1426,7 @@ test_histedit_duplicate_commit_in_script() { if [ $ret -eq 0 ]; then echo "histedit succeeded unexpectedly:" >&2 cat $testroot/stdout >&2 - test_done "$testroot" "$ret" + test_done "$testroot" 1 return 1 fi blob - a4561e55b71ef739aea26419efa37a02818e8885 blob + fea0fbd0c0b880d3f283fc17453e349290b0a480 --- regress/cmdline/integrate.sh +++ regress/cmdline/integrate.sh @@ -188,7 +188,7 @@ test_integrate_requires_rebase_first() { ret=$? if [ $ret -eq 0 ]; then echo "got integrate succeeded unexpectedly" - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi @@ -529,7 +529,7 @@ test_integrate_into_nonbranch() { ret=$? if [ $ret -eq 0 ]; then echo "got integrate succeeded unexpectedly" - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi blob - ca27e157f924c0abac516cda4f26581c04e3cc21 blob + 71e5e49a5b7f5ebee4e83f1e29b7b2352977c697 --- regress/cmdline/merge.sh +++ regress/cmdline/merge.sh @@ -88,7 +88,7 @@ test_merge_basic() { ret=$? if [ $ret -eq 0 ]; then echo "got merge succeeded unexpectedly" >&2 - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi echo -n "got: work tree must be updated before it can be used " \ @@ -123,7 +123,7 @@ test_merge_basic() { ret=$? if [ $ret -eq 0 ]; then echo "got merge succeeded unexpectedly" >&2 - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi echo -n "got: work tree contains files from multiple base commits; " \ @@ -160,7 +160,7 @@ test_merge_basic() { ret=$? if [ $ret -eq 0 ]; then echo "got merge succeeded unexpectedly" >&2 - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi echo "got: alpha: file is staged" > $testroot/stderr.expected @@ -185,7 +185,7 @@ test_merge_basic() { ret=$? if [ $ret -eq 0 ]; then echo "got merge succeeded unexpectedly" >&2 - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi echo -n "got: work tree contains local changes; " \ blob - 8c960baef8925da8232651df8d17bfdb3d9dc2cd blob + 76716f5e5237ac2f3426c566633ec858be31881e --- regress/cmdline/stage.sh +++ regress/cmdline/stage.sh @@ -2150,7 +2150,7 @@ test_stage_patch_removed_twice() { ret=$? if [ $ret -eq 0 ]; then echo "got stage command succeeded unexpectedly" >&2 - test_done "$testroot" "$ret" + test_done "$testroot" "1" return 1 fi