Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2e8ba3c
Migrate from std::string parameter to const char* due to ambiguity
toroidal-code Apr 2, 2025
5959b6a
Add source_location support
toroidal-code Apr 2, 2025
ddb9c57
Refactor around verb
toroidal-code Apr 2, 2025
1dc36f6
WIP JUnitXML output support
toroidal-code Apr 3, 2025
221d140
Remove LLVM specific versions
toroidal-code Apr 3, 2025
3c1e629
upgrade Clang
toroidal-code Apr 3, 2025
1c9807f
Default to failure in JUnit status if status is unknown
toroidal-code Apr 3, 2025
ba4612a
Use smart pointers in child list
toroidal-code Apr 4, 2025
3576e0b
Fix TAP and Verbose formatters and be_within_spec test
toroidal-code Apr 4, 2025
0d71c9c
Configure with CC/CXX on non-native builds
toroidal-code Apr 4, 2025
f9294d7
Fix cmake configure on windows
toroidal-code Apr 4, 2025
9fe7e32
Clang only on linux
toroidal-code Apr 4, 2025
e9be230
Simplify configure
toroidal-code Apr 4, 2025
5714b20
Add junit output support
toroidal-code Apr 4, 2025
0a69271
Cleanup and output JUnit
toroidal-code Apr 4, 2025
b825374
Separate artefacts per-strategy
toroidal-code Apr 4, 2025
2d5b43d
Fix warnings in junit_xml
toroidal-code Apr 4, 2025
584dceb
remove comma from testcase xml output
toroidal-code Apr 4, 2025
f1a4a50
encode strings for xml use
toroidal-code Apr 4, 2025
a3f78d5
output on failure
toroidal-code Apr 4, 2025
9ba4655
Upgrade argparse
toroidal-code Apr 4, 2025
7430221
set major version to 1.0
toroidal-code Apr 4, 2025
e6f172e
Add runtime exception handling, formatter improvements
toroidal-code Apr 5, 2025
a126ead
Fix be_within_spec
toroidal-code Apr 5, 2025
510c3c8
Truly optional CMake function
toroidal-code Apr 5, 2025
37eff63
spec results in folders
toroidal-code Apr 5, 2025
54dace9
Add macOS testing to CI
toroidal-code Apr 6, 2025
a248bd4
Remove non macOS compatible things
toroidal-code Apr 6, 2025
f662234
use __APPLE__ preprocessor macro
toroidal-code Apr 6, 2025
0bd43ee
Further tune test matrix
toroidal-code Apr 6, 2025
aca7b2a
Add Windows ClangCL
toroidal-code Apr 6, 2025
4416e65
reorder be_within members
toroidal-code Apr 6, 2025
6103762
Add doxygen action
toroidal-code Apr 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BasedOnStyle: Google
BasedOnStyle: Chromium
ColumnLimit: 120
5 changes: 2 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ Checks: >
-readability-identifier-length,
-readability-magic-numbers
WarningsAsErrors: false # should be true once we get there
#HeaderFileExtensions: ['h','hh','hpp','hxx'] # enable iff clang-tidy v17+
#ImplementationFileExtensions: ['c','cc','cpp','cxx'] # enable iff clang-tidy v17+ (stops from touching .S assembly files)
HeaderFileExtensions: ['h','hh','hpp','hxx'] # enable iff clang-tidy v17+
ImplementationFileExtensions: ['c','cc','cpp','cxx'] # enable iff clang-tidy v17+ (stops from touching .S assembly files)
HeaderFilterRegex: ".*"
AnalyzeTemporaryDtors: false
ExtraArgs: ['-Wno-unknown-argument', '-Wno-unknown-warning-option', '-W']
FormatStyle: file
CheckOptions:
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Generate Doxygen Documentation

on:
push:
branches:
- main
workflow_dispatch:

jobs:
generate-docs:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4

- name: Install CMake
uses: lukka/get-cmake@latest

- name: Install doxygen
uses: ssciwr/doxygen-install@v1

- name: Install graphviz
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y graphviz

- name: Run configure
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCPPSPEC_BUILD_DOCS=ON

# Generate Doxygen documentation
- name: Generate Doxygen documentation
run: cmake --build build --target doxygen

# Deploy to gh-pages branch
- name: Deploy to gh-pages branch
run: |
# Configure Git
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

# Create or switch to gh-pages branch
git fetch origin gh-pages || true
git checkout gh-pages || git checkout --orphan gh-pages

