Message ID | 20210817081458.53136-2-mirucam@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Finish converting git bisect to C part 4 | expand |
On 17/08/21 15.14, Miriam Rubio wrote: > +test_expect_success 'bisect run fails with exit code equals or greater than 128' ' > + write_script test_script.sh <<-\EOF && > + exit 128 >/dev/null > + EOF > + test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt > +' This only checks for exit code equals to 128. You should also check for exit code greater than 128, for example 255. > + > +test_expect_success 'bisect run fails with exit code smaller than 0' ' > + write_script test_script.sh <<-\EOF && > + exit -1 >/dev/null > + EOF > + test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt > +' This test looks OK, using -1 as representative of negative exit code. However, wording of test name can also be 'bisect run fails with negative exit code'. Thanks for reviewing.
On Tue, Aug 17, 2021 at 11:03 AM Bagas Sanjaya <bagasdotme@gmail.com> wrote: > > On 17/08/21 15.14, Miriam Rubio wrote: > > > +test_expect_success 'bisect run fails with exit code equals or greater than 128' ' > > + write_script test_script.sh <<-\EOF && > > + exit 128 >/dev/null > > + EOF > > + test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt > > +' > > This only checks for exit code equals to 128. You should also check for > exit code greater than 128, for example 255. > > > + > > +test_expect_success 'bisect run fails with exit code smaller than 0' ' > > + write_script test_script.sh <<-\EOF && > > + exit -1 >/dev/null > > + EOF > > + test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt > > +' > > This test looks OK, using -1 as representative of negative exit code. > However, wording of test name can also be 'bisect run fails with > negative exit code'. Actually I am not sure that it makes sense to test an exit code smaller than 0, as POSIX exit codes are between 0 and 255 (included). For example: $ bash -c 'exit -1'; echo $? 255 $ dash -c 'exit -1'; echo $? dash: 1: exit: Illegal number: -1 2
Hi, El mar, 17 ago 2021 a las 11:23, Christian Couder (<christian.couder@gmail.com>) escribió: > > On Tue, Aug 17, 2021 at 11:03 AM Bagas Sanjaya <bagasdotme@gmail.com> wrote: > > > > On 17/08/21 15.14, Miriam Rubio wrote: > > > > > +test_expect_success 'bisect run fails with exit code equals or greater than 128' ' > > > + write_script test_script.sh <<-\EOF && > > > + exit 128 >/dev/null > > > + EOF > > > + test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt > > > +' > > > > This only checks for exit code equals to 128. You should also check for > > exit code greater than 128, for example 255. > > Noted. Thank you for reviewing, Bagas. > > > + > > > +test_expect_success 'bisect run fails with exit code smaller than 0' ' > > > + write_script test_script.sh <<-\EOF && > > > + exit -1 >/dev/null > > > + EOF > > > + test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt > > > +' > > > > This test looks OK, using -1 as representative of negative exit code. > > However, wording of test name can also be 'bisect run fails with > > negative exit code'. > > Actually I am not sure that it makes sense to test an exit code > smaller than 0, as POSIX exit codes are between 0 and 255 (included). > > For example: > > $ bash -c 'exit -1'; echo $? > 255 > > $ dash -c 'exit -1'; echo $? > dash: 1: exit: Illegal number: -1 > 2 Ok, I will remove this test. No problem. Thanks, Christian.
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index a1baf4e451..f41453cc97 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -962,4 +962,18 @@ test_expect_success 'bisect handles annotated tags' ' grep "$bad is the first bad commit" output ' +test_expect_success 'bisect run fails with exit code equals or greater than 128' ' + write_script test_script.sh <<-\EOF && + exit 128 >/dev/null + EOF + test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt +' + +test_expect_success 'bisect run fails with exit code smaller than 0' ' + write_script test_script.sh <<-\EOF && + exit -1 >/dev/null + EOF + test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt +' + test_done
There is a gap on bisect run test coverage related with error exits. Add two tests to control these error cases. Signed-off-by: Miriam Rubio <mirucam@gmail.com> --- t/t6030-bisect-porcelain.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+)