From: Patrick Steinhardt <ps@pks.im>
To: "René Scharfe" <l.s.r@web.de>
Cc: Junio C Hamano <gitster@pobox.com>,
Kyle Lippincott <spectral@google.com>,
Git List <git@vger.kernel.org>,
Phillip Wood <phillip.wood@dunelm.org.uk>,
Josh Steadmon <steadmon@google.com>
Subject: Re: [PATCH v3 3/7] unit-tests: add for_test
Date: Wed, 31 Jul 2024 07:19:45 +0200 [thread overview]
Message-ID: <ZqnJcawtpzvguxtq@tanuki> (raw)
In-Reply-To: <53c1eaeb-6106-492c-9c44-13a7cd1bd0d0@web.de>
[-- Attachment #1: Type: text/plain, Size: 3804 bytes --]
On Tue, Jul 30, 2024 at 04:00:07PM +0200, René Scharfe wrote:
> Am 30.07.24 um 06:49 schrieb Patrick Steinhardt:
> > On Mon, Jul 29, 2024 at 11:55:52AM -0700, Junio C Hamano wrote:
> >> Patrick Steinhardt <ps@pks.im> writes:
> >>
> >>> is standalone nowadays and called "clar" [1]. The biggest downside of it
> >>> is that it depends on Python to auto-generate the test "main" function,
> >>> which is not really a good fit for the Git project.
> >>
> >> Is that because Python is optional (like, we only use it for
> >> optional Perforce thing and import-zip in contrib), or are there
> >> other concerns?
> >>
> >> Unlike these components, unit tests are not even for the end-user
> >> consumers, so if it is Python that you find it a blocker, I do not
> >> see a reason to reject it. The thing looked like a simple script
> >> that does not use any tricky language construct or modules.
> >
> > No concerns other than adding another mandatory dependency for devs. We
> > already depend on Perl and Shell, so adding Python to the stack feels
> > suboptimal to me.
> >
> > As you say though, the script isn't all that involved. So it would also
> > be possible to port it to Perl if we want to do that, I guess.
>
> From the point of view of a "minimal C unit testing framework" surely
> the implementation language with the best dependency story would be C.
> Perhaps it could then also test itself. On the other hand, writing a
> string handling program in 2024 in C is probably not the smartest idea.
I certainly wouldn't want to do it ;) I think Perl would be perfectly
fine given that we already rely on it rather extensively in Git.
> Then again, generate.py uses a non-greedy regex to remove single-line
> comments, which seems wrong, and doesn't seem to support preprocessor
> directives like #if and #ifdef, so whole tests can't be disabled this
> way.
I guess it doesn't have to be perfect, just good enough. clar comes with
some niceties like being able to run only some tests, all tests of a
particular suite or to exclude certain tests:
# Run only submodule::add tests.
$ ./libgit2_tests -t -ssubmodule::add::
TAP version 13
# start of suite 1: submodule::add
ok 1 - submodule::add::url_absolute
ok 2 - submodule::add::url_relative
ok 3 - submodule::add::url_relative_to_origin
ok 4 - submodule::add::url_relative_to_workdir
ok 5 - submodule::add::path_exists_in_index
ok 6 - submodule::add::file_exists_in_index
ok 7 - submodule::add::submodule_clone
ok 8 - submodule::add::submodule_clone_into_nonempty_dir_succeeds
ok 9 - submodule::add::submodule_clone_twice_fails
1..9
# Run only a single test in the submodule::add suite.
$ ./libgit2_tests -t -ssubmodule::add::url_absolute
TAP version 13
# start of suite 1: submodule::add
ok 1 - submodule::add::url_absolute
1..1
# Run all submodule tests, but exclude submodule::add.
$ ./libgit2_tests -t -ssubmodule:: -xsubmodule::add::
TAP version 13
# start of suite 1: submodule::escape
ok 1 - submodule::escape::from_gitdir
ok 2 - submodule::escape::from_gitdir_windows
# start of suite 2: submodule::init
ok 3 - submodule::init::absolute_url
...
So I'm not sure whether it's all that important to be able to recognize
things like #if and #ifdef given that you can pick tests to run on the
command line.
The alternative would be of course to hook up LLVM and properly parse
the C sources. But that feels like overthinking it ;)
> And it uses pickle to cache results; does that mean it would be
> slow without it?
Good question. I plan to find some time this week to draft a PoC and
will remember to benchmark this.
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-07-31 5:19 UTC|newest]
Thread overview: 115+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-29 15:33 [PATCH 0/6] unit-tests: add and use TEST_RUN to simplify tests René Scharfe
2024-06-29 15:35 ` [PATCH 1/6] t0080: move expected output to a file René Scharfe
2024-07-01 3:20 ` Jeff King
2024-07-01 19:17 ` Junio C Hamano
2024-07-01 22:10 ` Jeff King
2024-07-01 23:38 ` Junio C Hamano
2024-07-02 0:57 ` Jeff King
2024-07-01 19:51 ` René Scharfe
2024-07-01 22:18 ` Jeff King
2024-06-29 15:43 ` [PATCH 2/6] unit-tests: add TEST_RUN René Scharfe
2024-07-02 15:13 ` phillip.wood123
2024-07-02 15:51 ` Junio C Hamano
2024-07-02 20:55 ` René Scharfe
2024-07-02 20:55 ` René Scharfe
2024-07-05 9:42 ` phillip.wood123
2024-07-05 18:01 ` René Scharfe
2024-07-07 7:20 ` René Scharfe
2024-07-08 15:18 ` phillip.wood123
2024-07-08 15:39 ` Junio C Hamano
2024-07-11 15:34 ` Junio C Hamano
2024-07-13 13:27 ` Phillip Wood
2024-07-13 15:48 ` Junio C Hamano
2024-07-08 15:12 ` phillip.wood123
2024-06-29 15:44 ` [PATCH 3/6] t-ctype: use TEST_RUN René Scharfe
2024-07-01 19:49 ` Josh Steadmon
2024-07-01 20:04 ` René Scharfe
2024-07-02 15:14 ` phillip.wood123
2024-07-02 20:55 ` René Scharfe
2024-06-29 15:45 ` [PATCH 4/6] t-reftable-basics: " René Scharfe
2024-06-29 15:46 ` [PATCH 5/6] t-strvec: " René Scharfe
2024-07-02 15:14 ` phillip.wood123
2024-07-02 20:55 ` René Scharfe
2024-06-29 15:47 ` [PATCH 6/6] t-strbuf: " René Scharfe
2024-07-01 19:58 ` Josh Steadmon
2024-07-01 20:18 ` René Scharfe
2024-07-02 15:14 ` phillip.wood123
2024-07-02 20:55 ` René Scharfe
2024-07-04 13:09 ` phillip.wood123
2024-07-10 13:55 ` Phillip Wood
2024-07-14 11:44 ` René Scharfe
2024-07-15 14:46 ` Ghanshyam Thakkar
2024-07-02 17:29 ` Ghanshyam Thakkar
2024-07-02 20:55 ` René Scharfe
2024-07-03 3:42 ` Ghanshyam Thakkar
2024-07-08 18:11 ` Josh Steadmon
2024-07-08 21:59 ` Ghanshyam Thakkar
2024-07-01 19:59 ` [PATCH 0/6] unit-tests: add and use TEST_RUN to simplify tests Josh Steadmon
2024-07-10 22:13 ` Junio C Hamano
2024-07-11 10:05 ` Phillip Wood
2024-07-11 15:12 ` Junio C Hamano
2024-07-14 10:35 ` René Scharfe
2024-07-21 6:12 ` [PATCH v2 0/6] unit-tests: add and use for_test " René Scharfe
2024-07-21 6:15 ` [PATCH v2 1/6] t0080: move expected output to a file René Scharfe
2024-07-23 20:54 ` Jeff King
2024-07-21 6:21 ` [PATCH v2 2/6] unit-tests: add for_test René Scharfe
2024-07-22 19:13 ` Kyle Lippincott
2024-07-22 19:36 ` Junio C Hamano
2024-07-22 20:31 ` René Scharfe
2024-07-22 20:41 ` Junio C Hamano
2024-07-22 22:47 ` Kyle Lippincott
2024-07-23 12:37 ` René Scharfe
2024-07-23 6:02 ` [PATCH v2] unit-tests: show location of checks outside of tests René Scharfe
2024-07-23 13:25 ` Phillip Wood
2024-07-22 22:41 ` [PATCH v2 2/6] unit-tests: add for_test Kyle Lippincott
2024-07-23 7:18 ` René Scharfe
2024-07-23 6:36 ` Patrick Steinhardt
2024-07-23 9:25 ` René Scharfe
2024-07-23 9:53 ` Patrick Steinhardt
2024-07-23 12:37 ` René Scharfe
2024-07-23 13:00 ` Patrick Steinhardt
2024-07-23 13:23 ` Phillip Wood
2024-07-23 13:58 ` René Scharfe
2024-07-23 13:24 ` Phillip Wood
2024-07-25 9:45 ` Phillip Wood
2024-07-30 14:00 ` René Scharfe
2024-07-21 6:22 ` [PATCH v2 3/6] t-ctype: use for_test René Scharfe
2024-07-21 6:23 ` [PATCH v2 4/6] t-reftable-basics: " René Scharfe
2024-07-21 6:24 ` [PATCH v2 5/6] t-strvec: " René Scharfe
2024-07-21 6:26 ` [PATCH v2 6/6] t-strbuf: " René Scharfe
2024-07-23 13:23 ` Phillip Wood
2024-07-24 14:42 ` [PATCH v3 0/7] add and use for_test to simplify tests René Scharfe
2024-07-24 14:48 ` [PATCH v3 1/7] t0080: use here-doc test body René Scharfe
2024-07-24 14:50 ` [PATCH v3 2/7] unit-tests: show location of checks outside of tests René Scharfe
2024-07-24 14:51 ` [PATCH v3 3/7] unit-tests: add for_test René Scharfe
2024-07-24 19:24 ` Kyle Lippincott
2024-07-25 9:45 ` Phillip Wood
2024-07-25 16:02 ` Junio C Hamano
2024-07-25 21:31 ` Kyle Lippincott
2024-07-26 2:41 ` Junio C Hamano
2024-07-26 12:56 ` Patrick Steinhardt
2024-07-26 15:59 ` Junio C Hamano
2024-07-29 9:48 ` Patrick Steinhardt
2024-07-29 18:55 ` Junio C Hamano
2024-07-30 4:49 ` Patrick Steinhardt
2024-07-30 14:00 ` René Scharfe
2024-07-31 5:19 ` Patrick Steinhardt [this message]
2024-07-31 16:48 ` René Scharfe
2024-08-01 6:51 ` Patrick Steinhardt
2024-07-24 14:52 ` [PATCH v3 4/7] t-ctype: use for_test René Scharfe
2024-07-24 14:54 ` [PATCH v3 5/7] t-reftable-basics: " René Scharfe
2024-07-24 14:54 ` [PATCH v3 6/7] t-strvec: " René Scharfe
2024-07-24 14:55 ` [PATCH v3 7/7] t-strbuf: " René Scharfe
2024-07-30 14:03 ` [PATCH v4 0/6] add and use if_test to simplify tests René Scharfe
2024-07-30 14:05 ` [PATCH v4 1/6] t0080: use here-doc test body René Scharfe
2024-07-31 20:52 ` Kyle Lippincott
2024-07-30 14:07 ` [PATCH v4 2/6] unit-tests: show location of checks outside of tests René Scharfe
2024-07-31 21:03 ` Kyle Lippincott
2024-08-01 7:23 ` René Scharfe
2024-07-30 14:08 ` [PATCH v4 3/6] unit-tests: add if_test René Scharfe
2024-07-31 22:04 ` Kyle Lippincott
2024-08-01 7:32 ` René Scharfe
2024-08-02 0:48 ` Kyle Lippincott
2024-07-30 14:10 ` [PATCH v4 4/6] t-ctype: use if_test René Scharfe
2024-07-30 14:10 ` [PATCH v4 5/6] t-reftable-basics: " René Scharfe
2024-07-30 14:12 ` [PATCH v4 6/6] t-strvec: " René Scharfe
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=ZqnJcawtpzvguxtq@tanuki \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
--cc=phillip.wood@dunelm.org.uk \
--cc=spectral@google.com \
--cc=steadmon@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).