Merge branch 'release/0.10' into feature/library_intermediate

This commit is contained in:
Sebastian Messmer 2019-01-24 00:43:21 -08:00
commit 1eba529a47
4 changed files with 63 additions and 6 deletions

View File

@ -1,13 +1,11 @@
image:
#- Visual Studio 2013
#- Visual Studio 2015
- Visual Studio 2017
#- Visual Studio 2017 Preview
platform:
- x64
- x86
- Any CPU
#- Any CPU
configuration:
- Debug
@ -33,7 +31,8 @@ install:
build_script:
- cmd: mkdir build
- cmd: cd build
- cmd: cmake .. -G "Ninja" -DBUILD_TESTING=on -DBOOST_ROOT="C:/Libraries/boost_1_65_1" -DDOKAN_PATH="C:/Program Files/Dokan/DokanLibrary-1.1.0"
# note: The cmake+ninja workflow requires us to set build type in both cmake commands ('cmake' and 'cmake --build'), otherwise the cryfs.exe will depend on debug versions of the visual studio c++ runtime (i.e. msvcp140d.dll)
- cmd: cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DBUILD_TESTING=on -DBOOST_ROOT="C:/Libraries/boost_1_65_1" -DDOKAN_PATH="C:/Program Files/Dokan/DokanLibrary-1.1.0"
- cmd: cmake --build . --config %CONFIGURATION%
- cmd: .\test\gitversion\gitversion-test.exe
# cpp-utils-test disables ThreadDebuggingTest_ThreadName.*_thenIsCorrect because the appveyor image is too old to support the API needed for that

View File

@ -1,6 +1,10 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#ifdef NDEBUG
#define _REAL_NDEBUG
#endif
//Include the ASSERT macro for a debug build
#undef NDEBUG
#include "cpp-utils/assert/assert.h"
@ -29,9 +33,18 @@ constexpr const char* EXPECTED = R"(Assertion \[2==5\] failed in .*assert_debug_
);
}
#if !(defined(_MSC_VER) && defined(_REAL_NDEBUG))
TEST(AssertTest_DebugBuild, AssertMessageContainsBacktrace) {
EXPECT_DEATH(
ASSERT(2==5, "my message"),
"cpputils::"
);
}
#else
TEST(AssertTest_DebugBuild, AssertMessageContainsBacktrace) {
EXPECT_DEATH(
ASSERT(2==5, "my message"),
"#1"
);
}
#endif

View File

@ -2,6 +2,10 @@
#include <gmock/gmock.h>
#include <regex>
#ifdef NDEBUG
#define _REAL_NDEBUG
#endif
//Include the ASSERT macro for a release build
#ifndef NDEBUG
#define NDEBUG
@ -31,10 +35,11 @@ TEST(AssertTest_ReleaseBuild, AssertMessage) {
/*EXPECT_THAT(e.what(), MatchesRegex(
R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:27: my message)"
));*/
EXPECT_TRUE(std::regex_search(e.what(), std::regex(R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:26: my message)")));
EXPECT_TRUE(std::regex_search(e.what(), std::regex(R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:30: my message)")));
}
}
#if !(defined(_MSC_VER) && defined(_REAL_NDEBUG))
TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) {
try {
ASSERT(2==5, "my message");
@ -45,3 +50,15 @@ TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) {
));
}
}
#else
TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) {
try {
ASSERT(2==5, "my message");
FAIL();
} catch (const cpputils::AssertFailed &e) {
EXPECT_THAT(e.what(), HasSubstr(
"#1"
));
}
}
#endif

View File

@ -19,6 +19,12 @@ namespace {
}
}
TEST(BacktraceTest, ContainsBacktrace) {
string backtrace = cpputils::backtrace();
EXPECT_THAT(backtrace, HasSubstr("#1"));
}
#if !(defined(_MSC_VER) && defined(NDEBUG))
TEST(BacktraceTest, ContainsExecutableName) {
string backtrace = cpputils::backtrace();
EXPECT_THAT(backtrace, HasSubstr("cpp-utils-test"));
@ -29,7 +35,7 @@ TEST(BacktraceTest, ContainsTopLevelLine) {
EXPECT_THAT(backtrace, HasSubstr("BacktraceTest"));
EXPECT_THAT(backtrace, HasSubstr("ContainsTopLevelLine"));
}
#endif
namespace {
std::string call_process_exiting_with_nullptr_violation() {
@ -77,6 +83,7 @@ TEST(BacktraceTest, DoesntCrashOnCaughtException) {
}
}
#if !(defined(_MSC_VER) && defined(NDEBUG))
TEST(BacktraceTest, ShowBacktraceOnNullptrAccess) {
auto output = call_process_exiting_with_nullptr_violation();
EXPECT_THAT(output, HasSubstr("cpp-utils-test_exit_signal"));
@ -96,6 +103,27 @@ TEST(BacktraceTest, ShowBacktraceOnSigIll) {
auto output = call_process_exiting_with_sigill();
EXPECT_THAT(output, HasSubstr("cpp-utils-test_exit_signal"));
}
#else
TEST(BacktraceTest, ShowBacktraceOnNullptrAccess) {
auto output = call_process_exiting_with_nullptr_violation();
EXPECT_THAT(output, HasSubstr("#1"));
}
TEST(BacktraceTest, ShowBacktraceOnSigSegv) {
auto output = call_process_exiting_with_sigsegv();
EXPECT_THAT(output, HasSubstr("#1"));
}
TEST(BacktraceTest, ShowBacktraceOnUnhandledException) {
auto output = call_process_exiting_with_exception("my_exception_message");
EXPECT_THAT(output, HasSubstr("#1"));
}
TEST(BacktraceTest, ShowBacktraceOnSigIll) {
auto output = call_process_exiting_with_sigill();
EXPECT_THAT(output, HasSubstr("#1"));
}
#endif
#if !defined(_MSC_VER)
TEST(BacktraceTest, ShowBacktraceOnSigAbrt) {