From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, "David Turner" <novalis@novalis.org>,
"Elijah Newren" <newren@gmail.com>,
"Matheus Tavares" <matheus.bernardino@usp.br>,
"Jeff King" <peff@peff.net>,
"Derrick Stolee" <derrickstolee@github.com>,
"Đoàn Trần Công Danh" <congdanhqx@gmail.com>
Subject: Re: test-lib.sh musings: test_expect_failure considered harmful
Date: Wed, 13 Oct 2021 12:10:43 +0200 [thread overview]
Message-ID: <87o87ti5n6.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <xmqq4k9m6vkw.fsf@gitster.g>
On Tue, Oct 12 2021, Junio C Hamano wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> On Mon, Oct 11 2021, Junio C Hamano wrote:
> [...]
>> Presumably with test_expect_failure.
>>
>> I'll change it, in this case we'd end up with a test_expect_success at
>> the end, so it doesn't matter much & I don't care.
>
> I do agree with you that compared to expect_success, which requires
> _all_ steps to succeed, so an failure in any of its steps is
> immediately noticeable, it is harder to write and keep
> expect_failure useful, because it is not like we are happy to see
> any failure in any step. We do not expect a failure in many
> preparation and conclusion steps in the &&-chain in expect_failure
> block, and we consider it is an error if these steps fail. We only
> want to mark only a single step to exhibit an expected but undesirable
> behaviour.
>
> But even with the shortcomings of expect_failure, it still is much
> better than claiming that we expect a bogus outcome.
>
> Improving the shortcomings of expect_failure would be a much better
> use of our time than advocating an abuse of expect_sucess, I would
> think.
I'd like to improve it, but I'll have to get any patch in this are past
you :)
My reading of your opinion from past exchanges is that you find it
objectionable to say "this is a success" when it's not the /desired/
behavior, whereas I think it's valuable to just test for and document
the exact existing behavior, even if it's not desirable. So you don't
really need a function different from test_expect_success, just a
comment saying "this should change", or add a ("non-hash so it's not TAP
syntax") "TODO" to the description of the test.
But if you agree that we shouldn't conflate failures in the different
steps I think we're getting somewhere, so to begin with what do you
think about the hack in the v2 of my series?
https://lore.kernel.org/git/cover-v2-0.2-00000000000-20211012T142950Z-avarab@gmail.com/
If we were to prompote those semantics to something that
test_expect_failure would use it would be the below, which I think is
the only sensible way to use it.
But that would mean changing all existing test_expect_failure uses in
the test suite, so it would need either a pretty large patch, or some
incremental steps to get there:
But it will mean we can't use it for any test that's actually flaky, so
we'll need a test_expect_flaky, or have some test-specific workarounds
in those areas.
diff --git a/t/t7815-grep-binary.sh b/t/t7815-grep-binary.sh
index 90ebb64f46e..9a95c9e7d69 100755
--- a/t/t7815-grep-binary.sh
+++ b/t/t7815-grep-binary.sh
@@ -64,7 +64,7 @@ test_expect_success 'git grep ile a' '
'
test_expect_failure 'git grep .fi a' '
- git grep .fi a
+ test_must_fail git grep .fi a
'
test_expect_success 'grep respects binary diff attribute' '
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 8361b5c1c57..6d9291b7ead 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -728,8 +728,8 @@ test_known_broken_ok_ () {
then
write_junit_xml_testcase "$* (breakage fixed)"
fi
- test_fixed=$(($test_fixed+1))
- say_color error "ok $test_count - $@ # TODO known breakage vanished"
+ test_broken=$(($test_broken+1))
+ say_color warn "not ok $test_count - $@ # TODO known breakage"
}
test_known_broken_failure_ () {
@@ -737,8 +737,8 @@ test_known_broken_failure_ () {
then
write_junit_xml_testcase "$* (known breakage)"
fi
- test_broken=$(($test_broken+1))
- say_color warn "not ok $test_count - $@ # TODO known breakage"
+ test_fixed=$(($test_fixed+1))
+ say_color error "not ok $test_count - $@ # TODO a 'known breakage' changed behavior!"
}
test_debug () {
next prev parent reply other threads:[~2021-10-13 10:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 9:23 test-lib.sh musings: test_expect_failure considered harmful Ævar Arnfjörð Bjarmason
2021-10-12 16:45 ` Junio C Hamano
2021-10-13 10:10 ` Ævar Arnfjörð Bjarmason [this message]
2021-10-13 13:05 ` Derrick Stolee
2021-10-13 17:16 ` Junio C Hamano
2021-10-14 17:11 ` Ævar Arnfjörð Bjarmason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o87ti5n6.fsf@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=congdanhqx@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=matheus.bernardino@usp.br \
--cc=newren@gmail.com \
--cc=novalis@novalis.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.