Skip to content
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

Wire up support for selftests #102

Merged
merged 10 commits into from
Oct 21, 2024
Merged

Wire up support for selftests #102

merged 10 commits into from
Oct 21, 2024

Commits on Oct 21, 2024

  1. cmake: drop unused BUILD_TESTS option

    We explicitly declare a `BUILD_TESTS` option. This option is unused as
    we use `BUILD_TESTING` instead, which is what the CTest module brings
    with it.
    
    Drop the `BUILD_TESTS` option.
    pks-t committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    b4832fa View commit details
    Browse the repository at this point in the history
  2. clar: allow overriding current file, line and function

    When raising an error we print the current file, line and function where
    the error was raised. This is of course quite helpful to users, but it
    stands in the way of testing the clar because they make the output of
    executables dependent on the developer's setup.
    
    Add the ability to override these with fixed constants via a new
    `CLAR_SELFTEST` macro.
    pks-t committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    759d092 View commit details
    Browse the repository at this point in the history
  3. clar: fix platform-specific use of error codes

    We use `exit(-1)` in two places. Exit codes should be in the range of
    [0, 255] though, so the resulting behaviour is not defined and depends
    on the platform. Fix this by using `exit(1)` instead.
    pks-t committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    671f47e View commit details
    Browse the repository at this point in the history
  4. clar: fix platform-specific behaviour of "%p"

    The "%p" formatter has platform-specific behaviour. On Windows for
    example it prints as a zero-padded integer, whereas on glibc systems it
    prints as non-zero-padded integer with "0x" prepended.
    
    Address this by instead using PRIxPTR and casting the pointers to the
    `uintptr_t` type.
    pks-t committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    6341120 View commit details
    Browse the repository at this point in the history
  5. test: split out examples into their own directory

    The examples are closely coupled with our selftests, which makes it hard
    to iterate on both. Split them out into their own standalone directory
    as a prerequisite for wiring up proper testing of the clar.
    pks-t committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    2392c8a View commit details
    Browse the repository at this point in the history
  6. test: move tests into subdirectory

    We are about to wire up proper testing of clar via CI. This will be done
    by executing the "clar_test" binary we already have in another clar test
    binary. This requires us to move the current "clar_test" into its own
    subdirectory such that "generate.py" can then generate the "clar.suite"
    for each of these two test binaries independently.
    pks-t committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    48bb9c8 View commit details
    Browse the repository at this point in the history
  7. test: drop global test counter

    The global test counter has been added as a demonstration for how it is
    possible to modify global resources. Now that we have moved examples
    into their own directory though it no longer serves that purpose.
    
    In fact, it now stands in our way as we are about to introduce testing
    of the clar itself with various different options. But as we assert that
    the counter is "8" after all tests have ran, we wouldn't be able to
    exclude some tests from running.
    
    Drop the counter altogether to prepare for the change.
    pks-t committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    7019cdd View commit details
    Browse the repository at this point in the history
  8. test: deterministic pointers

    The output for the test that exercise `cl_assert_equal_p()` is
    indeterministic because we compare on-stack addresses, which naturally
    change between executions. Adapt the test to instead use fixed values.
    pks-t committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    28eb749 View commit details
    Browse the repository at this point in the history
  9. test: exercise the clar itself

    While we have had the "clar_test" binary for a very long time already,
    it was more for demonstration purposes than for real testing of the
    clar. It could serve as sort of a smoke test if the developer remembered
    to execute it, but that's about it.
    
    In the preceding commits we have moved the "clar_test" into a separate
    directory, renamed it to "selftest_suite" and made its output
    deterministic. We can thus now wire up proper testing of the clar by
    exercising the "selftest_suite" binary via a new "selftest" binary.
    These tests run the "selftest_test" binary with various different
    arguments and check both its return code as well as its output.
    pks-t committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    724698a View commit details
    Browse the repository at this point in the history
  10. ci: wire up support for testing

    Wire up support for testing in our CI now that we have proper self
    tests.
    pks-t committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    f68801e View commit details
    Browse the repository at this point in the history