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

Re: [RFC PATCH 0/2] add an external testing library for unit tests

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Apr 27, 2023, 21:35 UTC
Message-ID
<ZErqvkCIkytTCvZr@tapette.crustytoothpaste.net>
In-Reply-To
<20230427175007.902278-1-calvinwan@google.com>
On 2023-04-27 at 17:50:05, Calvin Wan wrote:
Show 11 quoted lines
> 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.

I think this is a good idea. Like Junio said downthread, we need to have integration and end-to-end tests, and I think those will continue to compose the majority of our tests. However, having simple and easy to use unit tests would be really valuable for testing things like our hash and HMAC implementations, as well as a variety of other library functions, including our strbuf code.

At work, I recently ported a project from C with no unit tests to Rust with unit tests (and in both cases, our existing integration and functional testsuite) and found that writing unit tests let us have substantially more confidence in the correct functioning of our code.

I think it's great that we're using existing TAP functionality as well.

If you're looking for some proof-of-concept projects to illustrate why this is useful in v1, might I suggest some of the subsystems above? Assuming it lands, I plan on sending some tests for the percent-encoding in the strbuf code and some more aggressive testing of our block SHA-256 and HMAC implementations if nobody gets to it before me. (Mostly because this is stuff I wrote or touched and would like to have more confidence in.)

-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
Previous: Calvin WanNext: Felipe Contreras
Message 26 of 29 in “add an external testing library for unit tests”
  1. 0/2 add an external testing library for unit testsCalvin Wan, Apr 27, 2023
  2. 1/2 Add C TAP harnessCalvin Wan, Apr 27, 2023
  3. SZEDER GáborApr 27, 2023
  4. Calvin WanApr 27, 2023
  5. Phillip WoodApr 27, 2023
  6. Calvin WanApr 28, 2023
  7. Felipe ContrerasMay 2, 2023
  8. Phillip WoodMay 10, 2023
  9. Glen ChooMay 11, 2023
  10. Phillip WoodMay 18, 2023
  11. Linus ArverJun 21, 2023
  12. Phillip WoodJun 26, 2023
  13. Linus ArverJun 28, 2023
  14. Oswald BuddenhagenJun 29, 2023
  15. Phillip WoodJun 30, 2023
  16. Felipe ContrerasMay 2, 2023
  17. Ævar Arnfjörð BjarmasonMay 2, 2023
  18. Felipe ContrerasMay 2, 2023
  19. Ævar Arnfjörð BjarmasonMay 2, 2023
  20. Phillip WoodMay 10, 2023
  21. 2/2 unit test: add basic exampleCalvin Wan, Apr 27, 2023
  22. Junio C HamanoApr 27, 2023
  23. Felipe ContrerasMay 2, 2023
  24. Junio C HamanoApr 27, 2023
  25. Calvin WanApr 27, 2023
  26. brian m. carlsonApr 27, 2023
  27. Felipe ContrerasMay 2, 2023
  28. Ævar Arnfjörð BjarmasonMay 2, 2023
  29. Felipe ContrerasMay 2, 2023

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.