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

Revise testing system to make it easier to add new tests #50

Merged
merged 6 commits into from
Aug 28, 2024

Conversation

BrendanKKrueger
Copy link
Collaborator

@BrendanKKrueger BrendanKKrueger commented Aug 28, 2024

PR Summary

In #48 I did a very hacky job of adding new tests, and @Yurlungur rightly pointed out that it's not ideal. There could be a variety of ways to handle this, but I stole shamelessly from Singe to propose a new way to handle new unit test files. Now new files should only need to be added to the target_sources command at the end of test/CMakeLists.txt.

PR Checklist

  • Any changes to code are appropriately documented.
  • Code is formatted.
  • Install test passes.
  • Docs build.
  • If preparing for a new release, update the version in cmake.

Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @BrendanKKrueger this is a needed improvement!

test/test_main.cpp Outdated Show resolved Hide resolved

target_link_libraries(test_portsofcall
add_executable(test_main test_main.cpp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer if the test executable was still named test_portsofcall

Suggested change
add_executable(test_main test_main.cpp)
add_executable(test_portsofcall test_main.cpp)

though maybe this suggests the test_portsofcall.cpp file should be called something like test_portability.cpp or something


target_link_libraries(test_portsofcall
add_executable(test_main test_main.cpp)
target_link_libraries(test_main
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
target_link_libraries(test_main
target_link_libraries(test_portsofcall

PRIVATE
ports-of-call::ports-of-call
portsofcall_iface
)

include(Catch)
catch_discover_tests(test_portsofcall)
catch_discover_tests(test_main)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
catch_discover_tests(test_main)
catch_discover_tests(test_portsofcall)


target_sources(test_main PRIVATE test_portsofcall.cpp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
target_sources(test_main PRIVATE test_portsofcall.cpp)
target_sources(test_portsofcall PRIVATE test_portsofcall.cpp)

@Yurlungur
Copy link
Collaborator

Feel free to push back on my suggestions here. I'm happy to merge as is.

@Yurlungur
Copy link
Collaborator

I migrated us to catch2 v3 and added a fetch content line to the cmake so we can get catch even if it's not available via find_package. I think we're good to go here.

@Yurlungur Yurlungur merged commit b22d992 into main Aug 28, 2024
3 checks passed
@Yurlungur Yurlungur deleted the bkk_testing branch August 28, 2024 23:34
@Yurlungur Yurlungur added the Build Relevant for the build system label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Relevant for the build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants