Skip to content

Commit f7a180e

Browse files
authored
Update Boost UTF lecture and exercise (#215)
* Update timetable * Update lecture slides and demo notes * Update exercise sheet * Update demo notes BOOST UTF in preCICE * Add note on running tests in parallel * Fix linter
1 parent 6b8eb12 commit f7a180e

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

05_testing_and_ci/boost_testing_exercise.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Boost.Test and CTest in Action: SideMade Exercise
22

3-
In this exercise, you extend and automate the unit tests of the [SideMade code](https://github.com/Simulation-Software-Engineering/testing-boost-exercise-wt2223), on which we worked during the lecture.
3+
In this exercise, you extend and automate the unit tests of the [SideMade code](https://github.com/Simulation-Software-Engineering/testing-boost-exercise-wt2425), on which we worked during the lecture.
44

5-
Deadline: **Thursday, February 9th, 2023, 09:00**
5+
Deadline: **Thursday, February 5, 2025, 09:00**
66

77
## Preparation and Submission
88

9-
10-
- Import the [testing boost exercise repository](https://github.com/Simulation-Software-Engineering/testing-boost-exercise-wt2223) in your own account/namespace on GitHub and name it `testing-boost-exercise` again. **Note**: We cannot work with forks here because GitHub Actions may not work in pull requests without explicit approval of the owner of the target repository
9+
- Import the [testing boost exercise repository](https://github.com/Simulation-Software-Engineering/testing-boost-exercise-wt2425) in your own account/namespace on GitHub and name it `testing-boost-exercise` again. **Note**: We cannot work with forks here because GitHub Actions may not work in pull requests without explicit approval of the owner of the target repository
1110
- Create a new branch `extend-tests` from `main` and work in this branch.
1211
- To submit, open a PR from `extend-tests` to `main` in your own repository. Then paste a link to this PR in a new issue in the original repository. Use `[GITLAB-USERNAME] Boost test exercise` as title of the issue.
1312

@@ -25,12 +24,13 @@ Deadline: **Thursday, February 9th, 2023, 09:00**
2524
- Test: Check whether all tests run successfully.
2625
- Add a corresponding [GitHub workflow status badge](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/adding-a-workflow-status-badge) to the `README.md`.
2726

28-
## Optional Task
27+
## Optional Tasks
2928

3029
- Extend the automation with a [build matrix](https://docs.github.com/en/actions/using-jobs/using-a-build-matrix-for-your-jobs). Test whether your code builds in Debug and in Release mode, and with the gcc and the clang compiler. Make use of CMake variables to modify these parameters.
30+
- Implement more tests.
3131

3232
## Hints and Remarks
3333

3434
- When importing a project on GitHub, it could be that by default actions are disabled. You can enable them via `Settings -> Actions -> General -> Allow all actions`.
3535
- Be careful: the style job should not format the code, but rather report whether the code was formatted correctly or not. There are different ways how to do this. You could use the option `--dry-run`, but then you still need to interpret warnings as errors with `-Werror`. Or you could format inplace (`-i`) and use `git diff`.
36-
- Try to use the build from the build job for the tests in the test job by uploading and downloading the build as an artifact. Problem is that this way file permissions are not preserved. You can work around this problem, by archiving. See [the official workaround](https://github.com/actions/upload-artifact#maintaining-file-permissions-and-case-sensitive-files).
36+
- Try to use the build from the build job for the tests in the test job by uploading and downloading the build as an artifact. Previously, there was an issue with file permissions, where archiving was [a known workaround](https://github.com/actions/upload-artifact/tree/v3.2.1?tab=readme-ov-file#maintaining-file-permissions-and-case-sensitive-files). This should no longer be a problem.

05_testing_and_ci/boost_testing_intro_slides.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ slideOptions:
5252
- Powerful unit test framework
5353
- Sometimes called (the) **Unit Test Framework** (UTF) or **Boost.Test**
5454
- Valid on all slides: `namespace utf = boost::unit_test;`
55-
- [List of contributors and maintainers](https://www.boost.org/doc/libs/1_81_0/libs/test/doc/html/boost_test/acknowledgements.html)
55+
- [List of contributors and maintainers](https://www.boost.org/doc/libs/1_87_0/libs/test/doc/html/boost_test/acknowledgements.html)
5656

5757
---
5858

@@ -190,4 +190,4 @@ Which behavior do you then expect and why?
190190

191191
## Further Reading
192192

193-
- [Documentation of Boost Unit Test Framework](https://www.boost.org/doc/libs/1_78_0/libs/test/doc/html/index.html)
193+
- [Documentation of Boost Unit Test Framework](https://www.boost.org/doc/libs/1_87_0/libs/test/doc/html/index.html)

05_testing_and_ci/boost_testing_precice_demo.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ Look around preCICE in the terminal + text editor.
1010
- Imports `testing/Testing.hpp`, there we handle UTF imports
1111
- Test suite for `math` namespace and test suite per file (here `math/differences.hpp`)
1212
- `BOOST_CHECK` actually not recommended to use. Is used internally by `BOOST_TEST`.
13-
- Powerful macro `PRECICE_TEST(1_rank)`; here it means that this test is run on one MPI rank
14-
- Tests are normally run on 4 MPI ranks to test parallel implementation and to mimic different coupled solvers
13+
- Powerful macro `PRECICE_TEST()` to setup test context (resources, singletons, not data)
1514

1615
## Unit vs. Integration Tests
1716

1817
- Clear separation in preCICE: integration tests only directly use API of preCICE.
1918
- They are located in `tests` folder.
20-
- Look at `tests/serial/initialize-data/Explicit.cpp`
21-
- Explain `PRECICE_TEST` and how it is used
19+
- Look at `tests/serial/initialize-data/Explicit.cpp`:
20+
- Explain `PRECICE_TEST_SETUP` and how it is used: test is run on two MPI ranks living in seperate MPI communicators.
21+
- Information can be accessed via `context`.
2222
- More information: [blog post on bssw.io on multiphysics testing](https://bssw.io/blog_posts/overcoming-complexity-in-testing-multiphysics-coupling-software)
2323

2424
## White-Box Testing
@@ -34,18 +34,22 @@ Look around preCICE in the terminal + text editor.
3434
- Has public and private members. We want to check the private members in tests.
3535
- Does not `friend` every test, but only `WaveformFixture`
3636
- `src/testing/WaveformFixture.hpp` has functions to access private members
37-
- This fixture is used in many tests in `src/time/tests/WaveformTests`
37+
- This fixture is used in many tests in `src/time/tests/WaveformTests` (but not handed over to test like normal UTF fixtures)
3838

3939
## Test Matrices
4040

4141
- Look at `tests/serial/mapping-nearest-projection/QuadMappingDiagonalNearestProjectionEdgesTallKite.cpp`:
4242
- Define test matrix with data sets: `boost::unit_test::data::make`
4343

44-
## Test Context
44+
## Boost Test Context
4545

4646
- Look at `src/mapping/tests/NearestProjectionMappingTest.cpp`:
4747
- `BOOST_TEST_CONTEXT` outputs context information on failure
4848

4949
## CMake
5050

51-
- Look at `cmake/CTestConfig.cmake`: More things tested than only UTF
51+
- Look at `cmake/CTestConfig.cmake`: Complicated, but more things tested than only UTF (search for `add_test`)
52+
53+
## CTest in Parallel
54+
55+
- Build preCICE and run tests via `ctest -j 16`, runs tests in parallel, automatic feature of CTest

05_testing_and_ci/boost_testing_sidemade_demo.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ Repository: [testing boost exercise – demo-start branch](https://github.com/Si
4646
find_package(Boost 1.71 REQUIRED unit_test_framework)
4747
file(GLOB_RECURSE TEST_FILES CONFIGURE_DEPENDS tests/*.cpp)
4848
add_executable(testsidemade "${TEST_FILES}")
49+
set_property(target testsidemade PROPERTY CXX_STANDARD 11)
4950
target_link_libraries(testsidemade PRIVATE Boost::unit_test_framework)
5051
add_test(NAME "MatrixSolverTests" COMMAND ${CMAKE_CURRENT_BINARY_DIR}/testsidemade)
5152
```
5253
54+
- `add_test` can work with anything that returns an exit code. Does not have to be a fancy testing framework.
55+
5356
- Reconfigure CMake, build, run via ...
5457
- `./testsidemade`
5558
- `./testsidemade --list_content`

timetable.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@
132132

133133
## 13.2 – Wed, January 29, 2025
134134

135-
- **15** min.: Lecture evaluation
136-
- **75** min.: [Boost.Test and CTest in Action: SideMade Exercise](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/05_testing_and_ci/boost_testing_exercise.md)
135+
- **90** min.: [Boost.Test and CTest in Action: SideMade Exercise](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/05_testing_and_ci/boost_testing_exercise.md)
137136

138137
## 14.1 – Wed, February 5, 2025
139138

0 commit comments

Comments
 (0)