Commit Graph

739 Commits

Author SHA1 Message Date
Martin Hořeňovský 4ce11d63a6 Merge branch 'dev-performance' 2017-01-25 22:56:36 +01:00
Martin Hořeňovský 83f4b39680 Added benchmark for previous commit, added iterations to failure bench. 2017-01-25 22:39:43 +01:00
Martin Hořeňovský b1171bd1f2 Merge branch 'dev-signals' 2017-01-25 22:09:52 +01:00
Martin Hořeňovský 184865358c CHECK no longer stops running SECTION on exception.
This seems to be much closer to desired behaviour than the current one, where
CHECK(false) lets the execution continue, but CHECK(<throws>) does not.
2017-01-23 17:52:17 +00:00
Phil Nash 31c23b9489 Added [!nonportable] tag 2017-01-23 17:44:55 +00:00
Phil Nash 1efd8d3067 Added missing <iterator> #include 2017-01-23 15:19:42 +00:00
Phil Nash e7bcbb35c0 First cut of -c/—section option for running specific sections 2017-01-23 12:36:03 +00:00
Martin Hořeňovský 9a56609569 v1.6.1 build 2017-01-20 12:49:59 +01:00
Mickey Rose 227598af47 use sizeof(expr) for unevaluated syntax check 2017-01-19 21:25:27 +01:00
Martin Hořeňovský ee0ca512ea Force short-circuited evaluation for types that have overloaded &&.
This fixes #574.
2017-01-17 23:31:03 +01:00
Martin Hořeňovský 2e87f8e328 Merge branch 'windows-header-defines' of https://github.com/horenmar/Catch 2017-01-16 17:00:43 +01:00
Martin Hořeňovský afe46ff270 Extracted NOMINMAX and WIN32_LEAN_AND_MEAN guards into a proxy header 2017-01-16 16:52:44 +01:00
Phil Nash c65aeaf25f Clean up generator state 2017-01-16 10:34:16 +00:00
Phil Nash 750b52b814 suppress use of __COUNTER__ when being parsed by CLion (or AppCode). 2017-01-16 10:34:16 +00:00
Vadim Zeitlin e1c4a4bd9b Use inline assembly with gcc under Linux for CATCH_TRAP
This is more convenient than using the generic portable raise(SIGTRAP) as it
avoids having another stack frame in the debugger when the break happens.
2017-01-15 19:29:34 +01:00
Vadim Zeitlin 25d017763b Refactor CATCH_BREAK_INTO_DEBUGGER() to avoid repetition
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.
2017-01-15 19:29:34 +01:00
Vadim Zeitlin b634e592da Add support for breaking into debugger for Linux
Use Linux-specific /proc/$PID/status file to check whether we're being
debugged and a generic raise(SIGTRAP) to actually break into the debugger.
2017-01-15 19:29:34 +01:00
Martin Hořeňovský 3b98a0166f Various small string usage performance improvements.
* 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.
2017-01-15 10:05:01 +01:00
Mickey Rose a1e9b841ff lazily stringify expressions 2017-01-14 21:56:16 +01:00
Martin Hořeňovský ffc4a9dc14 If we receive a signal, we re-register ALL previous signal handlers.
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...
2017-01-14 15:21:44 +01:00
Martin Hořeňovský 7c8b93eac3 Removed superfluous comments (bad merge after cherry pick). 2017-01-14 15:08:00 +01:00
Phil Nash 40dbdf6cb2 Reset signals immediately after use and re-raise orginal signal instead of just exiting 2017-01-12 17:31:56 +01:00
Martin Hořeňovský 70f43d719b Added signal handling under Windows.
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.
2017-01-12 16:40:14 +01:00
Martin Hořeňovský a281173099 Fix for sigsegv stack overflow behavior
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.
2017-01-12 16:23:55 +01:00
Martin Hořeňovský b3907a78e1 Added NOMINMAX and WIN32_LEAN_AND_MEAN defines before including windows.h
This stops the `windows.h` header from defining `min` and `max` macros
and including lot of Windows APIs that are not needed by Catch.
2017-01-12 16:00:02 +01:00
Phil Nash 3b2f206191 v1.6.0 build - including release notes 2017-01-11 16:44:36 +00:00
Phil Nash 4e4d733f90 Added \ as escape character in test names on the command line - so you can run tests by name when they contain , or [ 2017-01-11 16:27:16 +00:00
Phil Nash b68e8f9a24 Added missing #include so CATCH_CONFIG_COUNTER properly takes into account the current compiler.
May address #677 and #435 and others.
2017-01-11 16:27:16 +00:00
Martin Hořeňovský a1bed572be Standardize C++11 feature toggles to follow documentation
Closes #774
2017-01-10 22:54:57 +01:00
Martin Hořeňovský 6991549457 Fixed compile error under VS2015 /c++:latest, caused by using random_shuffle
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.
2017-01-09 23:29:13 +01:00
Phil Nash 5b00fd40ba Merge pull request #767 from hmich/xml-encoder-extended-ascii
Do not encode extended ASCII characters in XML reporter
2017-01-09 18:37:52 +00:00
Jonathan B. Coe 37e1e24309 add support for inequalities 2017-01-08 22:28:53 +01:00
Ross Bencina 7255be28cc remove concatenation of m_exprComponents.op in if-branch where op has tested empty in previous line 2017-01-07 13:37:08 +01:00
Philipp Claßen 8d1e240700 Fixed shell color code of "Blue" 2017-01-07 10:30:43 +01:00
Igor Akhmetov 8d16d95a99 Do not encode extended ASCII characters in XML reporter 2016-12-26 11:39:19 +00:00
Phil Nash 2be372710e Build 1.5.9 2016-11-29 12:15:50 +00:00
Martin Hořeňovský 0c8c6b347a Fixes build error caused by missing include. 2016-11-28 15:47:20 +01:00
Phil Nash e27c4ee042 Build 1.5.8 2016-10-26 12:08:26 +01:00
Billy Robert O'Neal III c17ba0870a Fix transform without a lambda
Catch apparently supports targeting C++03, so use an inline function
instead.
2016-10-14 14:28:15 -07:00
Billy Robert O'Neal III 79f01100e3 Fix transform narrowing warnings
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.
2016-10-14 14:16:21 -07:00
Billy Robert O'Neal III ccf7f2842a Fix random_shuffle narrowing warnings
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.
2016-10-14 14:06:45 -07:00
Phil Nash 40f6068d52 Build 1.5.7 2016-09-27 10:46:22 +01:00
Phil Nash 21cbfc107e --list-test-names quotes test names that start with #
- completes #717
2016-09-27 10:43:03 +01:00
Phil Nash b1eeec7c69 -f supports quoted test names (test name surrounded with " characters).
This is the first part to resolving #717
2016-09-27 10:27:28 +01:00
Phil Nash c23b374f3d Added braces to emphasise the return logic 2016-09-27 09:58:12 +01:00
nabijaczleweli 8c459dd207
Fix misindent
Closes #679
2016-09-27 00:35:26 +02:00
Robert A Zeh 5095619955 Fixes for XML encoding.
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
2016-08-24 09:38:24 -05:00
Phil Nash 35f510545d v1.5.6 2016-06-09 19:21:09 +01:00
Phil Nash 1aa6c91e64 Fixed RNG issue with pre C++14 compilers 2016-06-09 19:07:05 +01:00
Phil Nash ac220289a6 v1.5.5:
Deal with auto_ptr and random_shuffle hard deprecations in C++14
2016-06-09 08:19:23 +01:00