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

Setup binary and unit tests with GTest framework #13

Closed
7 tasks done
Tracked by #10
doodspav opened this issue Mar 13, 2023 · 0 comments · Fixed by #14
Closed
7 tasks done
Tracked by #10

Setup binary and unit tests with GTest framework #13

doodspav opened this issue Mar 13, 2023 · 0 comments · Fixed by #14
Assignees
Labels
user story User story

Comments

@doodspav
Copy link
Owner

doodspav commented Mar 13, 2023

Description

  • Create test folder with binary and unit tests (and any other tests) using GTest framework

Acceptance Criteria

  • Running ctest . runs all tests that were built
  • Tests can only be built as part of the library if the library as built as a top level project, unless overriden with option
  • The user of the test shall provide GTest, the test shall only look for it using find_package
  • The tests must be able to be built separately to the library, and link with the library using find_package
  • It shall be possible to only build certain test types (binary or unit test)
  • It shall be possible to only build certain suites from a test type
  • It shall be possible to install tests, but they will be excluded from all
@doodspav doodspav self-assigned this Mar 13, 2023
@doodspav doodspav added the user story User story label Mar 13, 2023
doodspav added a commit that referenced this issue Mar 15, 2023
doodspav added a commit that referenced this issue Mar 18, 2023
doodspav added a commit that referenced this issue Mar 18, 2023
doodspav added a commit that referenced this issue Mar 18, 2023
Signed-off-by: doodspav <[email protected]>
@doodspav doodspav linked a pull request Mar 18, 2023 that will close this issue
doodspav added a commit that referenced this issue Mar 18, 2023
doodspav added a commit that referenced this issue Mar 18, 2023
doodspav added a commit that referenced this issue Mar 19, 2023
doodspav added a commit that referenced this issue Mar 21, 2023
- windows dependency file is generated per test kind, rather than once for all tests
- all windows stuff is shifted either into test kind CMake file, or into create_test
- create_test now accepts LINK parameters
- create_test now uses the "name" parameter as the created target name

Signed-off-by: doodspav <[email protected]>
doodspav added a commit that referenced this issue Mar 21, 2023
- also tests should have unique suite.name or CTest will skip "duplicates"

Signed-off-by: doodspav <[email protected]>
doodspav added a commit that referenced this issue Mar 21, 2023
doodspav added a commit that referenced this issue Mar 21, 2023
create_test(BT example SOURCE example.cpp):
- target created -> patomic_bt_example
- executable created -> example(.exe)
- executable installed as -> <prefix>/patomic/bt/example(.exe)

Signed-off-by: doodspav <[email protected]>
doodspav added a commit that referenced this issue Mar 21, 2023
- only creates test targets that match the regex obtained from this option
- the target name must match the regex; it is not tested against:
  - executable name
  - name passed to create_test
  - test suite/case name (this can be limited at runtime with gtest_filter)
- look at create_test docs to see what target name is chosen

Signed-off-by: doodspav <[email protected]>
doodspav added a commit that referenced this issue Mar 21, 2023
- also remove redundant example_add.cpp file

Signed-off-by: doodspav <[email protected]>
doodspav added a commit that referenced this issue Mar 21, 2023
- when skipping creation of test due to not matching regex
- when skipping creation of deps_path file due to no tests existing

Signed-off-by: doodspav <[email protected]>
doodspav added a commit that referenced this issue Mar 22, 2023
…rriden

- if BUILD_TESTING=OFF and patomic_BUILD_TESTING=ON, tests are built but not registered with CTest
- need to call enable_testing() to get CTest to behave as expected

Signed-off-by: doodspav <[email protected]>
doodspav added a commit that referenced this issue Mar 22, 2023
- disabled by default
- determines whether windows_dependencies_path.txt is generated for tests or not

Signed-off-by: doodspav <[email protected]>
doodspav added a commit that referenced this issue Mar 23, 2023
doodspav added a commit that referenced this issue Mar 24, 2023
## Scope

- create core test files (`test`)
- setup CMake to build and install tests
- each test has its own target as well as targets for test kind, and target for all tests
- each test kind group is its own component and can be installed per component
- all tests can also be installed together
- path is automatically set for tests run with ctest on windows (unless disabled via option)
- file containing path for test dependencies can be created on windows if option is enabled
- tests can be built as a completely independent project
- user can choose which tests to build using regex option

---------

Signed-off-by: doodspav <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user story User story
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant