Some versions of MinGW do not support enough of Win32 API to let us work
with SEH, so SEH is now MSVC only (+ configurable toggle).
Also made use of gmtime_s MSVC only (as oposed to Windows only).
Fixes#805
Because the signal changes were in a different branch from the windows.h
related changes, the SEH handling code included the header directly.
Fixes#803
This prevents Clang from complaining about unused value in expressions
containing explicit casts used in the THROW assertion macro family.
Example:
`REQUIRE_THROWS_AS(static_cast<bool>(object), std::bad_cast);` would
trigger `-Wunused-value` warning. Now it does not.
Credits to Arto Bendiken, who submitted a PR almost 3 years ago, but his
branch has since died and I was unable to merge it.
The integrated assembler segment was missing an underscore:
"_asm__". Also we remove the "DEBUG" macro check, so we are consistent
with the linux and windows variant.
Now breaking into gdb on failure should work via:
gdb --args test_executable --break
Using sizeof(expr) can trigger a compile-time error,
"lambda expressions are not allowed in an unevaluated context", when passing
expression containing lambda, like a std algorithm. This error is considered
a standard defect, as it is meant to prevent lambdas in decltype
or templates, but not in sizeof.
This reverts commit 227598af47.
In reality, this is a relatively small performance improvement,
especially with the previous improvements removing lots of superfluous
string handling, but still was measurable.
This is sane, because those `const char*`s are given to us by compiler,
from the text area and thus we do not have to manage their lifetimes. We
also never want to change them.
Also moved copy constructor to compiler-generated methods, not sure why
it wasn't -- even before it was the same as a compiler would generate.
This means that all tabs used in indentation are now 4 spaces and that
there should be no more trailing whitespace.
Ill also look into creating a pre-commit hook that will prevent this
from happening in the future.
Fixes#105
Don't duplicate Catch::isDebuggerActive() check many times, do it just once
in CATCH_BREAK_INTO_DEBUGGER() definition and use a separate CATCH_TRAP()
macro for the really platform-dependent part.
* Empty strings are now direct constructed as `std::string()`, not as empty string literals.
* `startsWith` and `endsWith` no longer construct new a string. This should be an improvement
for libstdc++ when using older standards, as it doesn't use SSO but COW and thus even short
strings are expensive to first create.
* Various places now use char literal instead of string literals containing single char.
** `startsWith` and `endsWith` now also have overload that takes single char.
Generally the performance improvements under VS2015 are small, as going from short string
to char is mostly meaningless because of SSO (Catch doesn't push string handling that hard)
and previous commit removed most string handling if tests pass, which is the expect case.
This fixes the case when we pass signal to previously registered
handler, and it needs to transform the signal into different one.
Still problematic: What if the signal handler we replaced does not
terminate the application? We can end up in a weird state and loop
forever.
Possible solution: Deregister our signal handlers, CALL the previous
signal handler explicitly and if control returns, abort. This would
however complicate our code quite a bit, as we would have to parse the
sigaction we delegate to, decide whether to use signal handler or signal
action, etc...
Only some "signals" are handled under Windows, because Windows does not
use signals per-se and the mechanics are different. For now, we handle
sigsegv, stack overflow, div-by-zero and sigill. We can also
meaningfully
add various floating point errors, but not sigterm and family, because
sigterm is not a structured exception under Windows.
There is also no catch-all, because that would also catch various
debugger-related exceptions, like EXCEPTION_BREAKPOINT.
Also stops Catch from assuming its the only signal user in the binary,
and makes it restore the signal handlers it has replaced. Same goes for
the signal stack.
The signal stack itself probably shouldn't be always reallocated for
fragmentation reasons, but that can be fixed later on.
Now if we detect C++11 compiler, or MSVC in version corresponding to VS2015,
we switch from using `std::random_shuffle` to `std::shuffle`.
`std::random_shuffle` was officially deprecated in C++14, and removed in C++17.
Also removed guarded inclusion of `<random>` header, as there was nothing
in the header that used it.
Catch passes ::tolower into std::transform with string iterators.
::tolower has the signature int(int), which triggers a stealth narrowing
warning inside std::transform, because transform calls
*_Dest = _Fn(*_First), which implicitly narrows an int to a char.
For this particular application the narrowing is fine, so explicitly
narrow in a lambda.
Catch passes an RNG which accepts int to random_shuffle. Inside
random_shuffle, the STL tries to call that RNG with the difference_type
of the user provided iterators. For std::vector, this is ptrdiff_t,
which on amd64 builds is wider than int. This triggers a narrowing
warning because the 64 bit difference is being truncated to 32 bits.
Note that this RNG implementation still does not produce a correctly
uniformly shuffled result -- it's currently asserting that std::rand
can produce 1000000 which is false -- but I don't know enough about
how much repeatable shuffles are necessary here, so I'm leaving that
alone for now.
This commit fixes the following scenario:
* You have a test that compares strings with embedded control
characters.
* The test fails.
* You are using JUnit tests within TeamCity.
Before this commit, the JUnit report watcher fails on parsing the XML
for two reasons: the control characters are missing a semicolon at the
end, and the XML document doesn't specify that it is XML 1.1.
XML 1.0 --- what we get if we don't specify an XML version --- doesn't support embedding control characters --- see
http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml
for all of the gory details.
This is based on PR #588 by @mrpi
Instead of `exit(1)`, it now throws `std::runtime_error` with the details
of the failure. This exception is handled in `run()` at a higher level where
the log is printed to cerr and the test gracefully exits.
- it was forward declared as a class, which caused warnings on some compilers. It should really have been a class anyway.
- this addresses the same issue as PR #534, albeit from the other angle.
I've incremented the minor release number. This is a slight abuse of semantic versioning so let me explain:
I've slightly changed how matchers are used. The matcher macro (REQUIRE_THAT/ CHECK_THAT) used to introduce the Catch::Matchers namespace before the macro token for the matcher, to save you having import the namespace yourself.
The trouble is if the matcher token is not a simple matcher (can now be an expression) this breaks!
So I've removed that qualification. Now if you use Matchers you'll have to do somethings like using namespace Catch::Matchers to bring them in.
This is a breaking change - but, OTTOH, Matchers are an undocumented "beta' feature that I've stated in the past is not guaranteed to have a stable API - so I don't think this warrants a major version change - but I did want to make it significant enough that people do notice that something is going on - and perhaps lead them to this commit message.
- simpler, polymorphic hierarchy-based, approach
- less bitty conditionals spread across the code
- all resolved up-front so now config class is immutable
(it had evolved the way it was and in need of a clean-up sweep for a long time)
This commit fixes the white background that appears in windows powershell
when catch outputs messages with colour. The previous implementation
ignored the original background colour and defaulted to a white background.
as prompted by #365, #430, #447 and a thread on the google group.
- split version bumping out of generateSingleHeader script
- separate scripts for bumping each version component
- "build" number only incremented for "develop" builds
Adding a --force-colour option to force colour output on POSIX systems,
provided a debugger is not attached.
This allows for Catch to output colours even if STDOUT is not a tty,
which can be the case when the test executable is being spawned by a
parent process (e.g. CMake's ctest).
# By Andy Sawyer
# Via Andy Sawyer (1) and Phil Nash (1)
* 'develop' of github.com:philsquared/Catch:
catch_tostring: tostring for enum class types
SelfTest: Build as C++11, add EnumToString tests
SelfTest: refresh makefile
- based on PR 232 (https://github.com/philsquared/Catch/pull/232 - thanks Lukasz Forynski)
- Writes to reporter, so gets all the usual context, but then exits directly (since the stack cannot be resumed) so no summary
- On Windows does nothing, as yet.
- moved as much logic out of the macros as possible
- moved most logic into new ResultBuilder class, which wraps ExpressionResultBuilder (may take it over next), subsumes ResultAction and also takes place of ExpressionDecomposer.
This introduces many SRP violations - but all in the name of minimising macro logic!
- Fixed endianness when converting numbers to hex strings
- Added option to show invisibles (/t, /n) in printed strings with -i
- moved toString() impls to impl file
- avoid allocations for static strings used in reporter
When the section tracking code was rewritten a while back to simplify and iron out some bugs the order of evaluation was changed so that each new section was skipped on the first run through.
This had unwelcome consequences for some people.
This commit restores the original semantics (while maintaining the simpler, less buggy, new code).
# By gnzlbg
# Via gnzlbg
* 'master' of https://github.com/gnzlbg/Catch:
Conditionally removes usage of deprecated features
Conflicts (resolved):
include/internal/catch_common.h
include/internal/catch_section.hpp
Added !throws special tag which denotes a test case to be skipped when run with -e
(the idea being that the test case is expected to throw an exception which is not caught within a XXX_THROWS assertion).
-add macros to test for C++ version and features
to catch_compiler_capabilities.hpp
- replaces dynamic exception specifications (deprecated)
with noexcept in C++ Version >= 11
- defines defaulted copy constructor/move constructors/assignment
in C++ Version >= 11 since their implicit generation is deprecated
under some circumstances.
- fixes#259
- updated command line setup with new API
- updated STITCH macros
- force embedded Clara to use Catch’s console width (but restore it after)
- remove command line tests (as these have now moved into the Clara project)
- Clara now built with new stitch script (based on generateSingleInclude)
- also fixed python scripts for python 3 (print now a function rather than a keyword)
- This is just a first step. It still has a dependency on catch_text.h, which also needs to be made a Cliche header.
- These then need their own homes on GitHub.
- use -f to specify filename. Blank lines and lines starting with # are ignored
- also added --list-test-names-only to list test names out to file in a form that can be immediate read in by -f
Detail::rangeToString is now defined after the various toString
overloads. This results in them being accessible with rangeToString is
instantiated (in this case, by StringMaker<vector>). This (sort-of)
fixes the problem where contained types are toString'd incorrectly.
Consider:
std::vector<std::string> v { "abc" };
Before:
Catch::toString( v ) == "{ abc }"
After:
Catch::toString( v ) == "{ "abc" }"
(note the extra pair of quotes around the "abc" - these are added by
Catch::toString( std::string ) which is now called by rangeToString)
- started integrating with reporters (now (optionally) supported in console reporter).
- introduced Node<> template to help with cumulative reporting and used it instead of ThreadedSectionInfo.
- also pass extra section to reporter - one for each test case - ignore it in headers
(this is so we know a test case has restarted)
- significant effect on regression test due to change of ordering of sections
- fixes infinite loop issue
includes:
- SFINAE version of IsStreamable (where available)
- new Text class that replaces LineWrapper (internal)
- fix for spurious double exception reporting (#164)
Always print test case + sections in header for every new section.
Group sections into single block
Tweaked BDD mappings to print out nicely with above
commit 70c5ef9eed
Author: Phil Nash <github@philnash.me>
Date: Tue Nov 13 21:46:01 2012 +0000
Regen single include
commit 4ea535e505
Author: Phil Nash <github@philnash.me>
Date: Tue Nov 13 09:56:30 2012 +0000
Tidied up result enums
commit 7717c29072
Author: Phil Nash <github@philnash.me>
Date: Tue Nov 13 09:45:29 2012 +0000
Implemented CHECK_NOFAIL
Previous commit missed some files
commit d539da9030
Author: Phil Nash <github@philnash.me>
Date: Tue Nov 13 09:44:52 2012 +0000
Implemented CHECK_NO_FAIL
commit af1a321860
Author: Phil Nash <github@philnash.me>
Date: Sat Nov 10 18:46:39 2012 +0000
Regen single include
commit f54ac5625e
Author: Phil Nash <github@philnash.me>
Date: Sat Nov 10 18:44:12 2012 +0000
New (combined) baselines
commit defca58566
Author: Phil Nash <github@philnash.me>
Date: Sat Nov 10 18:43:23 2012 +0000
negate() -> endExpression(), takes ResultDisposition
commit b2ef998825
Author: Phil Nash <github@philnash.me>
Date: Sat Nov 10 10:35:09 2012 +0000
Changed shouldNegate boolean to use part of ResultDisposition enum
commit 1af13dba97
Author: Phil Nash <github@philnash.me>
Date: Sat Nov 10 10:20:08 2012 +0000
Changed StopOnFailure boolean to an enum
commit a1dc7e312c
Author: Phil Nash <github@philnash.me>
Date: Tue Nov 6 19:34:35 2012 +0000
Regen single include
commit 20e59ce9d1
Author: Phil Nash <github@philnash.me>
Date: Tue Nov 6 19:34:10 2012 +0000
Added tags docs
commit b5b1b1e430
Author: Phil Nash <github@philnash.me>
Date: Tue Nov 6 19:13:25 2012 +0000
Some expression/ evaluation clean-up
commit ec5956f471
Author: Phil Nash <github@philnash.me>
Date: Tue Nov 6 07:52:28 2012 +0000
Fix for #134
The INTERNAL_CATCH_MSG macro, which is used by INFO, WARN and FAIL places its lines in a do…while block so it can be used after an if statement with no block
commit 88b70828f2
Author: Phil Nash <github@philnash.me>
Date: Sun Nov 4 21:39:38 2012 +0000
Regen single include
commit b323fc7e6c
Author: Phil Nash <github@philnash.me>
Date: Sun Nov 4 21:39:16 2012 +0000
Fixed line/no regression for SECTIONs
Unexpected exceptions within a section now get the SECTION's line no. again (instead of TEST_CASE line/no)
commit 78fba28c4b
Author: Phil Nash <github@philnash.me>
Date: Sun Nov 4 21:11:59 2012 +0000
Added className to TestCaseInfo
className is passed through from class based test methods and held in the TestCaseInfo.
For free-function based test cases it is set to "global".
The JUnit reporter uses the className value to populate he class attribute.
commit 81cb69ef18
Author: Phil Nash <github@philnash.me>
Date: Sun Nov 4 21:09:22 2012 +0000
AssertionInfo captures more info (for test cases and sections)
commit a4e088c999
Author: Phil Nash <github@philnash.me>
Date: Fri Nov 2 08:29:03 2012 +0000
Removed __FUNCTION__ from SourceLineInfo
commit 2a1e8bfc6e
Author: Phil Nash <github@philnash.me>
Date: Thu Nov 1 08:16:15 2012 +0000
Updated colour comments
commit f0f407fc3e
Author: Phil Nash <github@philnash.me>
Date: Wed Oct 31 18:28:21 2012 +0000
Manually applied merge #133 from Master
commit 355b95fda1
Author: Phil Nash <github@philnash.me>
Date: Wed Oct 31 18:04:22 2012 +0000
Cleaned up ANSI colour code impl a bit
commit 778f9c4fc7
Author: Phil Nash <github@philnash.me>
Date: Tue Oct 30 09:09:30 2012 +0000
Removed "no-" from Wno-global-constructors when disabling
commit 5efa4bcb8a
Author: Phil Nash <github@philnash.me>
Date: Mon Oct 29 20:49:22 2012 +0000
Regenerated single_include
commit 108f1937d8
Author: Phil Nash <github@philnash.me>
Date: Mon Oct 29 20:46:45 2012 +0000
Added terminal colour codes for POSIX
With thanks to Adam Strzelecki
commit 8f4cc541d5
Author: Phil Nash <github@philnash.me>
Date: Mon Oct 29 19:55:34 2012 +0000
Added regression test baselines
commit 2e203a1834
Author: Phil Nash <github@philnash.me>
Date: Mon Oct 29 19:55:13 2012 +0000
Fixed remaining reporting regressions
commit 134e45b3ad
Author: Phil Nash <github@philnash.me>
Date: Sun Oct 28 20:57:21 2012 +0000
Fixed#132
commit 2f92db9898
Author: Phil Nash <github@philnash.me>
Date: Sun Oct 28 12:15:34 2012 +0000
Updated the readme specifically for the Integration branch
commit 82acc2ca05
Author: Phil Nash <github@philnash.me>
Date: Sun Oct 28 12:07:17 2012 +0000
Regenerated single include
commit fe1d7c1d08
Author: Phil Nash <github@philnash.me>
Date: Sun Oct 28 10:27:44 2012 +0000
Small fixes and tweaks
commit 355b5e546d
Author: Phil Nash <github@philnash.me>
Date: Fri Oct 26 09:05:36 2012 +0100
Some tidy-up
commit f847186ebb
Author: Phil Nash <github@philnash.me>
Date: Fri Oct 26 08:45:23 2012 +0100
AssertionResultBuilder -> ExpressionResultBuilder
commit 8cca2f1369
Author: Phil Nash <github@philnash.me>
Date: Wed Oct 24 22:09:01 2012 +0100
ExpressionBuilder ->ExpressionDecomposer
Expression -> ExpressionLhs
commit e04e74f896
Author: Phil Nash <github@philnash.me>
Date: Wed Oct 24 21:59:47 2012 +0100
More AssertionResult refactoring
commit 1dd56d4d2b
Author: Phil Nash <github@philnash.me>
Date: Fri Oct 19 08:01:34 2012 +0100
AssertionResultBuilder can be constructed from result type
commit f2d5f1b3e4
Author: Phil Nash <github@philnash.me>
Date: Fri Oct 19 08:01:05 2012 +0100
Expression has its own result builder - not passed in from expression builder
commit e3b111a39a
Author: Phil Nash <github@philnash.me>
Date: Thu Oct 18 22:59:16 2012 +0100
streamlined acceptResult
commit 3ad13256e1
Author: Phil Nash <github@philnash.me>
Date: Thu Oct 18 08:39:44 2012 +0100
Refactored assertion builder stuff out of expression builder
commit c96f9330a0
Author: Phil Nash <github@philnash.me>
Date: Wed Oct 17 08:14:22 2012 +0100
Collect assertion info up front
commit a5fa78284d
Author: Phil Nash <github@philnash.me>
Date: Tue Oct 16 08:33:13 2012 +0100
ResultData -> AssertionResultData
commit c597a893fa
Author: Phil Nash <github@philnash.me>
Date: Tue Oct 16 08:31:05 2012 +0100
ResultInfo -> AssertionResult filenames and variables
commit d16955f63a
Author: Phil Nash <github@philnash.me>
Date: Tue Oct 16 08:27:21 2012 +0100
Renamed ResultInfo -> AssertionResult
commit 175da3ef64
Author: Phil Nash <github@philnash.me>
Date: Fri Oct 12 18:39:22 2012 +0100
regen test 3
The INTERNAL_CATCH_MSG macro, which is used by INFO, WARN and FAIL places its lines in a do…while block so it can be used after an if statement with no block
className is passed through from class based test methods and held in the TestCaseInfo.
For free-function based test cases it is set to "global".
The JUnit reporter uses the className value to populate he class attribute.
commit 2a1e8bfc6e
Author: Phil Nash <github@philnash.me>
Date: Thu Nov 1 08:16:15 2012 +0000
Updated colour comments
commit f0f407fc3e
Author: Phil Nash <github@philnash.me>
Date: Wed Oct 31 18:28:21 2012 +0000
Manually applied merge #133 from Master
commit 355b95fda1
Author: Phil Nash <github@philnash.me>
Date: Wed Oct 31 18:04:22 2012 +0000
Cleaned up ANSI colour code impl a bit
commit 778f9c4fc7
Author: Phil Nash <github@philnash.me>
Date: Tue Oct 30 09:09:30 2012 +0000
Removed "no-" from Wno-global-constructors when disabling
commit 5efa4bcb8a
Author: Phil Nash <github@philnash.me>
Date: Mon Oct 29 20:49:22 2012 +0000
Regenerated single_include
commit 108f1937d8
Author: Phil Nash <github@philnash.me>
Date: Mon Oct 29 20:46:45 2012 +0000
Added terminal colour codes for POSIX
With thanks to Adam Strzelecki
commit 8f4cc541d5
Author: Phil Nash <github@philnash.me>
Date: Mon Oct 29 19:55:34 2012 +0000
Added regression test baselines
commit 2e203a1834
Author: Phil Nash <github@philnash.me>
Date: Mon Oct 29 19:55:13 2012 +0000
Fixed remaining reporting regressions
commit 134e45b3ad
Author: Phil Nash <github@philnash.me>
Date: Sun Oct 28 20:57:21 2012 +0000
Fixed#132
commit 2f92db9898
Author: Phil Nash <github@philnash.me>
Date: Sun Oct 28 12:15:34 2012 +0000
Updated the readme specifically for the Integration branch
commit 82acc2ca05
Author: Phil Nash <github@philnash.me>
Date: Sun Oct 28 12:07:17 2012 +0000
Regenerated single include
commit fe1d7c1d08
Author: Phil Nash <github@philnash.me>
Date: Sun Oct 28 10:27:44 2012 +0000
Small fixes and tweaks
commit 355b5e546d
Author: Phil Nash <github@philnash.me>
Date: Fri Oct 26 09:05:36 2012 +0100
Some tidy-up
commit f847186ebb
Author: Phil Nash <github@philnash.me>
Date: Fri Oct 26 08:45:23 2012 +0100
AssertionResultBuilder -> ExpressionResultBuilder
commit 8cca2f1369
Author: Phil Nash <github@philnash.me>
Date: Wed Oct 24 22:09:01 2012 +0100
ExpressionBuilder ->ExpressionDecomposer
Expression -> ExpressionLhs
commit e04e74f896
Author: Phil Nash <github@philnash.me>
Date: Wed Oct 24 21:59:47 2012 +0100
More AssertionResult refactoring
commit 1dd56d4d2b
Author: Phil Nash <github@philnash.me>
Date: Fri Oct 19 08:01:34 2012 +0100
AssertionResultBuilder can be constructed from result type
commit f2d5f1b3e4
Author: Phil Nash <github@philnash.me>
Date: Fri Oct 19 08:01:05 2012 +0100
Expression has its own result builder - not passed in from expression builder
commit e3b111a39a
Author: Phil Nash <github@philnash.me>
Date: Thu Oct 18 22:59:16 2012 +0100
streamlined acceptResult
commit 3ad13256e1
Author: Phil Nash <github@philnash.me>
Date: Thu Oct 18 08:39:44 2012 +0100
Refactored assertion builder stuff out of expression builder
commit c96f9330a0
Author: Phil Nash <github@philnash.me>
Date: Wed Oct 17 08:14:22 2012 +0100
Collect assertion info up front
commit a5fa78284d
Author: Phil Nash <github@philnash.me>
Date: Tue Oct 16 08:33:13 2012 +0100
ResultData -> AssertionResultData
commit c597a893fa
Author: Phil Nash <github@philnash.me>
Date: Tue Oct 16 08:31:05 2012 +0100
ResultInfo -> AssertionResult filenames and variables
commit d16955f63a
Author: Phil Nash <github@philnash.me>
Date: Tue Oct 16 08:27:21 2012 +0100
Renamed ResultInfo -> AssertionResult
commit 175da3ef64
Author: Phil Nash <github@philnash.me>
Date: Fri Oct 12 18:39:22 2012 +0100
regen test 3
Suppress
catch.hpp(1760) : warning C4512: 'Catch::TagExtracter' : assignment operator could not be generated
catch.hpp(1864) : warning C4512: 'Catch::TagExpressionParser' : assignment operator could not be generated
warnings given by MSVC 9 (and probably other version too) compiler with /W4 switch.
The warnings are given because the compiler can't synthesize the assignment
operators for the classes with members of reference type, so simply explicitly
declare (without defining) these operators ourselves to suppress them.