Merge branch 'master' into contrib

This commit is contained in:
coombez 2017-11-21 08:15:03 -06:00 committed by GitHub
commit 6ae8e53496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 91 additions and 54 deletions

3
.gitignore vendored
View File

@ -24,6 +24,5 @@ DerivedData
*.xccheckout *.xccheckout
Build Build
.idea .idea
cmake-build-debug
cmake-build-release
.vs .vs
cmake-build-*

View File

@ -203,9 +203,13 @@ install:
before_script: before_script:
- export CXX=${COMPILER} - export CXX=${COMPILER}
- cd ${TRAVIS_BUILD_DIR} - cd ${TRAVIS_BUILD_DIR}
# Only run valgrind in debug build # Regenerate single header file, so it is tested in the examples...
- cmake -H. -BBuild-Debug -DCMAKE_BUILD_TYPE=Debug -Wdev -DUSE_CPP14=${CPP14} -DUSE_VALGRIND=${VALGRIND} -DNO_SELFTEST=${ENV_NO_SELFTEST} -DBUILD_EXAMPLES=${ENV_BUILD_EXAMPLES} - python scripts/generateSingleHeader.py
- cmake -H. -BBuild-Release -DCMAKE_BUILD_TYPE=Release -Wdev -DUSE_CPP14=${CPP14} -DNO_SELFTEST=${ENV_NO_SELFTEST} -DBUILD_EXAMPLES=${ENV_BUILD_EXAMPLES}
# Use Debug builds for running Valgrind and building examples
- cmake -H. -BBuild-Debug -DCMAKE_BUILD_TYPE=Debug -Wdev -DUSE_CPP14=${CPP14} -DUSE_VALGRIND=${VALGRIND} -DBUILD_EXAMPLES=ON
# Check that we don't miscompile with optimalizations...
- cmake -H. -BBuild-Release -DCMAKE_BUILD_TYPE=Release -Wdev -DUSE_CPP14=${CPP14}
script: script:
- cd Build-Debug - cd Build-Debug

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.0)
project(CatchSelfTest) project(CatchSelfTest)
option(USE_VALGRIND "Perform SelfTests with Valgrind" OFF) option(USE_VALGRIND "Perform SelfTests with Valgrind" OFF)
option(BUILD_EXAMPLES "Build documentation examples" OFF)
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
@ -177,6 +178,7 @@ set(INTERNAL_HEADERS
${HEADER_DIR}/internal/catch_timer.h ${HEADER_DIR}/internal/catch_timer.h
${HEADER_DIR}/internal/catch_tostring.h ${HEADER_DIR}/internal/catch_tostring.h
${HEADER_DIR}/internal/catch_totals.h ${HEADER_DIR}/internal/catch_totals.h
${HEADER_DIR}/internal/catch_user_interfaces.h
${HEADER_DIR}/internal/catch_version.h ${HEADER_DIR}/internal/catch_version.h
${HEADER_DIR}/internal/catch_wildcard_pattern.h ${HEADER_DIR}/internal/catch_wildcard_pattern.h
${HEADER_DIR}/internal/catch_windows_h_proxy.h ${HEADER_DIR}/internal/catch_windows_h_proxy.h

View File

@ -20,24 +20,11 @@ environment:
- additional_flags: "/D_UNICODE /DUNICODE" - additional_flags: "/D_UNICODE /DUNICODE"
wmain: 1 wmain: 1
- additional_flags: ""
wmain: 0
env_build_examples: 1
env_no_selftest: 1
matrix: matrix:
exclude: exclude:
- os: Visual Studio 2015 - os: Visual Studio 2015
additional_flags: "/permissive- /std:c++latest" additional_flags: "/permissive- /std:c++latest"
- os: Visual Studio 2015
env_build_examples: 1
env_no_selftest: 1
- configuration: Debug
env_build_examples: 1
env_no_selftest: 1
init: init:
- git config --global core.autocrlf input - git config --global core.autocrlf input
# Set build version to git commit-hash # Set build version to git commit-hash
@ -59,8 +46,9 @@ configuration:
#Cmake will autodetect the compiler, but we set the arch #Cmake will autodetect the compiler, but we set the arch
before_build: before_build:
- python scripts/generateSingleHeader.py
- set CXXFLAGS=%additional_flags% - set CXXFLAGS=%additional_flags%
- cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% -DNO_SELFTEST=%env_no_selftest% -DBUILD_EXAMPLES=%env_build_examples% - cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% -DBUILD_EXAMPLES=ON
# build with MSBuild # build with MSBuild
build: build:

View File

@ -30,6 +30,7 @@
# if defined(CATCH_CONFIG_DISABLE_MATCHERS) # if defined(CATCH_CONFIG_DISABLE_MATCHERS)
# undef CATCH_CONFIG_DISABLE_MATCHERS # undef CATCH_CONFIG_DISABLE_MATCHERS
# endif # endif
# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
#endif #endif
#if !defined(CATCH_CONFIG_IMPL_ONLY) #if !defined(CATCH_CONFIG_IMPL_ONLY)
@ -42,6 +43,7 @@
# endif # endif
#endif #endif
#include "internal/catch_user_interfaces.h"
#include "internal/catch_tag_alias_autoregistrar.h" #include "internal/catch_tag_alias_autoregistrar.h"
#include "internal/catch_test_registry.h" #include "internal/catch_test_registry.h"
#include "internal/catch_capture.hpp" #include "internal/catch_capture.hpp"

View File

@ -63,7 +63,7 @@
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
INTERNAL_CATCH_REACT( catchAssertionHandler ) \ INTERNAL_CATCH_REACT( catchAssertionHandler ) \
} while( Catch::isTrue( false && static_cast<bool>( !!(__VA_ARGS__) ) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look } while( Catch::isTrue(false) && static_cast<bool>( !!(__VA_ARGS__) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look
// The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&.
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -62,7 +62,8 @@ namespace Catch {
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
// This is just here to avoid compiler warnings with macro constants and boolean literals // This is just here to avoid compiler warnings with macro constants and boolean literals
inline bool isTrue( bool value ) { return value; } inline bool isTrue( bool value ){ return value; }
bool alwaysTrue(); bool alwaysTrue();
bool alwaysFalse(); bool alwaysFalse();

View File

@ -8,8 +8,6 @@
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
static auto const& defaultExpression = "{Unknown expression after the reported line}";
namespace Catch { namespace Catch {
StreamRedirect::StreamRedirect(std::ostream& stream, std::string& targetString) StreamRedirect::StreamRedirect(std::ostream& stream, std::string& targetString)
@ -129,9 +127,13 @@ namespace Catch {
static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals))); static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
// Reset working state // Reset working state
m_lastAssertionInfo = { "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}", m_lastAssertionInfo.resultDisposition }; resetAssertionInfo();
m_lastResult = result; m_lastResult = result;
} }
void RunContext::resetAssertionInfo() {
m_lastAssertionInfo.macroName = StringRef();
m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"_sr;
}
bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) { bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) {
ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo)); ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo));
@ -255,8 +257,7 @@ namespace Catch {
void RunContext::assertionPassed() { void RunContext::assertionPassed() {
++m_totals.assertions.passed; ++m_totals.assertions.passed;
m_lastAssertionInfo.capturedExpression = StringRef(defaultExpression, sizeof(defaultExpression) - 1); resetAssertionInfo();
m_lastAssertionInfo.macroName = StringRef("", 0);
} }
void RunContext::assertionRun() { void RunContext::assertionRun() {
@ -274,18 +275,19 @@ namespace Catch {
Counts prevAssertions = m_totals.assertions; Counts prevAssertions = m_totals.assertions;
double duration = 0; double duration = 0;
m_shouldReportUnexpected = true; m_shouldReportUnexpected = true;
try {
m_lastAssertionInfo = { "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal }; m_lastAssertionInfo = { "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal };
seedRng(*m_config); seedRng(*m_config);
Timer timer; Timer timer;
timer.start(); try {
if (m_reporter->getPreferences().shouldRedirectStdOut) { if (m_reporter->getPreferences().shouldRedirectStdOut) {
StreamRedirect coutRedir(cout(), redirectedCout); StreamRedirect coutRedir(cout(), redirectedCout);
StdErrRedirect errRedir(redirectedCerr); StdErrRedirect errRedir(redirectedCerr);
timer.start();
invokeActiveTestCase(); invokeActiveTestCase();
} else { } else {
timer.start();
invokeActiveTestCase(); invokeActiveTestCase();
} }
duration = timer.getElapsedSeconds(); duration = timer.getElapsedSeconds();

View File

@ -116,6 +116,8 @@ namespace Catch {
void runCurrentTest(std::string& redirectedCout, std::string& redirectedCerr); void runCurrentTest(std::string& redirectedCout, std::string& redirectedCerr);
void invokeActiveTestCase(); void invokeActiveTestCase();
void resetAssertionInfo();
private: private:
void handleUnfinishedSections(); void handleUnfinishedSections();

View File

@ -14,8 +14,12 @@
#include "catch_stringref.h" #include "catch_stringref.h"
#include <ostream> #include <ostream>
#include <cstring>
namespace Catch { namespace Catch {
StringRef::StringRef( char const* rawChars ) noexcept
: StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) )
{}
StringRef::operator std::string() const { StringRef::operator std::string() const {
return std::string( m_start, m_size ); return std::string( m_start, m_size );

View File

@ -10,8 +10,6 @@
#include <cstddef> #include <cstddef>
#include <string> #include <string>
#include <iosfwd> #include <iosfwd>
#include <cassert>
#include <cstring>
namespace Catch { namespace Catch {
@ -25,10 +23,12 @@ namespace Catch {
/// visible - but it does mean (substring) StringRefs should not be shared between /// visible - but it does mean (substring) StringRefs should not be shared between
/// threads. /// threads.
class StringRef { class StringRef {
friend struct StringRefTestAccess; public:
using size_type = std::size_t; using size_type = std::size_t;
private:
friend struct StringRefTestAccess;
char const* m_start; char const* m_start;
size_type m_size; size_type m_size;
@ -56,12 +56,7 @@ namespace Catch {
other.m_data = nullptr; other.m_data = nullptr;
} }
StringRef( char const* rawChars ) noexcept StringRef( char const* rawChars ) noexcept;
: m_start( rawChars ),
m_size( static_cast<size_type>(std::strlen(rawChars)))
{
assert( rawChars );
}
StringRef( char const* rawChars, size_type size ) noexcept StringRef( char const* rawChars, size_type size ) noexcept
: m_start( rawChars ), : m_start( rawChars ),
@ -121,6 +116,10 @@ namespace Catch {
auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;
inline auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
return StringRef( rawChars, size );
}
} // namespace Catch } // namespace Catch
#endif // CATCH_STRINGREF_H_INCLUDED #endif // CATCH_STRINGREF_H_INCLUDED

View File

@ -35,7 +35,7 @@ auto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInvoker* {
} }
struct NameAndTags { struct NameAndTags {
NameAndTags( StringRef name_ = "", StringRef tags_ = "" ) noexcept; NameAndTags( StringRef name_ = StringRef(), StringRef tags_ = StringRef() ) noexcept;
StringRef name; StringRef name;
StringRef tags; StringRef tags;
}; };

View File

@ -12,6 +12,10 @@
# pragma clang diagnostic ignored "-Wglobal-constructors" # pragma clang diagnostic ignored "-Wglobal-constructors"
#endif #endif
// Enable specific decls locally
#if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)
#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
#endif
#include "catch_tostring.h" #include "catch_tostring.h"
#include "catch_interfaces_config.h" #include "catch_interfaces_config.h"
@ -221,6 +225,13 @@ std::string StringMaker<double>::convert(double value) {
return fpToString(value, 10); return fpToString(value, 10);
} }
std::string ratio_string<std::atto>::symbol() { return "a"; }
std::string ratio_string<std::femto>::symbol() { return "f"; }
std::string ratio_string<std::pico>::symbol() { return "p"; }
std::string ratio_string<std::nano>::symbol() { return "n"; }
std::string ratio_string<std::micro>::symbol() { return "u"; }
std::string ratio_string<std::milli>::symbol() { return "m"; }
} // end namespace Catch } // end namespace Catch

View File

@ -26,7 +26,7 @@
// We need a dummy global operator<< so we can bring it into Catch namespace later // We need a dummy global operator<< so we can bring it into Catch namespace later
struct Catch_global_namespace_dummy; struct Catch_global_namespace_dummy {};
std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy);
namespace Catch { namespace Catch {
@ -351,6 +351,9 @@ namespace Catch {
#include <ratio> #include <ratio>
#include <chrono> #include <chrono>
namespace Catch {
template <class Ratio> template <class Ratio>
struct ratio_string { struct ratio_string {
static std::string symbol(); static std::string symbol();
@ -365,30 +368,29 @@ std::string ratio_string<Ratio>::symbol() {
} }
template <> template <>
struct ratio_string<std::atto> { struct ratio_string<std::atto> {
static std::string symbol() { return "a"; } static std::string symbol();
}; };
template <> template <>
struct ratio_string<std::femto> { struct ratio_string<std::femto> {
static std::string symbol() { return "f"; } static std::string symbol();
}; };
template <> template <>
struct ratio_string<std::pico> { struct ratio_string<std::pico> {
static std::string symbol() { return "p"; } static std::string symbol();
}; };
template <> template <>
struct ratio_string<std::nano> { struct ratio_string<std::nano> {
static std::string symbol() { return "n"; } static std::string symbol();
}; };
template <> template <>
struct ratio_string<std::micro> { struct ratio_string<std::micro> {
static std::string symbol() { return "u"; } static std::string symbol();
}; };
template <> template <>
struct ratio_string<std::milli> { struct ratio_string<std::milli> {
static std::string symbol() { return "m"; } static std::string symbol();
}; };
namespace Catch {
//////////// ////////////
// std::chrono::duration specializations // std::chrono::duration specializations
template<typename Value, typename Ratio> template<typename Value, typename Ratio>

View File

@ -0,0 +1,18 @@
/*
* Created by Martin on 21/11/2017.
*
* This file collects declaration that we want to expose to test files.
* These declarations are expected to be duplicated elsewhere,
* together with their implementation.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef TWOBLUECUBES_CATCH_USER_INTERFACES_H_INCLUDED
#define TWOBLUECUBES_CATCH_USER_INTERFACES_H_INCLUDED
namespace Catch {
unsigned int rngSeed();
}
#endif // TWOBLUECUBES_CATCH_USER_INTERFACES_H_INCLUDED

View File

@ -6,8 +6,6 @@ import re
import string import string
from scriptCommon import catchPath from scriptCommon import catchPath
import generateSingleHeader
import updateWandbox
versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' ) versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' )
rootPath = os.path.join( catchPath, 'include/' ) rootPath = os.path.join( catchPath, 'include/' )
@ -80,6 +78,8 @@ class Version:
f.write( line + "\n" ) f.write( line + "\n" )
def updateReadmeFile(version): def updateReadmeFile(version):
import updateWandbox
downloadParser = re.compile( r'<a href=\"https://github.com/philsquared/Catch/releases/download/v\d+\.\d+\.\d+/catch.hpp\">' ) downloadParser = re.compile( r'<a href=\"https://github.com/philsquared/Catch/releases/download/v\d+\.\d+\.\d+/catch.hpp\">' )
success, wandboxLink = updateWandbox.uploadFiles() success, wandboxLink = updateWandbox.uploadFiles()
if not success: if not success:
@ -142,7 +142,10 @@ def performUpdates(version):
# First update version file, so we can regenerate single header and # First update version file, so we can regenerate single header and
# have it ready for upload to wandbox, when updating readme # have it ready for upload to wandbox, when updating readme
version.updateVersionFile() version.updateVersionFile()
import generateSingleHeader
generateSingleHeader.generate(version) generateSingleHeader.generate(version)
updateReadmeFile(version) updateReadmeFile(version)
updateConanFile(version) updateConanFile(version)
updateConanTestFile(version) updateConanTestFile(version)