git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/7] test-lib: add a "test_expect_todo", similar to "test_expect_failure"

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 19, 2022, 07:12 UTC
Message-ID
<xmqqilsa76ve.fsf@gitster.g>
In-Reply-To
<220319.86v8waetae.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 53 quoted lines
>> emit certain output.  We may assert the ideal future world like so:
>>
>> 	test_expect_success 'make sure foo works the way we want' '
>> 		preparatory step &&
>> 		test_must_fail git foo --bad-option >error &&
>> 		grep "expected error message" error &&
>> 		! grep "unwanted error message" error &&
>> 		git foo >output &&
>> 		grep expected output &&
>> 		! grep unwanted output
>> 	'
>>
>> Let's also imagine that right now, option parsing in "git foo",
>> works but the main execution of the command does not work.
>>
>> With test_expect_todo, you have to write something like this
>> to document the current breakage:
>>
>> 	test_expect_todo 'document breakage' '
>> 		preparatory step &&
>> 		test_must_fail git foo --bad-option >error &&
>> 		grep "expected error message" error &&
>> 		! grep "unwanted error message" error &&
>> 		test_must_fail git foo >output &&
>> 		! grep expected output &&
>> 		grep unwanted output
>> 	'
>>
>> You can see that this makes one thing unclear.
>>
>> Among the two test_must_fail and two !, which one(s) document the
>> breakage?  In other words, which one of these four negations do we
>> wish to lift eventually?  The answer is the latter two (we said that
>> handling of "--bad-option" is already working), but it is not obvious
>> in the above test_expect_todo test sequence.
>>
>> I'd suggest we allow our test to be written this way:
>>
>> 	test_expect_success 'make sure foo works the way we want' '
>> 		preparatory step &&
>> 		test_must_fail git foo --bad-option >error &&
>> 		grep "expected error message" error &&
>> 		! grep "unwanted error message" error &&
>> 	test_ki git foo >output &&
>> 	test_ki grep expected output &&
>> 	test_ki ! grep unwanted output
>> 	'
>>
>> and teach test_expect_success that an invocation of test_ki ("known
>> issue"---a better name that is NOT test_must_fail very much welcome)
>> means we hope this test someday passes without test_ki but not
>> today, i.e. what your test_expect_todo means, and we unfortunately
>> have to expect that the lines annotated with test_ki would "fail".
> Have you had the time to look past patch 1/7 of this series? 2/7
> introduces a "test_todo" helper, the "test_expect_todo" is just the
> basic top-level primitive.

No, and I do not have to. I care about the most basic form first, and if you cannot get it right, it is not interesting. You can consider the test_ki above as the primitive form of your "test_todo" that says "I want the command to give true, but I know it currently gives false".

And quite honestly, I am not interested in _how_ it currently happens to break. We may want the command being tested to eventually count three commits, but due to a bug, it may only count one. You may say "test_todo count --want 3 --expect 1 blah", but the "expect" part is much less interesting than the fact that the command being tested on _that_ line (not the whole sequence run with test_expect_failure) is clearly documented to want 3 but currently is broken, and it can be clearly distinguished from the normal test_must_fail or ! that documents that we do want a failure out of the command being tested there.

So with or without the "higher level" wrappers, how else, other than the way I showed in the message you are responding to as a rewrite of the example to use test_expect_todo, that uses two test_must_fail and two ! and makes which ones are expected failure and which ones are documentation of the current breakage, do you propose to write the equivalent? It may be that your test_todo may be a different way to spell the test_ki marker I showed above, and if that is the case it is perfectly fine, but I want it to be THE primitive, not test_must_fail or !, to mark a single command in the test that currently does not work as expected.

Show 11 quoted lines
> I don't think we can categorically replace all of the
> "test_expect_failure" cases, because in some of those it's too much of a
> hassle to assert the exact current behavior, or we don't really care.
>
> But I think for most cases instead of a:
>
> 	test_ki ! grep unwanted output
>
> It makes more sense to do (as that helper does):
>
> 	test_todo grep --want yay --expect unwanted -- output

My take is the complete opposite. We can and should start small, and how exactly the current implementation happens to be broken does not matter most of the time.

Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 6 of 18 in “test-lib-functions: a better "test_expect_failure"”
  1. 0/7 test-lib-functions: a better "test_expect_failure"Ævar Arnfjörð Bjarmason, Mar 18, 2022
  2. 1/7 test-lib: add a "test_expect_todo", similar to "test_expect_failure"Ævar Arnfjörð Bjarmason, Mar 18, 2022
  3. Junio C HamanoMar 18, 2022
  4. Junio C HamanoMar 18, 2022
  5. Ævar Arnfjörð BjarmasonMar 18, 2022
  6. Junio C HamanoMar 19, 2022
  7. Ævar Arnfjörð BjarmasonMar 19, 2022
  8. Phillip WoodMar 20, 2022
  9. Junio C HamanoMar 20, 2022
  10. Derrick StoleeMar 22, 2022
  11. Junio C HamanoMar 23, 2022
  12. Phillip WoodMar 24, 2022
  13. 2/7 test-lib-functions: add and use a "test_todo" helperÆvar Arnfjörð Bjarmason, Mar 18, 2022
  14. 3/7 tests: allow test_* in "test_must_fail_acceptable" for "test_todo"Ævar Arnfjörð Bjarmason, Mar 18, 2022
  15. 4/7 test-lib-functions: add and use a "todo_test_cmp" helperÆvar Arnfjörð Bjarmason, Mar 18, 2022
  16. 6/7 test-lib-functions: make test_todo support a --resetÆvar Arnfjörð Bjarmason, Mar 18, 2022
  17. 5/7 test-lib-functions: add and use a "todo_test_path" helperÆvar Arnfjörð Bjarmason, Mar 18, 2022
  18. 7/7 sparse tests: convert a TODO test to use "test_expect_todo"Ævar Arnfjörð Bjarmason, Mar 18, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.