From 64b0b674f63738997fe35c2235b58401211e2d7e Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 18:51:30 +0000 Subject: [PATCH 01/11] ? --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf6718d..a97c94b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,3 +14,5 @@ add_compile_options(-Wimplicit-fallthrough) add_subdirectory(src/willow) add_executable(willow_test src/main.cpp) target_link_libraries(willow_test PRIVATE willow) + +install(DIRECTORY src/willow DESTINATION willow) From 1ce1707f58f2e3836d13597e8f0e2f6b7bdf65b7 Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 20:37:08 +0000 Subject: [PATCH 02/11] cmake updates --- CMakeLists.txt | 24 +++++++++++++----------- src/willow/CMakeLists.txt | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a97c94b..5516f57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,17 +2,19 @@ cmake_minimum_required(VERSION 3.30) set(CMAKE_CXX_COMPILER "/usr/bin/clang++") project(willow-test LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(CMAKE_CXX_STANDARD 23) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -add_compile_options(-g) -add_compile_options(-Wall) -add_compile_options(-Wextra) -add_compile_options(-Wconversion) -add_compile_options(-Wimplicit-fallthrough) + add_compile_options(-g) + add_compile_options(-Wall) + add_compile_options(-Wextra) + add_compile_options(-Wconversion) + add_compile_options(-Wimplicit-fallthrough) -add_subdirectory(src/willow) -add_executable(willow_test src/main.cpp) -target_link_libraries(willow_test PRIVATE willow) + add_subdirectory(src/willow) + add_executable(willow_test src/main.cpp) + target_link_libraries(willow_test PRIVATE willow) +endif() -install(DIRECTORY src/willow DESTINATION willow) +# install(DIRECTORY src/willow DESTINATION willow) diff --git a/src/willow/CMakeLists.txt b/src/willow/CMakeLists.txt index 868b0c7..245d181 100644 --- a/src/willow/CMakeLists.txt +++ b/src/willow/CMakeLists.txt @@ -3,5 +3,5 @@ add_library(willow STATIC ) target_include_directories(willow PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_SOURCE_DIR}/../.. ) From f660ca16e5ec1bdfeaa069eb709f41a87e493110 Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 20:37:54 +0000 Subject: [PATCH 03/11] enable install --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5516f57..a8adef1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,4 +17,4 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) target_link_libraries(willow_test PRIVATE willow) endif() -# install(DIRECTORY src/willow DESTINATION willow) +install(DIRECTORY src/willow DESTINATION willow) From d14327873e8f0576272809ef7595b4b11222f13d Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 20:40:56 +0000 Subject: [PATCH 04/11] move things around --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8adef1..f397950 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.30) set(CMAKE_CXX_COMPILER "/usr/bin/clang++") project(willow-test LANGUAGES CXX) +add_subdirectory(src/willow) + if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(CMAKE_CXX_STANDARD 23) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -12,9 +14,8 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) add_compile_options(-Wconversion) add_compile_options(-Wimplicit-fallthrough) - add_subdirectory(src/willow) add_executable(willow_test src/main.cpp) target_link_libraries(willow_test PRIVATE willow) endif() -install(DIRECTORY src/willow DESTINATION willow) +# install(DIRECTORY src/willow DESTINATION willow) From f7e072b5b7cb6d0ef2b9ceb12e8a1bd56c87703d Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 20:41:25 +0000 Subject: [PATCH 05/11] move things around again --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f397950..c55b3bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,4 +18,4 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) target_link_libraries(willow_test PRIVATE willow) endif() -# install(DIRECTORY src/willow DESTINATION willow) +install(DIRECTORY src/willow DESTINATION willow) From 44c6908772867889dafeaf8f80373b2398379dda Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 20:42:00 +0000 Subject: [PATCH 06/11] without if statement --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c55b3bd..b6763cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(willow-test LANGUAGES CXX) add_subdirectory(src/willow) -if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) +# if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(CMAKE_CXX_STANDARD 23) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -16,6 +16,6 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) add_executable(willow_test src/main.cpp) target_link_libraries(willow_test PRIVATE willow) -endif() +# endif() install(DIRECTORY src/willow DESTINATION willow) From f8601e83e8265f84729ed52b4c95adfb864dc463 Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 20:43:29 +0000 Subject: [PATCH 07/11] without if statement again --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6763cb..daf5fac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,4 +18,4 @@ add_subdirectory(src/willow) target_link_libraries(willow_test PRIVATE willow) # endif() -install(DIRECTORY src/willow DESTINATION willow) +# install(DIRECTORY src/willow DESTINATION willow) From 7d511689a1f4b4eeb5c47174e23de34d85ccd0c6 Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 20:44:44 +0000 Subject: [PATCH 08/11] change --- src/willow/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/willow/CMakeLists.txt b/src/willow/CMakeLists.txt index 245d181..868b0c7 100644 --- a/src/willow/CMakeLists.txt +++ b/src/willow/CMakeLists.txt @@ -3,5 +3,5 @@ add_library(willow STATIC ) target_include_directories(willow PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../.. + ${CMAKE_CURRENT_SOURCE_DIR}/.. ) From 8c9d4899d75cc2fa0519098c8ea5f71dda4a4311 Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 20:45:27 +0000 Subject: [PATCH 09/11] with the if statement --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index daf5fac..f397950 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(willow-test LANGUAGES CXX) add_subdirectory(src/willow) -# if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) +if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(CMAKE_CXX_STANDARD 23) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -16,6 +16,6 @@ add_subdirectory(src/willow) add_executable(willow_test src/main.cpp) target_link_libraries(willow_test PRIVATE willow) -# endif() +endif() # install(DIRECTORY src/willow DESTINATION willow) From ac6ca8ad241103e07ad7006291fe70f2e6ba17e8 Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 21:32:21 +0000 Subject: [PATCH 10/11] update readme --- CMakeLists.txt | 5 ++-- README.md | 53 ++++++++++++++++++++++++++++++++++++++++++ src/willow/reporters.h | 2 ++ 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f397950..722b50e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required(VERSION 3.30) -set(CMAKE_CXX_COMPILER "/usr/bin/clang++") project(willow-test LANGUAGES CXX) add_subdirectory(src/willow) if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(CMAKE_CXX_COMPILER "/usr/bin/clang++") + set(CMAKE_CXX_STANDARD 23) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -17,5 +18,3 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) add_executable(willow_test src/main.cpp) target_link_libraries(willow_test PRIVATE willow) endif() - -# install(DIRECTORY src/willow DESTINATION willow) diff --git a/README.md b/README.md index cc91cfb..255ea7b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,56 @@ # Willow A unit testing library for modern c++23 + +# How to use +Currently, willow only supports CMake for distribution, although if you know +what you're doing, feel free to clone the repo and do what you need yourself. + +```cmake +include(FetchContent) +fetchcontent_declare( + rawterm + GIT_REPOSITORY https://github.com/ttibsi/willow + GIT_TAG v0.0.1 +) +fetchcontent_makeavailable(rawterm) +``` + +# Example +A minimal usage looks like the below code. However, willow dogfoods itself, +meaning that it's tested with itself. To see more usage, see the `src/main.cpp` +file -- anything in the `src/` directory are the tests for this project, +`src/willow` is the source code. + +```cpp +#include "willow/reporters.h" +#include "willow/willow.h" + +auto add(int x, int y) -> int { return x + y; } + +// Any test must follow this signature. It's return code is used to mark if +// it succeeded or not. Alerts print on function failure +auto test_add(Willow::Test* test) -> int { + if (add(3, 2) != 5) { + Willow::alert(test, "3 + 2 does not equal 5"); + return 1; + } + + return 0; +} + +auto main() -> int { + // Select which reporter to use to display output. A number of reporters + // are available + Willow::DefaultReporter reporter = {}; + + // Your executable will exit with a return code displaying the number of + // failed tests + return Willow::runTests({ + // Each test function is given a name to display as output. you can also + // mark tests for skipping + {"addition test", test_add}, + {"skipped test", test_add, Willow::Status::Skip}, + }, reporter); +} +``` diff --git a/src/willow/reporters.h b/src/willow/reporters.h index 63f8e6b..33616d5 100644 --- a/src/willow/reporters.h +++ b/src/willow/reporters.h @@ -1,6 +1,8 @@ #ifndef WILLOW_REPORTER_H #define WILLOW_REPORTER_H +// TODO: Implement JSONReporter + #include #include "test.h" From 5406b63c1b4e4fd56c6160b89bb60da921132d30 Mon Sep 17 00:00:00 2001 From: ttibsi Date: Sun, 2 Nov 2025 21:52:13 +0000 Subject: [PATCH 11/11] IDK --- CMakeLists.txt | 26 +++++++++++--------------- README.md | 6 +++--- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 722b50e..bf6718d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,16 @@ cmake_minimum_required(VERSION 3.30) +set(CMAKE_CXX_COMPILER "/usr/bin/clang++") project(willow-test LANGUAGES CXX) -add_subdirectory(src/willow) - -if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(CMAKE_CXX_COMPILER "/usr/bin/clang++") +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - set(CMAKE_CXX_STANDARD 23) - set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +add_compile_options(-g) +add_compile_options(-Wall) +add_compile_options(-Wextra) +add_compile_options(-Wconversion) +add_compile_options(-Wimplicit-fallthrough) - add_compile_options(-g) - add_compile_options(-Wall) - add_compile_options(-Wextra) - add_compile_options(-Wconversion) - add_compile_options(-Wimplicit-fallthrough) - - add_executable(willow_test src/main.cpp) - target_link_libraries(willow_test PRIVATE willow) -endif() +add_subdirectory(src/willow) +add_executable(willow_test src/main.cpp) +target_link_libraries(willow_test PRIVATE willow) diff --git a/README.md b/README.md index 255ea7b..62caadb 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ fetchcontent_makeavailable(rawterm) ``` # Example -A minimal usage looks like the below code. However, willow dogfoods itself, +A minimal usage looks like the below code. However, willow dogfoods itself, meaning that it's tested with itself. To see more usage, see the `src/main.cpp` -file -- anything in the `src/` directory are the tests for this project, +file -- anything in the `src/` directory are the tests for this project, `src/willow` is the source code. ```cpp @@ -44,7 +44,7 @@ auto main() -> int { // are available Willow::DefaultReporter reporter = {}; - // Your executable will exit with a return code displaying the number of + // Your executable will exit with a return code displaying the number of // failed tests return Willow::runTests({ // Each test function is given a name to display as output. you can also