RFC Add an external testing library for unit tests
Get series with b4
b4 am [email protected] change-id 20230517-unit-tests-v2-94f50a7ccd8aVersions newest first
- v2 RFC Latest4 patches 11 repliesIn review
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | common-main: split common_exit() into a new fileMakefile common-exit.c common-main.c | +27 | 4 replies | |
| 2/4 | unit tests: Add a project plan documentDocumentation/ Documentation/ | +48 | 4 replies | |
| 3/4 | Add C TAP harnesst/ t/ t/ +1 more | +3125 | 2 replies | |
| 4/4 | unit test: add basic example and build rules.gitignore Makefile t/ +3 more | +91 | 1 reply |
Reviews trailers per patch
None of the 4 patches has a Reviewed-by or Acked-by.
| Patch | Calvin Wan |
|---|---|
| Series | Coauthored-by |
| 1/4 | |
| 2/4 | |
| 3/4 | |
| 4/4 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH RFC v2 0/4] Add an external testing library for unit tests
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). Phillip Wood has also proposed an alternative implementation[3]. I have not had a chance to review that patch in much detail, but I have hopefully made the Makefile integration here somewhat pluggable so that we can easily switch to his version if it proves superior. For now, I have continued with the C TAP library.
The first patch is a small cleanup to allow linking common_exit() separately from common-main.o. In the second patch, I've added a rough draft project plan listing some goals. Patch 3 adds the C TAP libraries. Patch 4 is a modified version of Calvin's previous implemenation with better integration to our Makefiles.
[1] https://lore.kernel.org/git/CAJoAoZ=Cig_kLocxKGax31sU7Xe4==BGzC__Bg2_pr7krNq6MA@mail.gmail.com/
[2] https://github.com/rra/c-tap-harness/
[3]: https://lore.kernel.org/git/[email protected]/
---
Calvin Wan (1):
Add C TAP harness
Josh Steadmon (3):
common-main: split common_exit() into a new file unit tests: Add a project plan document unit test: add basic example and build rules
.gitignore | 2 + Documentation/Makefile | 1 + Documentation/technical/unit-tests.txt | 47 + Makefile | 25 +- common-exit.c | 26 + common-main.c | 24 - t/Makefile | 10 + t/runtests.c | 1789 ++++++++++++++++++++++++++++++++ t/strbuf-test.c | 54 + t/tap/basic.c | 1029 ++++++++++++++++++ t/tap/basic.h | 198 ++++ t/tap/macros.h | 109 ++ 12 files changed, 3289 insertions(+), 25 deletions(-)
---
base-commit: 69c786637d7a7fe3b2b8f7d989af095f5f49c3a8
change-id: 20230517-unit-tests-v2-94f50a7ccd8a
Best regards,
Signature · 1 line
Josh Steadmon <[email protected]>