# Remove old files and copy new documentation
git rm -rf doxygen || true
mv build/html doxygen

# Commit and push changes
git add .
git commit -m "Update Doxygen documentation"
git push origin gh-pages --force
115 changes: 77 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,87 @@ on:
- main

jobs:
build:
build-and-test:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
compiler: [native, llvm]
os: [ubuntu-latest, macos-latest, windows-latest]
compiler: [native, llvm-18, gcc-14]
os: [ubuntu-latest, windows-latest, macos-13, macos-15]
exclude:
- os: macos-latest
compiler: native
- os: windows-latest
compiler: gcc-14
- os: macos-13
compiler: native # AppleClang is too old

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install CMake
uses: lukka/get-cmake@latest

- name: Install Clang
run: |
brew install llvm@18
brew link --force --overwrite llvm@18
echo "CC=$(brew --prefix llvm@18)/bin/clang" >> $GITHUB_ENV
echo "CXX=$(brew --prefix llvm@18)/bin/clang++" >> $GITHUB_ENV
if: ${{ matrix.compiler == 'llvm-18' && (matrix.os == 'macos-13' || matrix.os == 'macos-15') }}

- name: Use LLVM and Clang
run: |
echo "CC=clang-18" >> $GITHUB_ENV
echo "CXX=clang++-18" >> $GITHUB_ENV
if: ${{ matrix.compiler == 'llvm-18' && (matrix.os != 'macos-13' && matrix.os != 'macos-15') }}

- name: Use GCC
run: |
echo "CC=gcc-14" >> $GITHUB_ENV
echo "CXX=g++-14" >> $GITHUB_ENV
if: ${{ matrix.compiler == 'gcc-14' }}

- name: Configure
run: cmake -B build -DCPPSPEC_BUILD_TESTS=YES
if: ${{ matrix.compiler != 'llvm-18' || matrix.os != 'windows-latest' }}

- name: Configure ClangCL
run: cmake -B build -DCPPSPEC_BUILD_TESTS=YES -G "Visual Studio 17 2022" -T ClangCL
if: ${{ matrix.compiler == 'llvm-18' && matrix.os == 'windows-latest' }}

- name: Build
run: cmake --build build --config Release

- name: Test
run: ctest --test-dir build --build-config Release --output-on-failure

- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: Test Results (${{ matrix.os }} - ${{ matrix.compiler }})
path: build/spec/results/*.xml

publish-test-results:
name: "Publish Tests Results"
needs: build-and-test
runs-on: ubuntu-latest
permissions:
checks: write

# only needed unless run with comment_mode: off
pull-requests: write

if: always()

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install CMake
uses: lukka/get-cmake@latest

- name: Install LLVM and Clang 17
uses: KyleMayes/install-llvm-action@v1
with:
version: "17"
env: true
if: ${{ matrix.compiler == 'llvm' && matrix.os != 'macos-latest' }}

- name: Install LLVM and Clang 15
uses: KyleMayes/install-llvm-action@v1
with:
version: "15.0.7"
env: true
if: ${{ matrix.compiler == 'llvm' && matrix.os == 'macos-latest' }}

- name: Configure for native compiler
run: cmake -B build -DCPPSPEC_BUILD_TESTS=YES
if: ${{ matrix.compiler == 'native'}}

- name: Configure for non-native compiler
run: cmake -B build -G Ninja -DCPPSPEC_BUILD_TESTS=YES -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX"
if: ${{ matrix.compiler != 'native'}}

- name: Build
run: cmake --build build --config Release

- name: Test
run: ctest --test-dir build --build-config Release
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "artifacts/**/*.xml"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
build*
.cache
.vscode
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/rhysd/actionlint
rev: v1.7.7
hooks:
- id: actionlint
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.0
hooks:
- id: clang-format
types_or: [c, c++]
44 changes: 33 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.27 FATAL_ERROR)

project(c++spec)
project(c++spec
VERSION 1.0.0
DESCRIPTION "BDD testing for C++"
LANGUAGES CXX
)

set(CMAKE_COLOR_DIAGNOSTICS ON)

Expand All @@ -10,7 +14,7 @@ include(FetchContent)

FetchContent_Declare(argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse/
GIT_TAG v3.1
GIT_TAG v3.2
GIT_SHALLOW 1
)
FetchContent_MakeAvailable(argparse)
Expand All @@ -35,7 +39,10 @@ target_link_libraries(c++spec INTERFACE
cxx-prettyprint
argparse
)
target_compile_options(c++spec INTERFACE -Wno-missing-template-arg-list-after-template-kw -Wno-dollar-in-identifier-extension)

if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(c++spec INTERFACE -Wno-missing-template-arg-list-after-template-kw -Wno-dollar-in-identifier-extension)
endif()

FILE(GLOB_RECURSE c++spec_headers ${CMAKE_CURRENT_LIST_DIR}/include/*.hpp)

Expand All @@ -49,26 +56,39 @@ endif()
# HELPERS

# Add spec
function(add_spec source_file)
function(add_spec source_file args)
cmake_path(GET source_file STEM spec_name)
add_executable(${spec_name} ${source_file})
target_link_libraries(${spec_name} c++spec)

target_compile_features(${spec_name} PRIVATE cxx_std_23)
set_target_properties(${spec_name} PROPERTIES
CXX_STANDARD 23
CXX_STANDARD_REQUIRED YES
)
add_test(NAME ${spec_name} COMMAND ${spec_name} --verbose)
add_test(NAME ${spec_name} COMMAND ${spec_name} --verbose ${args})
endfunction(add_spec)

# Discover Specs
function(discover_specs spec_folder)
file(GLOB_RECURSE specs ${spec_folder}/*_spec.cpp)
file(GLOB_RECURSE specs RELATIVE ${spec_folder} ${spec_folder}/*_spec.cpp)

if (${ARGC} GREATER 1)
set(output_junit ${ARGV1})
else()
set(output_junit FALSE)
endif()

foreach(spec IN LISTS specs)
add_spec(${spec})
cmake_path(GET spec STEM spec_name)
cmake_path(GET spec PARENT_PATH spec_folder)

if (${output_junit})
add_spec(${spec} "--output-junit;${CMAKE_CURRENT_BINARY_DIR}/results/${spec_folder}/${spec_name}.xml")
else()
add_spec(${spec} "")
endif()
endforeach()
endfunction(discover_specs)
endfunction()

# OPTIONS
option(CPPSPEC_BUILD_TESTS "Build C++Spec tests")
Expand All @@ -77,6 +97,7 @@ option(CPPSPEC_BUILD_DOCS "Build C++Spec documentation")

if(CPPSPEC_BUILD_TESTS)
enable_testing()
include(CTest)

# Tests
add_subdirectory(spec)
Expand All @@ -100,8 +121,9 @@ if(CPPSPEC_BUILD_DOCS)
endif()

FetchContent_Declare(doxygen-awesome-css
URL https://github.com/jothepro/doxygen-awesome-css/archive/refs/tags/v2.2.1.tar.gz
URL_HASH MD5=340d3a206794ac01a91791c2a513991f
GIT_REPOSITORY https://github.com/jothepro/doxygen-awesome-css/
GIT_TAG v2.3.4
GIT_SHALLOW 1
)
FetchContent_MakeAvailable(doxygen-awesome-css)

Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# C++Spec
# C++Spec
[![license](https://img.shields.io/badge/license-MIT-blue)](https://choosealicense.com/licenses/mit/)
[![GitHub Action](https://github.com/toroidal-code/cppspec/actions/workflows/test.yml/badge.svg)]() 
[![GitHub release](https://img.shields.io/github/release/toroidal-code/cppspec.svg)](https://github.com/toroidal-code/cppspec/releases/latest) 
Expand All @@ -12,9 +12,13 @@ See [http://cppspec.readthedocs.org/](http://cppspec.readthedocs.org/) for full

## Requirements

C++Spec requires a compiler and standard library with support for C++20.
C++Spec requires a compiler and standard library with support for C++23: Currently tested and confirmed working are:
- LLVM/Clang 18 (on Linux, macOS, and Windows)
- GCC 14.2 (on Linux and macOS)
- MSVC 19.43 (on Windows)
- AppleClang 16 (on macOS)

__Note:__ Only the tests require being compiled with C++20 support (`-std=c++20`). No other part of an existing project's build must be modified.
__Note:__ Only the tests require being compiled with C++23 support (`-std=c++23`). No other part of an existing project's build must be modified.

## Usage
The recommended usage is as a subproject integrated into your build system. For CMake this would look something like below:
Expand Down
7 changes: 6 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
add_compile_options(-Wall -Wextra -Wpedantic)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

add_subdirectory(sample)
#add_subdirectory(skip)
Expand Down
Loading
Loading