Skip to content

Commit 5b7402e

Browse files
committed
Initialization (#1)
Initialize the repo to working state, including examples, tests, cross-platform CI pipelines, documentation, and more
0 parents  commit 5b7402e

40 files changed

+2974
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.github/workflows/ci-linux.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Linux
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-and-test:
11+
name: ${{ matrix.name }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- name: "Linux GCC"
18+
compiler: gcc
19+
cmake-generator: 'Ninja'
20+
cmake-options: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++'
21+
22+
- name: "Linux Clang"
23+
compiler: clang
24+
cmake-generator: 'Ninja'
25+
cmake-options: '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++'
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
with:
31+
submodules: 'recursive'
32+
33+
- name: Install ninja-build
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y ninja-build
37+
shell: bash
38+
39+
- name: Configure CMake
40+
run: |
41+
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }} -DTESTCOE_BUILD_EXAMPLES=ON -DTESTCOE_BUILD_TESTS=ON
42+
shell: bash
43+
44+
- name: Build
45+
run: |
46+
cmake --build build --config Release
47+
shell: bash
48+
49+
- name: Run tests
50+
working-directory: build
51+
run: |
52+
./tests/testcoe_tests
53+
shell: bash

.github/workflows/ci-macos.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: macOS
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-and-test:
11+
name: ${{ matrix.name }}
12+
runs-on: macos-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- name: "macOS Clang"
18+
compiler: clang
19+
cmake-generator: 'Ninja'
20+
cmake-options: ''
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v3
25+
with:
26+
submodules: 'recursive'
27+
28+
- name: Install ninja-build
29+
run: |
30+
brew install ninja
31+
shell: bash
32+
33+
- name: Configure CMake
34+
run: |
35+
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }} -DTESTCOE_BUILD_EXAMPLES=ON -DTESTCOE_BUILD_TESTS=ON
36+
shell: bash
37+
38+
- name: Build
39+
run: |
40+
cmake --build build --config Release
41+
shell: bash
42+
43+
- name: Run tests
44+
working-directory: build/tests
45+
run: |
46+
./testcoe_tests
47+
shell: bash

.github/workflows/ci-windows.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Windows
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-and-test:
11+
name: ${{ matrix.name }}
12+
runs-on: windows-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- name: "Windows MSVC"
18+
compiler: msvc
19+
cmake-generator: 'Visual Studio 17 2022'
20+
cmake-options: ''
21+
22+
- name: "Windows MinGW"
23+
compiler: gcc
24+
cmake-generator: 'MinGW Makefiles'
25+
cmake-options: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++'
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
with:
31+
submodules: 'recursive'
32+
33+
- name: Install Windows build tools
34+
if: matrix.compiler != 'msvc'
35+
run: |
36+
choco install mingw
37+
shell: bash
38+
39+
- name: Configure CMake
40+
run: |
41+
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }} -DTESTCOE_BUILD_EXAMPLES=ON -DTESTCOE_BUILD_TESTS=ON
42+
shell: bash
43+
44+
- name: Build
45+
run: |
46+
cmake --build build --config Release
47+
shell: bash
48+
49+
- name: Run tests
50+
working-directory: build
51+
run: |
52+
if [ "${{ matrix.compiler }}" == "gcc" ]; then
53+
./tests/testcoe_tests.exe
54+
else
55+
./tests/Release/testcoe_tests.exe
56+
fi
57+
shell: bash

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
.vscode/

