Repository navigation
Add GoogleTest unit tests and CI - #21
Merged
Merged
Conversation
The tests can then link against the same code as the client. Also adds the BUILD_TESTS option and turns off libxml2's own tests.
Arch is the target platform (AUR); the Ubuntu job stays as a stable baseline. Outdated runs on the same branch are cancelled, except on main.
The v1.2 tag still points to a release that targets the deprecated Node.js 20.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds unit tests with GoogleTest (including GMock) and a GitHub Actions CI that builds the project and runs the tests on every push to any branch and on every pull request, on Arch Linux and Ubuntu.
There is only one example test (
tests/backend/html_parser_test.cpp), to show the conventions. Real tests come in later PRs.How
email_client_corelibrary: all sources exceptsrc/main.cppare now built into a static library. Bothemail_clientand the test binary link against it, so the tests use the same code as the client. The dependencies are linkedPUBLIC, so the tests get their headers and libraries too.BUILD_TESTSoption, off by default: a normal build (and the AUR package) does not download GoogleTest. GoogleTest is built statically, even though the project setsBUILD_SHARED_LIBS ON.email_client_tests), with tests registered in CTest throughgtest_discover_tests, so everyTESTshows up as a separate ctest test.LIBXML2_WITH_TESTS). They were registered in CTest but never built, soctestreported them as failed. The commands runctest --test-dir build/tests, so build directories created before this change still work.archandubuntu.archruns in thearchlinux:latestcontainer. Arch is the target platform (the client is packaged for the AUR), and it gets the newest GCC, ICU, GnuTLS and ncurses first.ubuntustays as a stable baseline. Arch is a rolling release, so ifarchfails andubuntupasses, an Arch update is the likely cause rather than our code.main, where every commit is tested.Requiring CI before merging
The workflow itself cannot block merging. After this PR is merged, a repository admin needs to add a branch protection rule for
main(Settings → Branches) that requires thearchandubuntustatus checks to pass.Conventions
They are also written down in the README under "Tests":
src/: tests forsrc/backend/html_parser.cppgo intests/backend/html_parser_test.cpp, and each new file is added totests/CMakeLists.txt.Test. Test name: what the code should do, as a sentence.EXPECT_*by default,ASSERT_*only when the rest of the test makes no sense after a failure.