git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] add an external testing library for unit tests
@ 2023-04-27 17:50 Calvin Wan
  2023-04-27 17:50 ` [RFC PATCH 1/2] Add C TAP harness Calvin Wan
                   ` (5 more replies)
  0 siblings, 6 replies; 29+ messages in thread
From: Calvin Wan @ 2023-04-27 17:50 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan

In our current testing environment, we spend a significant amount of
effort crafting end-to-end tests for error conditions that could easily
be captured by unit tests (or we simply forgo some hard-to-setup and
rare error conditions). Unit tests additionally provide stability to the
codebase and can simplify debugging through isolation. Turning parts of
Git into libraries[1] gives us the ability to run unit tests on the
libraries and to write unit tests in C. Writing unit tests in pure C,
rather than with our current shell/test-tool helper setup, simplifies
test setup, simplifies passing data around (no shell-isms required), and
reduces testing runtime by not spawning a separate process for every
test invocation.

Unit testing in C requires a separate testing harness that we ideally
would like to be TAP-style and to come with a non-restrictive license.
Fortunately, there already exists a C TAP harness library[2] with an MIT
license (at least for the files included in this series). 

This first patch introduces the C TAP harness and includes only the
necessary files. The second patch showcases a basic example of it. As an
RFC, I am wondering what the list thinks about using a second testing
library for unit testing? Are there any problems with this particular
external testing library and does it provide the necessary functionality
we would want for unit testing Git libraries? How should the folders be
structured and how should the new Makefile rules be written? Ultimately,
this will help us determine the setup of our unit tests in future
libification patches.

[1] https://lore.kernel.org/git/CAJoAoZ=Cig_kLocxKGax31sU7Xe4==BGzC__Bg2_pr7krNq6MA@mail.gmail.com/
[2] https://github.com/rra/c-tap-harness/ 

Calvin Wan (2):
  Add C TAP harness
  unit test: add basic example

 Makefile       |   11 +
 t/TESTS        |    1 +
 t/runtests.c   | 1789 ++++++++++++++++++++++++++++++++++++++++++++++++
 t/tap/basic.c  | 1029 ++++++++++++++++++++++++++++
 t/tap/basic.h  |  198 ++++++
 t/tap/macros.h |  109 +++
 t/unit-test.c  |   14 +
 7 files changed, 3151 insertions(+)
 create mode 100644 t/TESTS
 create mode 100644 t/runtests.c
 create mode 100644 t/tap/basic.c
 create mode 100644 t/tap/basic.h
 create mode 100644 t/tap/macros.h
 create mode 100644 t/unit-test.c

-- 
2.40.1.495.gc816e09b53d-goog


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2023-06-30  9:49 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 17:50 [RFC PATCH 0/2] add an external testing library for unit tests Calvin Wan
2023-04-27 17:50 ` [RFC PATCH 1/2] Add C TAP harness Calvin Wan
2023-04-27 18:29   ` SZEDER Gábor
2023-04-27 18:38     ` Calvin Wan
2023-04-27 20:15   ` Phillip Wood
2023-04-28 16:31     ` Calvin Wan
2023-05-02 15:46       ` Felipe Contreras
2023-05-10 15:46       ` Phillip Wood
2023-05-11 23:16         ` Glen Choo
2023-05-18 10:04           ` Phillip Wood
2023-06-21 15:57         ` Linus Arver
2023-06-26 13:15           ` Phillip Wood
2023-06-28 21:17             ` Linus Arver
2023-06-29  5:52             ` Oswald Buddenhagen
2023-06-30  9:48               ` Phillip Wood
2023-05-02 15:54     ` Felipe Contreras
2023-05-02 16:39       ` Ævar Arnfjörð Bjarmason
2023-05-02 18:11         ` Felipe Contreras
2023-05-02 16:34     ` Ævar Arnfjörð Bjarmason
2023-05-10  8:18       ` Phillip Wood
2023-04-27 17:50 ` [RFC PATCH 2/2] unit test: add basic example Calvin Wan
2023-04-27 18:47   ` Junio C Hamano
2023-05-02 15:58     ` Felipe Contreras
2023-04-27 18:39 ` [RFC PATCH 0/2] add an external testing library for unit tests Junio C Hamano
2023-04-27 18:46   ` Calvin Wan
2023-04-27 21:35 ` brian m. carlson
2023-05-02  4:18 ` Felipe Contreras
2023-05-02 13:52 ` Ævar Arnfjörð Bjarmason
2023-05-02 15:28   ` Felipe Contreras

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).