Skip to content

Add a test target and one unit test, using Check. #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 11, 2020

Conversation

schmonz
Copy link
Member

@schmonz schmonz commented Sep 10, 2019

Had a little time on the plane. Here's an extremely minimal example of a unit test. Not looking for approval yet, just feedback.

You'll need Check installed, and depending where it goes you may need to adjust conf-cc and conf-ld to find it.

Then run make test and behold, at least one use of stralloc is shown to work!

I picked stralloc because we all understand it, it's heavily used, it's relatively easy to test, and who knows, maybe with sufficient stralloc tests we'll discover something interesting we'll be glad to know about.

@schmonz schmonz force-pushed the schmonz-test-stralloc branch from 56e630d to 81a1f9d Compare September 22, 2019 19:45
@schmonz schmonz force-pushed the schmonz-test-stralloc branch 2 times, most recently from 90af82b to fb7b1e6 Compare December 29, 2019 14:34
@schmonz
Copy link
Member Author

schmonz commented Dec 29, 2019

I believe this branch is now merge-ready. It's one small test for a stralloc, one giant leap for giving us a clear way to keep adding tests.

Before building and running the tests, install Check (and pkg-config or pkgconf to find Check's includes and libs). These are dependencies for tests and only for tests.

To build and run the tests from the top-level Makefile, simply make test. Verified to work with recent BSD and GNU make.

To add more stralloc tests, copy the test_stralloc_thingy example in tests/unittest_stralloc.c. To add other tests, copy the unittest_stralloc example in tests/Makefile.

Travis and Cirrus now run make test, too.

In our too-brief meetup on Friday, @DerDakon suggested running tests via cmake to reduce build complexity, generate test reports, and possibly help in other ways. I'm open to it, but I'd love to see us first write a bunch of tests and learn what's annoying about that. :-)

The sooner we merge this, the sooner we can start adding tests with most every commit. The sooner we have existing code covered by test, the sooner we can make bolder changes. With good test coverage we can also easily get good valgrind coverage. So I'd like to see this go in ASAP, with the understanding that the way we write, run, and use the results of tests will necessarily need to be refined over time.

@schmonz schmonz force-pushed the schmonz-test-stralloc branch 2 times, most recently from fed01e0 to 97240dc Compare December 30, 2019 16:56
@schmonz schmonz requested a review from DerDakon December 31, 2019 15:22
@DerDakon
Copy link
Member

DerDakon commented May 8, 2020

@schmonz agreed that I can add another testcase I was just playing with, so I have extended this by a second commit that tests additional behavior of the stralloc functions.

@DerDakon DerDakon force-pushed the schmonz-test-stralloc branch from b23cb25 to 0609d1b Compare May 10, 2020 17:09
@schmonz
Copy link
Member Author

schmonz commented May 11, 2020

Happy with the additions, at a glance. Please feel free to merge.

@DerDakon DerDakon merged commit 8fa4b8b into master May 11, 2020
@DerDakon DerDakon deleted the schmonz-test-stralloc branch May 11, 2020 21:03
@DerDakon DerDakon added this to the 1.08 milestone May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants