Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance reporting #12

Merged
merged 68 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d02d1c9
feat: add Fwd.hpp
DNKpp May 2, 2024
e58e9b4
feat: make Reporter compile time exchangable
DNKpp May 2, 2024
c36d268
refactor: matcher description
DNKpp May 2, 2024
bf80476
fix: add missing exception include
DNKpp May 2, 2024
3e1aa30
fix: remove several constexpr from functions
DNKpp May 2, 2024
32d2a6b
refactor: divide matches into matches and describe functions
DNKpp May 3, 2024
1707696
refactor: simplify BasicExpectation::matches
DNKpp May 3, 2024
5062cea
feat: unreachable helper function
DNKpp May 3, 2024
d45287a
feat: call_report
DNKpp May 4, 2024
92b5f5d
refactor: overhaul handle_call
DNKpp May 4, 2024
4db7c9b
refactor: completely overhaul match reporting
DNKpp May 4, 2024
2084edf
fix: strengthen install_reporter
DNKpp May 4, 2024
09e872c
refactor: rename several report types to upper case
DNKpp May 4, 2024
26d303b
cleanup: remove derived_cast function
DNKpp May 4, 2024
9f0b1f3
refactor: revisit some std includes
DNKpp May 4, 2024
5b734be
test: add test for severl reports
DNKpp May 4, 2024
90ff268
fix: explicitly utility unreachable() in noreturn functions
DNKpp May 4, 2024
a14125c
refactor: use report types in reporting functions
DNKpp May 4, 2024
a201391
test: add reporting tests
DNKpp May 4, 2024
826458b
test: add cases for evalue_match_report
DNKpp May 4, 2024
52ad4c7
feat: add expectation_policies::Times and expectation_policies::Runti…
DNKpp May 4, 2024
a2ef6b1
feat: add describe_state to expectation_policies::Sequence
DNKpp May 4, 2024
af171fa
feat: collect times policies status text during handle_call
DNKpp May 4, 2024
af01cba
mark unreachable() as excluded from coverage
DNKpp May 4, 2024
ab98df4
surround unreachable() with coverage exclusion markers
DNKpp May 4, 2024
01829fa
feat: let DefaultReporter throw instead of direct terminate
DNKpp May 4, 2024
b5d10e7
fix: several test cases, which actually reports unsatisfied expectations
DNKpp May 4, 2024
5dda2a3
fix: apply code formatting on Reporter files
DNKpp May 4, 2024
aebbc8d
exclude unreachable branch from coverage report
DNKpp May 4, 2024
aa4b973
refactor: improve ValueCategory and Constness formatters
DNKpp May 5, 2024
eb6f9a7
docs: add Reporter.hpp documentation
DNKpp May 6, 2024
2919351
remove non-returning calls from coverage report
DNKpp May 6, 2024
e2186ad
fix: mark evaluate_match_report as noexcept
DNKpp May 6, 2024
0e9e08e
feat: stringify_match_report
DNKpp May 6, 2024
a90f5ea
env: disable CppClangTidyHicppExceptionBaseclass check
DNKpp May 6, 2024
5ed65c2
feat: stringify_call_report
DNKpp May 6, 2024
ab3005f
fix: make type name regex more relaxed
DNKpp May 6, 2024
49fe664
feat: add Expectation::report function
DNKpp May 6, 2024
9952e51
feat: stringify_expectation_report
DNKpp May 6, 2024
4f18fad
fix: please clang
DNKpp May 6, 2024
a717c6c
test: add BasicExpectation::report test case
DNKpp May 6, 2024
a44583b
test: extend BasicExpectation::report test case
DNKpp May 6, 2024
892f111
env: move unit tests into unit-tests subfolder
DNKpp May 6, 2024
c6bb2cb
feat: matchers return their description as std::optional<StringT>
DNKpp May 6, 2024
2cddd8e
revisit: slightly adjust stringify_match_report
DNKpp May 6, 2024
143b548
feat: add detail::ReporterInstaller
DNKpp May 6, 2024
d0c1eab
revisit: WildcardMatcher::describe return std::nullopt
DNKpp May 6, 2024
a1e184c
fix: make ScopedExpectation DTor and ExpectationCollection::remove no…
DNKpp May 6, 2024
d8bad10
fix: correct times stringification
DNKpp May 6, 2024
e0cf374
feat: Catch2 adapter
DNKpp May 6, 2024
a362d49
fix: add missing atomic include
DNKpp May 6, 2024
5c075b5
fix: please clang
DNKpp May 6, 2024
dee99b3
refactor: extract executable target setup into SetupTestTarget.cmake
DNKpp May 6, 2024
e133bd0
fix: utilize setup_test_target for adapter-test/catch2
DNKpp May 6, 2024
ee35642
deps: upgrade catch2 to version 3.6.0
DNKpp May 6, 2024
4f7d809
fix: correctly use CATCH_CONFIG_PREFIX_MESSAGES
DNKpp May 6, 2024
ed27395
fix: correctly apply MIMICPP_FORCED_CXX_STANDARD
DNKpp May 6, 2024
c3dabff
ci: correct flag setup
DNKpp May 7, 2024
283f7e4
ci: fix previous attempt
DNKpp May 7, 2024
0057f02
ci: exclude unreachable() function from coverage
DNKpp May 7, 2024
45e572f
env: remove explicit msvc flags
DNKpp May 7, 2024
d14073b
refactor: simplify detail::describe_times_state
DNKpp May 7, 2024
c5d9de0
docs: add catcch2 adapter docs
DNKpp May 7, 2024
a45ed58
feat: ScopedExpectation captures std::source_location
DNKpp May 7, 2024
411eaec
feat: add print overload for std::source_location
DNKpp May 7, 2024
9556fe8
feat: ExpectationReport and MatchReport contain source location
DNKpp May 7, 2024
219ef13
docs: tweak reporter documentation
DNKpp May 7, 2024
26168e6
fix: make test more robust
DNKpp May 7, 2024
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
15 changes: 10 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ jobs:
if: ${{ matrix.config.compiler_name == 'clang' && matrix.config.libcxx == true }}
shell: bash
run: |
echo "CXX_FLAGS=$(echo $CXX_FLAGS -stdlib=libc++)" >> $GITHUB_ENV
echo "LINK_FLAGS=$(echo $LINK_FLAGS -lc++abi)" >> $GITHUB_ENV
echo "CXXFLAGS=$(echo $CXXFLAGS -stdlib=libc++)" >> $GITHUB_ENV
echo "LDFLAGS=$(echo $LDFLAGS -lc++abi)" >> $GITHUB_ENV

- name: Setup linux
if: ${{ matrix.config.prefix == 'Linux' }}
Expand Down Expand Up @@ -170,9 +170,8 @@ jobs:
-S . \
-B build \
-D CMAKE_VERBOSE_MAKEFILE=yes \
-D CMAKE_CXX_FLAGS:STRING="${{ env.CXX_FLAGS }}" \
-D CMAKE_EXE_LINKER_FLAGS:STRING="${{ env.LINK_FLAGS }}" \
-D MIMICPP_FORCED_CXX_STANDARD="${{ matrix.cxx_standard }}" \
-D MIMICPP_ENABLE_ADAPTER_TESTS=YES \
${{ env.CMAKE_CONFIG_EXTRA }}

- name: Build
Expand All @@ -186,7 +185,13 @@ jobs:
shell: bash
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest --test-dir build/test -C ${{ matrix.build_mode }} -j4
run: ctest --test-dir build/test/unit-tests -C ${{ matrix.build_mode }} -j4

- name: Run adapter tests
shell: bash
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest --test-dir build/test/adapter-tests -C ${{ matrix.build_mode }} -j4

- name: Run examples
shell: bash
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ jobs:
- name: Configure
env:
LDFLAGS: "-fprofile-arcs"
CXXFLAGS: "-g -O0 --coverage -fno-inline -fprofile-abs-path -fkeep-inline-functions -fkeep-static-functions"
run: |
cmake -S . \
-B build \
-D CMAKE_CXX_FLAGS="-g -O0 --coverage -fno-inline -fprofile-abs-path -fkeep-inline-functions -fkeep-static-functions" \
-D CMAKE_BUILD_TYPE="Debug"
-D CMAKE_BUILD_TYPE="Debug" \
-D MIMICPP_ENABLE_ADAPTER_TESTS=YES

- name: Build
run: |
Expand All @@ -42,7 +43,12 @@ jobs:
- name: Run tests
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest --test-dir build/test -C Debug -j4
run: ctest --test-dir build/test/unit-tests -C Debug -j4

- name: Run adapter tests
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest --test-dir build/test/adapter-tests -C Debug -j4

- name: Run examples
env:
Expand All @@ -53,9 +59,11 @@ jobs:
run: |
# circumvnet "fatal: detected dubious ownership in repository" error
git config --global --add safe.directory /__w/mimicpp/mimicpp
gcovr --root build/test --filter "include/mimic++" --keep -j4 -v \
gcovr --root build/test/unit-tests --filter "include/mimic++" --keep -j4 -v \
--exclude-lines-by-pattern "\s*assert\(" \
--exclude-lines-by-pattern "\s*unreachable\(\);" \
--exclude-unreachable-branches \
--exclude-function-lines \
--exclude-noncode-lines \
--exclude-throw-branches \
--decisions \
Expand All @@ -68,7 +76,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: gcov-files
path: "build/test/*.gcov"
path: "build/test/unit-tests/*.gcov"

- name: Upload generated report artifacts
uses: actions/upload-artifact@v4
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ target_include_directories(
)

set(CMAKE_CXX_STANDARD 20)
if (MIMICPP_FORCED_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${MIMICPP_FORCED_CXX_STANDARD})
endif()

target_compile_features(
mimicpp
INTERFACE
cxx_std_20
cxx_std_${CMAKE_CXX_STANDARD}
)

if (CMAKE_SOURCE_DIR STREQUAL mimicpp_SOURCE_DIR)
Expand All @@ -41,10 +45,6 @@ else()
set(IS_TOP_LEVEL_PROJECT OFF)
endif()

if (MIMICPP_FORCED_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${MIMICPP_FORCED_CXX_STANDARD})
endif()

OPTION(MIMICPP_BUILD_TESTS "Determines, whether the tests shall be built." ${IS_TOP_LEVEL_PROJECT})
if (MIMICPP_BUILD_TESTS)
include(CTest)
Expand Down
1 change: 1 addition & 0 deletions Folder.DotSettings
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/CppInitialization/PreferUniformInitializationInNSDMIs/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/CppInitialization/UseUniformInitializationInMemberInitializers/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClangTidyHicppExceptionBaseclass/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersOrder/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersPlacement/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceDoStatementBraces/@EntryIndexedValue">WARNING</s:String>
Expand Down
24 changes: 24 additions & 0 deletions cmake/SetupTestTarget.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright Dominic (DNKpp) Koepke 2024 - 2024.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)


function(setup_test_target TARGET_NAME)

if (SANITIZE_ADDRESS)

# workaround linker errors on msvc
# see: https://learn.microsoft.com/en-us/answers/questions/864574/enabling-address-sanitizer-results-in-error-lnk203
target_compile_definitions(
${TARGET_NAME}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:_DISABLE_VECTOR_ANNOTATION>
$<$<CXX_COMPILER_ID:MSVC>:_DISABLE_STRING_ANNOTATION>
)

endif()

add_sanitizers(${TARGET_NAME})

endfunction()
4 changes: 2 additions & 2 deletions docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,15 @@ LOOKUP_CACHE_SIZE = 0
# DOT_NUM_THREADS setting.
# Minimum value: 0, maximum value: 32, default value: 1.

NUM_PROC_THREADS = 1
NUM_PROC_THREADS = 0

# If the TIMESTAMP tag is set different from NO then each generated page will
# contain the date or date and time when the page was generated. Setting this to
# NO can help when comparing the output of multiple runs.
# Possible values are: YES, NO, DATETIME and DATE.
# The default value is: NO.

TIMESTAMP = NO
TIMESTAMP = DATE

#---------------------------------------------------------------------------
# Build related configuration options
Expand Down
35 changes: 3 additions & 32 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CPMAddPackage("gh:catchorg/Catch2@3.5.4")
find_package(Catch2 REQUIRED)
include("${Catch2_SOURCE_DIR}/extras/Catch.cmake")

add_executable(
Expand All @@ -9,31 +9,8 @@ add_executable(
"SideEffects.cpp"
)

if (MSVC)

# When using github ci, exceptions seems to be disabled by default.
target_compile_options(
mimicpp-examples
PRIVATE
/EHsc
)

endif()

if (SANITIZE_ADDRESS)

# workaround linker errors on msvc
# see: https://learn.microsoft.com/en-us/answers/questions/864574/enabling-address-sanitizer-results-in-error-lnk203
target_compile_definitions(
mimicpp-examples
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:_DISABLE_VECTOR_ANNOTATION>
$<$<CXX_COMPILER_ID:MSVC>:_DISABLE_STRING_ANNOTATION>
)

endif()

add_sanitizers(mimicpp-tests)
include(SetupTestTarget)
setup_test_target(mimicpp-examples)

target_link_libraries(
mimicpp-examples
Expand All @@ -42,10 +19,4 @@ target_link_libraries(
Catch2::Catch2WithMain
)

target_compile_features(
mimicpp
INTERFACE
cxx_std_${CMAKE_CXX_STANDARD}
)

catch_discover_tests(mimicpp-examples)
2 changes: 0 additions & 2 deletions examples/Finalizers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include "mimic++/Mock.hpp"

#include "../test/TestReporter.hpp"

#include <catch2/catch_test_macros.hpp>

#include <stdexcept>
Expand Down
6 changes: 3 additions & 3 deletions examples/Requirements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include "mimic++/Mock.hpp"

#include "../test/TestReporter.hpp"

#include <catch2/catch_test_macros.hpp>

TEST_CASE(
Expand Down Expand Up @@ -161,7 +159,9 @@ TEST_CASE(
return std::ranges::find(target, element) != std::ranges::end(target);
},
// specify a descriptive format message, which will be applied to std::format.
"range {} contains the element {}",
"contains element {}",
// specify the inverted message, which will also be applied to std::format, when inversion is used
"contains not element {}",
// capture additional data, which will be forwarded to both, the predicate and the description
std::tuple{42}
};
Expand Down
2 changes: 0 additions & 2 deletions examples/Sequences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include "mimic++/Mock.hpp"
#include "mimic++/Sequence.hpp"

#include "../test/TestReporter.hpp"

#include <catch2/catch_test_macros.hpp>

TEST_CASE(
Expand Down
2 changes: 0 additions & 2 deletions examples/SideEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include "mimic++/Mock.hpp"

#include "../test/TestReporter.hpp"

#include <catch2/catch_test_macros.hpp>

TEST_CASE(
Expand Down
Loading
Loading