Merge branch 'master' of https://github.com/google/googletest
This commit is contained in:
commit
299d098daa
@ -1,5 +1,12 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.8)
|
cmake_minimum_required(VERSION 2.8.8)
|
||||||
add_definitions(-std=c++11)
|
|
||||||
|
if (CMAKE_VERSION VERSION_LESS "3.1")
|
||||||
|
add_definitions(-std=c++11)
|
||||||
|
else()
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (POLICY CMP0048)
|
if (POLICY CMP0048)
|
||||||
cmake_policy(SET CMP0048 NEW)
|
cmake_policy(SET CMP0048 NEW)
|
||||||
|
@ -124,8 +124,8 @@ include(ExternalProject)
|
|||||||
ExternalProject_Add(googletest
|
ExternalProject_Add(googletest
|
||||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||||
GIT_TAG master
|
GIT_TAG master
|
||||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
|
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
|
||||||
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
|
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
BUILD_COMMAND ""
|
BUILD_COMMAND ""
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
@ -140,13 +140,13 @@ Existing build's `CMakeLists.txt`:
|
|||||||
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
|
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||||
if(result)
|
if(result)
|
||||||
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||||
endif()
|
endif()
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||||
if(result)
|
if(result)
|
||||||
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||||
endif()
|
endif()
|
||||||
@ -157,8 +157,8 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|||||||
|
|
||||||
# Add googletest directly to our build. This defines
|
# Add googletest directly to our build. This defines
|
||||||
# the gtest and gtest_main targets.
|
# the gtest and gtest_main targets.
|
||||||
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
|
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||||
${CMAKE_BINARY_DIR}/googletest-build
|
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||||
EXCLUDE_FROM_ALL)
|
EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
# The gtest/gtest_main targets carry header search path
|
# The gtest/gtest_main targets carry header search path
|
||||||
|
@ -2520,8 +2520,9 @@ void Test::Run() {
|
|||||||
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
|
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
|
||||||
impl->os_stack_trace_getter()->UponLeavingGTest();
|
impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||||
internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
|
internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
|
||||||
// We will run the test only if SetUp() was successful.
|
// We will run the test only if SetUp() was successful and didn't call
|
||||||
if (!HasFatalFailure()) {
|
// GTEST_SKIP().
|
||||||
|
if (!HasFatalFailure() && !IsSkipped()) {
|
||||||
impl->os_stack_trace_getter()->UponLeavingGTest();
|
impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||||
internal::HandleExceptionsInMethodIfSupported(
|
internal::HandleExceptionsInMethodIfSupported(
|
||||||
this, &Test::TestBody, "the test body");
|
this, &Test::TestBody, "the test body");
|
||||||
@ -2698,9 +2699,10 @@ void TestInfo::Run() {
|
|||||||
factory_, &internal::TestFactoryBase::CreateTest,
|
factory_, &internal::TestFactoryBase::CreateTest,
|
||||||
"the test fixture's constructor");
|
"the test fixture's constructor");
|
||||||
|
|
||||||
// Runs the test if the constructor didn't generate a fatal failure.
|
// Runs the test if the constructor didn't generate a fatal failure or invoke
|
||||||
|
// GTEST_SKIP().
|
||||||
// Note that the object will not be null
|
// Note that the object will not be null
|
||||||
if (!Test::HasFatalFailure()) {
|
if (!Test::HasFatalFailure() && !Test::IsSkipped()) {
|
||||||
// This doesn't throw as all user code that can throw are wrapped into
|
// This doesn't throw as all user code that can throw are wrapped into
|
||||||
// exception handling code.
|
// exception handling code.
|
||||||
test->Run();
|
test->Run();
|
||||||
|
@ -32,7 +32,24 @@
|
|||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
using ::testing::Test;
|
||||||
|
|
||||||
TEST(SkipTest, DoesSkip) {
|
TEST(SkipTest, DoesSkip) {
|
||||||
GTEST_SKIP();
|
GTEST_SKIP();
|
||||||
EXPECT_EQ(0, 1);
|
EXPECT_EQ(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Fixture : public Test {
|
||||||
|
protected:
|
||||||
|
void SetUp() override {
|
||||||
|
GTEST_SKIP() << "skipping all tests for this fixture";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(Fixture, SkipsOneTest) {
|
||||||
|
EXPECT_EQ(5, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(Fixture, SkipsAnotherTest) {
|
||||||
|
EXPECT_EQ(99, 100);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user