|
1 | 1 | # Bootstrap for C++ coding kata |
2 | 2 |
|
3 | 3 | [](https://github.com/Coding-Cuddles/bootstrap-cpp-kata/actions/workflows/main.yml) |
| 4 | +[](https://en.cppreference.com/w/cpp/17) |
| 5 | +[](LICENSE) |
4 | 6 |
|
5 | | -## Overview |
6 | | - |
7 | | -This is a bootstrap repository for clean code katas in C++17 using GoogleTest. |
| 7 | +Start a C++17 coding kata with GoogleTest. Setup is complete when the starter |
| 8 | +test passes. |
8 | 9 |
|
9 | 10 | ## Prerequisites |
10 | 11 |
|
11 | | -- A compatible C++ compiler that supports at least C++17 |
12 | | -- [CMake](https://cmake.org) |
13 | | -- [GoogleTest](https://github.com/google/googletest) |
| 12 | +Required: |
| 13 | + |
| 14 | +- [Git](https://git-scm.com/downloads) |
| 15 | +- A compiler with C++17 support. Choose one: |
| 16 | + - [GCC](https://gcc.gnu.org/) 10+ on Linux |
| 17 | + - [LLVM Clang](https://llvm.org/) 14+ on Linux |
| 18 | + - [Apple Clang](https://developer.apple.com/xcode/) 17+ on macOS |
| 19 | + - [MSVC](https://visualstudio.microsoft.com/) 2022 on Windows |
| 20 | +- [CMake 3.24 or later](https://cmake.org) |
| 21 | + |
| 22 | +Optional: |
| 23 | + |
| 24 | +- [GNU Make](https://www.gnu.org/software/make/), for shorter commands. Every |
| 25 | + required task also has direct CMake and CTest commands. |
| 26 | + |
| 27 | +You do not need to install GoogleTest separately. CMake finds an installed |
| 28 | +copy or downloads the pinned release when needed. |
| 29 | + |
| 30 | +## Set up the kata |
| 31 | + |
| 32 | +1. Clone the repository: |
| 33 | + |
| 34 | + ```console |
| 35 | + git clone https://github.com/Coding-Cuddles/bootstrap-cpp-kata.git |
| 36 | + ``` |
| 37 | + |
| 38 | +2. Enter the repository directory: |
| 39 | + |
| 40 | + ```console |
| 41 | + cd bootstrap-cpp-kata |
| 42 | + ``` |
| 43 | + |
| 44 | +3. Run the starter test. Use Make when it is installed: |
| 45 | + |
| 46 | + ```console |
| 47 | + make test |
| 48 | + ``` |
| 49 | + |
| 50 | + Otherwise, use CMake and CTest directly: |
| 51 | + |
| 52 | + ```console |
| 53 | + cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug |
| 54 | + cmake --build build --config Debug |
| 55 | + ctest --test-dir build --build-config Debug --output-on-failure |
| 56 | + ``` |
| 57 | + |
| 58 | +The first run may download and build GoogleTest. Setup is complete when CTest reports |
| 59 | +`100% tests passed`. |
| 60 | + |
| 61 | +If a command reports a missing compiler or CMake, install that prerequisite |
| 62 | +and run the setup commands again. |
| 63 | + |
| 64 | +## Work on the kata |
| 65 | + |
| 66 | +1. Replace the starter assertions in `test_something.cpp` with the first kata test. |
| 67 | + |
| 68 | +2. Run the tests after each change. Use Make when it is installed: |
| 69 | + |
| 70 | + ```console |
| 71 | + make test |
| 72 | + ``` |
| 73 | + |
| 74 | + Otherwise, use CMake and CTest directly: |
14 | 75 |
|
15 | | -## Usage |
| 76 | + ```console |
| 77 | + cmake --build build --config Debug |
| 78 | + ctest --test-dir build --build-config Debug --output-on-failure |
| 79 | + ``` |
16 | 80 |
|
17 | | -### Build |
| 81 | + Continue when CTest reports `100% tests passed`. |
18 | 82 |
|
19 | | -```console |
20 | | -make build |
21 | | -``` |
| 83 | +## Make command reference |
22 | 84 |
|
23 | | -### Run tests |
| 85 | +Make is optional. Run `make` or `make help` to list these commands in the |
| 86 | +terminal. |
24 | 87 |
|
25 | | -```console |
26 | | -make test |
27 | | -``` |
| 88 | +| Command | Result | |
| 89 | +| ------------------- | ----------------------------------------- | |
| 90 | +| `make all` | Build and run the test suite | |
| 91 | +| `make build` | Configure and build without running tests | |
| 92 | +| `make test` | Build and run the test suite | |
| 93 | +| `make format` | Format tracked C++ and header files | |
| 94 | +| `make format-check` | Check formatting without changing files | |
| 95 | +| `make clean` | Remove generated build artifacts | |
0 commit comments