CMakeLists.txt

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(testcoe VERSION 0.1.0 LANGUAGES CXX)
3+
4+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
if(MSVC)
9+
# Ensure debug symbols are generated and linked
10+
add_compile_options(/Zi)
11+
add_link_options(/DEBUG)
12+
# Keep debug info in release builds too for stack traces
13+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
14+
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
15+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
16+
# Enhanced debug info for GCC/Clang
17+
add_compile_options(-g3 -fno-omit-frame-pointer)
18+
endif()
19+
20+
include(cmake/utils.cmake)
21+
22+
# googletest
23+
find_package(GTest QUIET)
24+
if(GTest_FOUND)
25+
message(STATUS "[testcoe] Using existing GoogleTest installation")
26+
ignore_external_warnings(GTest::Main)
27+
else()
28+
message(STATUS "[testcoe] GoogleTest not found, fetching from source")
29+
include(FetchContent)
30+
FetchContent_Declare(
31+
googletest
32+
GIT_REPOSITORY https://github.com/google/googletest.git
33+
GIT_TAG v1.16.0
34+
)
35+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
36+
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
37+
FetchContent_MakeAvailable(googletest)
38+
ignore_external_warnings(gtest_main)
39+
endif()
40+
41+
# backward-cpp
42+
set(BACKWARD_HAS_BFD 0 CACHE BOOL "Disable BFD support" FORCE)
43+
set(BACKWARD_HAS_DW 0 CACHE BOOL "Disable libdw support" FORCE)
44+
set(BACKWARD_HAS_DWARF 0 CACHE BOOL "Disable libdwarf support" FORCE)
45+
set(BACKWARD_HAS_UNWIND 0 CACHE BOOL "Disable libunwind support" FORCE)
46+
set(STACK_WALKING_UNWIND TRUE CACHE BOOL "Use unwind for stack walking" FORCE)
47+
set(STACK_DETAILS_AUTO_DETECT FALSE CACHE BOOL "Auto detect backward details" FORCE)
48+
set(STACK_DETAILS_BACKTRACE_SYMBOL TRUE CACHE BOOL "Use backtrace symbols" FORCE)
49+
50+
# Windows-specific enhancements for better stack traces
51+
if(WIN32)
52+
set(BACKWARD_HAS_DBGHELP 1 CACHE BOOL "Enable Windows DbgHelp for better stack traces" FORCE)
53+
endif()
54+
55+
find_package(Backward QUIET)
56+
if(Backward_FOUND)
57+
message(STATUS "[testcoe] Using existing Backward-cpp installation")
58+
ignore_external_warnings(Backward::Backward)
59+
else()
60+
message(STATUS "[testcoe] Backward-cpp not found, fetching from source")
61+
include(FetchContent)
62+
FetchContent_Declare(
63+
backward
64+
GIT_REPOSITORY https://github.com/bombela/backward-cpp
65+
GIT_TAG v1.6
66+
)
67+
FetchContent_MakeAvailable(backward)
68+
ignore_external_warnings(backward)
69+
endif()
70+
71+
# testcoe
72+
add_subdirectory(include)
73+
add_subdirectory(src)
74+
75+
option(TESTCOE_BUILD_EXAMPLES "Build the examples" OFF)
76+
option(TESTCOE_BUILD_TESTS "Build the tests" OFF)
77+
78+
if(TESTCOE_BUILD_EXAMPLES)
79+
add_subdirectory(examples)
80+
81+
if(TESTCOE_BUILD_TESTS)
82+
add_subdirectory(tests)
83+
endif()
84+
endif()
85+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Nir Cohen Hershkovitz
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# testcoe
2+
3+
Visual test progress and crash handling for Google Test.
4+
5+
[![Windows](https://github.com/nircoe/testcoe/actions/workflows/ci-windows.yml/badge.svg)](https://github.com/nircoe/testcoe/actions/workflows/ci-windows.yml)
6+
[![Linux](https://github.com/nircoe/testcoe/actions/workflows/ci-linux.yml/badge.svg)](https://github.com/nircoe/testcoe/actions/workflows/ci-linux.yml)
7+
[![macOS](https://github.com/nircoe/testcoe/actions/workflows/ci-macos.yml/badge.svg)](https://github.com/nircoe/testcoe/actions/workflows/ci-macos.yml)
8+
9+
## What is testcoe?
10+
11+
testcoe enhances Google Test with real-time grid visualization and crash reporting:
12+
13+
```
14+
Running 12 tests... Completed: 8/12 (P: 6, F: 2)
15+
P - Passed, F - Failed, R - Running, . - Not run yet
16+
17+
MathTests PPF.. (3/5)
18+
StringTests PRPP. (4/5)
19+
VectorTests .... (0/2)
20+
```
21+
22+
When tests crash, you get detailed stack traces instead of silent failures.
23+
24+
## Dependencies
25+
- [**Google Test**](https://github.com/google/googletest) (v1.16.0) - Test framework
26+
- [**backward-cpp**](https://github.com/bombela/backward-cpp) (v1.6) - Stack trace generation
27+
28+
## Quick Start
29+
30+
### 1. Add to your project (CMake)
31+
32+
```cmake
33+
include(FetchContent)
34+
FetchContent_Declare(
35+
testcoe
36+
GIT_REPOSITORY https://github.com/nircoe/testcoe.git
37+
GIT_TAG v0.1.0
38+
)
39+
FetchContent_MakeAvailable(testcoe)
40+
41+
target_link_libraries(your_test_executable PRIVATE testcoe)
42+
```
43+
44+
### 2. Use in your tests
45+
46+
```cpp
47+
#include <testcoe.hpp>
48+
49+
int main(int argc, char** argv) {
50+
testcoe::init(&argc, argv);
51+
return testcoe::run();
52+
}
53+
```
54+
55+
That's it! Run your tests and see the enhanced output.
56+
57+
## Features
58+
59+
- 🎯 **Grid Visualization** - See all tests progress in real-time
60+
- 🛡️ **Crash Handling** - Get stack traces when tests crash
61+
- 🎨 **Color Support** - Automatic terminal detection
62+
- 🔍 **Test Filtering** - Run specific tests or suites
63+
- 📦 **Zero Config** - Works out of the box with Google Test
64+
65+
## Examples
66+
67+
See the [examples/](examples/) directory for demonstrations:
68+
- [Basic usage](examples/basic/) - Grid visualization
69+
- [Crash handling](examples/crash/) - Stack traces on crashes
70+
- [Test filtering](examples/filter/) - Running specific tests
71+
72+
## Requirements
73+
74+
- C++17 or later
75+
- CMake 3.14+
76+
- Google Test (automatically included)
77+
78+
## API Reference
79+
80+
```cpp
81+
// Initialize testcoe
82+
testcoe::init(&argc, argv);
83+
84+
// Run all tests
85+
testcoe::run();
86+
87+
// Run specific suite
88+
testcoe::run_suite("MathTests");
89+
90+
// Run specific test
91+
testcoe::run_test("MathTests", "Addition");
92+
```
93+
94+
## Documentation
95+
96+
- [Architecture](docs/ARCHITECTURE.md) - How testcoe works internally
97+
- [Contributing](docs/CONTRIBUTING.md) - Development setup and guidelines
98+
- [Roadmap](docs/ROADMAP.md) - Version history and future plans
99+
100+
## License
101+
102+
MIT License - see [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)