You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# See original: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
5
+
6
+
name: CMake
7
+
8
+
on:
9
+
push:
10
+
branches: [ $default-branch ]
11
+
pull_request:
12
+
branches: [ $default-branch ]
13
+
14
+
jobs:
15
+
build:
16
+
runs-on: ${{ matrix.os }}
17
+
18
+
strategy:
19
+
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
20
+
fail-fast: false
21
+
22
+
# Set up a matrix to run the following 2 configurations:
23
+
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
24
+
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
25
+
#
26
+
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
27
+
matrix:
28
+
os: [ubuntu-latest]
29
+
build_type: [Release]
30
+
c_compiler: [gcc, clang]
31
+
include:
32
+
- os: ubuntu-latest
33
+
c_compiler: gcc
34
+
- os: ubuntu-latest
35
+
c_compiler: clang
36
+
37
+
steps:
38
+
- uses: actions/checkout@v4
39
+
40
+
- name: Set reusable strings
41
+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
63
+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
- A single header-file with plain C and `#define` macros.
4
4
- Plays well with CTest with a `discover_tests()` CMake function.
5
5
6
6
**mtest** is a simple, C-only unit testing framework inspired by [CuTest](https://cutest.sourceforge.net/) with some modern features inspired by [doctest](https://github.com/doctest/doctest).
7
7
8
-
For mature and feature-complete C/C++ testing frameworks, take a look at [Boost.Test](https://github.com/boostorg/test), [Catch2](https://github.com/catchorg/Catch2), [doctest](https://github.com/doctest/doctest), or [Google Test](https://github.com/google/googletest).
8
+
For more mature and feature-complete C/C++ testing frameworks, take a look at [Boost.Test](https://github.com/boostorg/test), [Catch2](https://github.com/catchorg/Catch2), [doctest](https://github.com/doctest/doctest), or [Google Test](https://github.com/google/googletest).
message(FATAL_ERROR "The git submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Did you forget to run `git submodule init` after cloning?")
108
+
else()
109
+
add_subdirectory(extern/mtest)
110
+
endif()
111
+
```
43
112
44
-
TEST_CASE(my_first_test_case, {
45
-
int i = 42;
46
-
CHECK_EQ_INT(1, i); // Test fails, but we continue running.
47
-
REQUIRE_GT_INT(i, 0); // This test is executed and succeeds, but the test case failed due to the previous line.
48
-
})
113
+
Updating mtest can be done with the `git submodule update` command, then
114
+
using git to commit the updated submodule directory.
49
115
50
-
TEST_CASE(my_other_test_case, {
51
-
double i = 3.14;
52
-
// When comparing doubles, we need to specify a tolerance - here we choose 0.01
53
-
REQUIRE_EQ_DOUBLE(4.0, i, 0.01); // Test fails and the test case exits.
54
-
CHECK_TRUE(1); // Not executed but it would succeed.
55
-
})
116
+
### Using system-installed `mtest` (Advanced)
56
117
57
-
// This macro creates a main function that can call each test case, and it tells CTest which test cases are available.
0 commit comments