From 0663ce9024c9b78ddf6eb3fc1ceb45361ed91767 Mon Sep 17 00:00:00 2001 From: Romain Geissler Date: Sat, 2 Dec 2017 22:47:20 +0100 Subject: [PATCH 01/17] Fix double free when building Gtest/GMock in shared libraries and linking a test executable with both. --- googlemock/CMakeLists.txt | 63 +++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt index 724fdd5f..f7bad8af 100644 --- a/googlemock/CMakeLists.txt +++ b/googlemock/CMakeLists.txt @@ -86,16 +86,23 @@ endif() # Google Mock libraries. We build them using more strict warnings than what # are used for other targets, to ensure that Google Mock can be compiled by # a user aggressive about warnings. -cxx_library(gmock - "${cxx_strict}" - "${gtest_dir}/src/gtest-all.cc" - src/gmock-all.cc) +if (MSVC) + cxx_library(gmock + "${cxx_strict}" + "${gtest_dir}/src/gtest-all.cc" + src/gmock-all.cc) -cxx_library(gmock_main - "${cxx_strict}" - "${gtest_dir}/src/gtest-all.cc" - src/gmock-all.cc - src/gmock_main.cc) + cxx_library(gmock_main + "${cxx_strict}" + "${gtest_dir}/src/gtest-all.cc" + src/gmock-all.cc + src/gmock_main.cc) +else() + cxx_library(gmock "${cxx_strict}" src/gmock-all.cc) + target_link_libraries(gmock gtest) + cxx_library(gmock_main "${cxx_strict}" src/gmock_main.cc) + target_link_libraries(gmock_main gmock) +endif() # If the CMake version supports it, attach header directory information # to the targets for when we are part of a parent build (ie being pulled @@ -175,23 +182,33 @@ if (gmock_build_tests) ############################################################ # C++ tests built with non-standard compiler flags. - cxx_library(gmock_main_no_exception "${cxx_no_exception}" - "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) - - cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" - "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) - - if (NOT MSVC OR MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010. - # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that - # conflict with our own definitions. Therefore using our own tuple does not - # work on those compilers. - cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}" + if (MSVC) + cxx_library(gmock_main_no_exception "${cxx_no_exception}" "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) - cxx_test_with_flags(gmock_use_own_tuple_test "${cxx_use_own_tuple}" - gmock_main_use_own_tuple test/gmock-spec-builders_test.cc) - endif() + cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" + "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) + if (MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010. + # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that + # conflict with our own definitions. Therefore using our own tuple does not + # work on those compilers. + cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}" + "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) + + cxx_test_with_flags(gmock_use_own_tuple_test "${cxx_use_own_tuple}" + gmock_main_use_own_tuple test/gmock-spec-builders_test.cc) + endif() + else() + cxx_library(gmock_main_no_exception "${cxx_no_exception}" src/gmock_main.cc) + target_link_libraries(gmock_main_no_exception gmock) + + cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" src/gmock_main.cc) + target_link_libraries(gmock_main_no_rtti gmock) + + cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}" src/gmock_main.cc) + target_link_libraries(gmock_main_use_own_tuple gmock) + endif() cxx_test_with_flags(gmock-more-actions_no_exception_test "${cxx_no_exception}" gmock_main_no_exception test/gmock-more-actions_test.cc) From 2982dc1a5800131f567f8b7fdfff8b2c15584b35 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Thu, 11 Jan 2018 14:57:20 -0500 Subject: [PATCH 02/17] Trying to fix travis --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 738e1194..1f6b8094 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,15 +13,11 @@ matrix: - os: linux group: deprecated-2017Q4 compiler: gcc - sudo: true - cache: install: ./ci/install-linux.sh && ./ci/log-config.sh script: ./ci/build-linux-bazel.sh - os: linux group: deprecated-2017Q4 compiler: clang - sudo: true - cache: install: ./ci/install-linux.sh && ./ci/log-config.sh script: ./ci/build-linux-bazel.sh - os: linux From 93b77987f59955e3a927c957a99cb8290b9f4990 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Thu, 11 Jan 2018 17:36:34 -0500 Subject: [PATCH 03/17] continue upstream/merge, etc --- googletest/include/gtest/internal/gtest-internal.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 454fffbc..88f94c4a 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -197,7 +197,7 @@ namespace edit_distance { // Returns the optimal edits to go from 'left' to 'right'. // All edits cost the same, with replace having lower priority than // add/remove. -// Simple implementation of the Wagner-Fischer algorithm. +// Simple implementation of the Wagner–Fischer algorithm. // See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm enum EditType { kMatch, kAdd, kRemove, kReplace }; GTEST_API_ std::vector CalculateOptimalEdits( @@ -650,7 +650,7 @@ class TypeParameterizedTest { // Types). Valid values for 'index' are [0, N - 1] where N is the // length of Types. static bool Register(const char* prefix, - CodeLocation code_location, + const CodeLocation& code_location, const char* case_name, const char* test_names, int index) { typedef typename Types::Head Type; @@ -681,7 +681,7 @@ class TypeParameterizedTest { template class TypeParameterizedTest { public: - static bool Register(const char* /*prefix*/, CodeLocation, + static bool Register(const char* /*prefix*/, const CodeLocation&, const char* /*case_name*/, const char* /*test_names*/, int /*index*/) { return true; @@ -727,7 +727,7 @@ class TypeParameterizedTestCase { template class TypeParameterizedTestCase { public: - static bool Register(const char* /*prefix*/, CodeLocation, + static bool Register(const char* /*prefix*/, const CodeLocation&, const TypedTestCasePState* /*state*/, const char* /*case_name*/, const char* /*test_names*/) { return true; From da1f7fe1e7a54f2ecc6451b08053a29f735b4327 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 15 Jan 2018 16:06:32 -0500 Subject: [PATCH 04/17] Code merging --- googletest/include/gtest/gtest.h | 11 ++++++++++- googletest/include/gtest/gtest_pred_impl.h | 13 ++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 57201123..940e5769 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -349,6 +349,15 @@ GTEST_API_ AssertionResult AssertionFailure(); // Deprecated; use AssertionFailure() << msg. GTEST_API_ AssertionResult AssertionFailure(const Message& msg); +} // namespace testing + +// Includes the auto-generated header that implements a family of generic +// predicate assertion macros. This include comes late because it relies on +// APIs declared above. +#include "gtest/gtest_pred_impl.h" + +namespace testing { + // The abstract class that all tests inherit from. // // In Google Test, a unit test program contains one or many TestCases, and @@ -359,7 +368,7 @@ GTEST_API_ AssertionResult AssertionFailure(const Message& msg); // this for you. // // The only time you derive from Test is when defining a test fixture -// to be used a TEST_F. For example: +// to be used in a TEST_F. For example: // // class FooTest : public testing::Test { // protected: diff --git a/googletest/include/gtest/gtest_pred_impl.h b/googletest/include/gtest/gtest_pred_impl.h index 30ae712f..c8be230e 100644 --- a/googletest/include/gtest/gtest_pred_impl.h +++ b/googletest/include/gtest/gtest_pred_impl.h @@ -27,7 +27,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command +// This file is AUTOMATICALLY GENERATED on 01/02/2018 by command // 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND! // // Implements a family of generic predicate assertion macros. @@ -35,10 +35,9 @@ #ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ #define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ -// Makes sure this header is not included before gtest.h. -#ifndef GTEST_INCLUDE_GTEST_GTEST_H_ -# error Do not include gtest_pred_impl.h directly. Include gtest.h instead. -#endif // GTEST_INCLUDE_GTEST_GTEST_H_ +#include "gtest/gtest.h" + +namespace testing { // This header implements a family of generic predicate assertion // macros: @@ -66,8 +65,6 @@ // We also define the EXPECT_* variations. // // For now we only support predicates whose arity is at most 5. -// Please email googletestframework@googlegroups.com if you need -// support for higher arities. // GTEST_ASSERT_ is the basic statement to which all of the assertions // in this file reduce. Don't use this in your code. @@ -355,4 +352,6 @@ AssertionResult AssertPred5Helper(const char* pred_text, +} // namespace testing + #endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ From d629744ec0e08d4e8b27ec18ec8e38ca52fea843 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 15 Jan 2018 16:23:23 -0500 Subject: [PATCH 05/17] More code merges --- googletest/include/gtest/gtest.h | 33 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 940e5769..fe515bda 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -563,9 +563,8 @@ class GTEST_API_ TestResult { // Returns the elapsed time, in milliseconds. TimeInMillis elapsed_time() const { return elapsed_time_; } - // Returns the i-th test part result among all the results. i can range - // from 0 to test_property_count() - 1. If i is not in that range, aborts - // the program. + // Returns the i-th test part result among all the results. i can range from 0 + // to total_part_count() - 1. If i is not in that range, aborts the program. const TestPartResult& GetTestPartResult(int i) const; // Returns the i-th test property. i can range from 0 to @@ -688,6 +687,9 @@ class GTEST_API_ TestInfo { // Returns the line where this test is defined. int line() const { return location_.line; } + // Return true if this test should not be run because it's in another shard. + bool is_in_another_shard() const { return is_in_another_shard_; } + // Returns true if this test should run, that is if the test is not // disabled (or it is disabled but the also_run_disabled_tests flag has // been specified) and its full name matches the user-specified filter. @@ -708,10 +710,9 @@ class GTEST_API_ TestInfo { // Returns true iff this test will appear in the XML report. bool is_reportable() const { - // For now, the XML report includes all tests matching the filter. - // In the future, we may trim tests that are excluded because of - // sharding. - return matches_filter_; + // The XML report includes tests matching the filter, excluding those + // run in other shards. + return matches_filter_ && !is_in_another_shard_; } // Returns the result of the test. @@ -775,6 +776,7 @@ class GTEST_API_ TestInfo { bool is_disabled_; // True iff this test is disabled bool matches_filter_; // True if this test matches the // user-specified filter. + bool is_in_another_shard_; // Will be run in another shard. internal::TestFactoryBase* const factory_; // The factory that creates // the test object @@ -1791,7 +1793,6 @@ template class TestWithParam : public Test, public WithParamInterface { }; - // Macros for indicating success/failure in test code. // ADD_FAILURE unconditionally adds a failure to the current test. @@ -1864,22 +1865,18 @@ class TestWithParam : public Test, public WithParamInterface { // AssertionResult. For more information on how to use AssertionResult with // these macros see comments on that class. #define EXPECT_TRUE(condition) \ - GTEST_TEST_BOOLEAN_((condition), #condition, false, true, \ + GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ GTEST_NONFATAL_FAILURE_) #define EXPECT_FALSE(condition) \ GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ GTEST_NONFATAL_FAILURE_) #define ASSERT_TRUE(condition) \ - GTEST_TEST_BOOLEAN_((condition), #condition, false, true, \ + GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ GTEST_FATAL_FAILURE_) #define ASSERT_FALSE(condition) \ GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ GTEST_FATAL_FAILURE_) -// Includes the auto-generated header that implements a family of -// generic predicate assertion macros. -#include "gtest/gtest_pred_impl.h" - // Macros for testing equalities and inequalities. // // * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2 @@ -1921,8 +1918,8 @@ class TestWithParam : public Test, public WithParamInterface { // // Examples: // -// EXPECT_NE(5, Foo()); -// EXPECT_EQ(NULL, a_pointer); +// EXPECT_NE(Foo(), 5); +// EXPECT_EQ(a_pointer, NULL); // ASSERT_LT(i, array_size); // ASSERT_GT(records.size(), 0) << "There is no record left."; @@ -2221,8 +2218,8 @@ bool StaticAssertTypeEq() { // } // // TEST_F(FooTest, ReturnsElementCountCorrectly) { -// EXPECT_EQ(0, a_.size()); -// EXPECT_EQ(1, b_.size()); +// EXPECT_EQ(a_.size(), 0); +// EXPECT_EQ(b_.size(), 1); // } #define TEST_F(test_fixture, test_name)\ From 5f4ce9d88475b5f5b089c10983ea65cdc9cb92d8 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 15 Jan 2018 16:46:16 -0500 Subject: [PATCH 06/17] Test files for corresponding changes --- googletest/test/gtest_xml_output_unittest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index 9f92f982..9ba08dfb 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -141,6 +141,19 @@ EXPECTED_FILTERED_TEST_XML = """ """ +EXPECTED_SHARDED_TEST_XML = """ + + + + + + + + + + +""" + EXPECTED_EMPTY_XML = """ From f45c22c4824934299f2899d2717efbf3061cfe73 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 15 Jan 2018 16:56:17 -0500 Subject: [PATCH 07/17] Test files for corresponding changes --- googletest/test/gtest_xml_output_unittest.py | 30 ++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index 9ba08dfb..3b0abaea 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -46,11 +46,16 @@ import gtest_xml_test_utils GTEST_FILTER_FLAG = '--gtest_filter' GTEST_LIST_TESTS_FLAG = '--gtest_list_tests' -GTEST_OUTPUT_FLAG = "--gtest_output" -GTEST_DEFAULT_OUTPUT_FILE = "test_detail.xml" -GTEST_PROGRAM_NAME = "gtest_xml_output_unittest_" +GTEST_OUTPUT_FLAG = '--gtest_output' +GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml' +GTEST_PROGRAM_NAME = 'gtest_xml_output_unittest_' -SUPPORTS_STACK_TRACES = False +# The environment variables for test sharding. +TOTAL_SHARDS_ENV_VAR = 'TEST_TOTAL_SHARDS' +SHARD_INDEX_ENV_VAR = 'TEST_SHARD_INDEX' +SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE' + +SUPPORTS_STACK_TRACES = IS_LINUX if SUPPORTS_STACK_TRACES: STACK_TRACE_TEMPLATE = '\nStack trace:\n*' @@ -276,7 +281,22 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0, extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG]) - def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code): + def testShardedTestXmlOutput(self): + """Verifies XML output when run using multiple shards. + + Runs a test program that executes only one shard and verifies that tests + from other shards do not show up in the XML output. + """ + + self._TestXmlOutput( + GTEST_PROGRAM_NAME, + EXPECTED_SHARDED_TEST_XML, + 0, + extra_env={SHARD_INDEX_ENV_VAR: '0', + TOTAL_SHARDS_ENV_VAR: '10'}) + + def _GetXmlOutput(self, gtest_prog_name, extra_args, extra_env, + expected_exit_code): """ Returns the xml output generated by running the program gtest_prog_name. Furthermore, the program's exit code must be expected_exit_code. From 6befe422f2ce9e2d8b702c1afb70325a6f2856e4 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 15 Jan 2018 16:59:57 -0500 Subject: [PATCH 08/17] Test files for corresponding changes --- googletest/test/gtest_xml_output_unittest.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index 3b0abaea..2057be7d 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -200,7 +200,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): Runs a test program that generates an empty XML output, and checks if the timestamp attribute in the testsuites tag is valid. """ - actual = self._GetXmlOutput('gtest_no_test_unittest', [], 0) + actual = self._GetXmlOutput('gtest_no_test_unittest', [], {}, 0) date_time_str = actual.documentElement.getAttributeNode('timestamp').value # datetime.strptime() is only available in Python 2.5+ so we have to # parse the expected datetime manually. @@ -230,8 +230,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): 'gtest_no_test_unittest') try: os.remove(output_file) - except OSError: - e = sys.exc_info()[1] + except OSError, e: if e.errno != errno.ENOENT: raise @@ -307,7 +306,11 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] + extra_args) - p = gtest_test_utils.Subprocess(command) + environ_copy = os.environ.copy() + if extra_env: + environ_copy.update(extra_env) + p = gtest_test_utils.Subprocess(command, env=environ_copy) + if p.terminated_by_signal: self.assert_(False, '%s was killed by signal %d' % (gtest_prog_name, p.signal)) @@ -321,7 +324,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): return actual def _TestXmlOutput(self, gtest_prog_name, expected_xml, - expected_exit_code, extra_args=None): + expected_exit_code, extra_args=None, extra_env=None): """ Asserts that the XML document generated by running the program gtest_prog_name matches expected_xml, a string containing another @@ -330,7 +333,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): """ actual = self._GetXmlOutput(gtest_prog_name, extra_args or [], - expected_exit_code) + extra_env or {}, expected_exit_code) expected = minidom.parseString(expected_xml) self.NormalizeXml(actual.documentElement) self.AssertEquivalentNodes(expected.documentElement, From 304be8f009d0b8be6e98fb136a77df6ee8bb129f Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 15 Jan 2018 17:15:52 -0500 Subject: [PATCH 09/17] Test files for corresponding changes --- googletest/test/gtest_xml_output_unittest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index 2057be7d..234c914f 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -40,6 +40,8 @@ import re import sys from xml.dom import minidom, Node +IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux' + import gtest_test_utils import gtest_xml_test_utils From b9e297838daa46cbfc8cfef58fe4c4c3cc8c0d68 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 15 Jan 2018 17:34:46 -0500 Subject: [PATCH 10/17] Reverting some changes, need to make the merge compile --- googletest/include/gtest/gtest.h | 5 +- googletest/test/gtest_xml_output_unittest.py | 60 ++++---------------- 2 files changed, 12 insertions(+), 53 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index fe515bda..3eeaf6fb 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -687,9 +687,6 @@ class GTEST_API_ TestInfo { // Returns the line where this test is defined. int line() const { return location_.line; } - // Return true if this test should not be run because it's in another shard. - bool is_in_another_shard() const { return is_in_another_shard_; } - // Returns true if this test should run, that is if the test is not // disabled (or it is disabled but the also_run_disabled_tests flag has // been specified) and its full name matches the user-specified filter. @@ -712,7 +709,7 @@ class GTEST_API_ TestInfo { bool is_reportable() const { // The XML report includes tests matching the filter, excluding those // run in other shards. - return matches_filter_ && !is_in_another_shard_; + return matches_filter_; } // Returns the result of the test. diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index 234c914f..9f92f982 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -40,24 +40,17 @@ import re import sys from xml.dom import minidom, Node -IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux' - import gtest_test_utils import gtest_xml_test_utils GTEST_FILTER_FLAG = '--gtest_filter' GTEST_LIST_TESTS_FLAG = '--gtest_list_tests' -GTEST_OUTPUT_FLAG = '--gtest_output' -GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml' -GTEST_PROGRAM_NAME = 'gtest_xml_output_unittest_' +GTEST_OUTPUT_FLAG = "--gtest_output" +GTEST_DEFAULT_OUTPUT_FILE = "test_detail.xml" +GTEST_PROGRAM_NAME = "gtest_xml_output_unittest_" -# The environment variables for test sharding. -TOTAL_SHARDS_ENV_VAR = 'TEST_TOTAL_SHARDS' -SHARD_INDEX_ENV_VAR = 'TEST_SHARD_INDEX' -SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE' - -SUPPORTS_STACK_TRACES = IS_LINUX +SUPPORTS_STACK_TRACES = False if SUPPORTS_STACK_TRACES: STACK_TRACE_TEMPLATE = '\nStack trace:\n*' @@ -148,19 +141,6 @@ EXPECTED_FILTERED_TEST_XML = """ """ -EXPECTED_SHARDED_TEST_XML = """ - - - - - - - - - - -""" - EXPECTED_EMPTY_XML = """ @@ -202,7 +182,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): Runs a test program that generates an empty XML output, and checks if the timestamp attribute in the testsuites tag is valid. """ - actual = self._GetXmlOutput('gtest_no_test_unittest', [], {}, 0) + actual = self._GetXmlOutput('gtest_no_test_unittest', [], 0) date_time_str = actual.documentElement.getAttributeNode('timestamp').value # datetime.strptime() is only available in Python 2.5+ so we have to # parse the expected datetime manually. @@ -232,7 +212,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): 'gtest_no_test_unittest') try: os.remove(output_file) - except OSError, e: + except OSError: + e = sys.exc_info()[1] if e.errno != errno.ENOENT: raise @@ -282,22 +263,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0, extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG]) - def testShardedTestXmlOutput(self): - """Verifies XML output when run using multiple shards. - - Runs a test program that executes only one shard and verifies that tests - from other shards do not show up in the XML output. - """ - - self._TestXmlOutput( - GTEST_PROGRAM_NAME, - EXPECTED_SHARDED_TEST_XML, - 0, - extra_env={SHARD_INDEX_ENV_VAR: '0', - TOTAL_SHARDS_ENV_VAR: '10'}) - - def _GetXmlOutput(self, gtest_prog_name, extra_args, extra_env, - expected_exit_code): + def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code): """ Returns the xml output generated by running the program gtest_prog_name. Furthermore, the program's exit code must be expected_exit_code. @@ -308,11 +274,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] + extra_args) - environ_copy = os.environ.copy() - if extra_env: - environ_copy.update(extra_env) - p = gtest_test_utils.Subprocess(command, env=environ_copy) - + p = gtest_test_utils.Subprocess(command) if p.terminated_by_signal: self.assert_(False, '%s was killed by signal %d' % (gtest_prog_name, p.signal)) @@ -326,7 +288,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): return actual def _TestXmlOutput(self, gtest_prog_name, expected_xml, - expected_exit_code, extra_args=None, extra_env=None): + expected_exit_code, extra_args=None): """ Asserts that the XML document generated by running the program gtest_prog_name matches expected_xml, a string containing another @@ -335,7 +297,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): """ actual = self._GetXmlOutput(gtest_prog_name, extra_args or [], - extra_env or {}, expected_exit_code) + expected_exit_code) expected = minidom.parseString(expected_xml) self.NormalizeXml(actual.documentElement) self.AssertEquivalentNodes(expected.documentElement, From 6d04de7419a722e382c0445db88a7f749f6087d6 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 15 Jan 2018 17:36:45 -0500 Subject: [PATCH 11/17] Reverting some changes, need to make the merge compile --- googletest/include/gtest/gtest.h | 1 - 1 file changed, 1 deletion(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 3eeaf6fb..8326fa5d 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -773,7 +773,6 @@ class GTEST_API_ TestInfo { bool is_disabled_; // True iff this test is disabled bool matches_filter_; // True if this test matches the // user-specified filter. - bool is_in_another_shard_; // Will be run in another shard. internal::TestFactoryBase* const factory_; // The factory that creates // the test object From 9195571c6952dc4c8b6059fc6c15157a1e50f623 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 15 Jan 2018 17:39:33 -0500 Subject: [PATCH 12/17] Reverting some changes, need to make the merge compile --- googletest/include/gtest/gtest.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 8326fa5d..c6efae50 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -707,8 +707,9 @@ class GTEST_API_ TestInfo { // Returns true iff this test will appear in the XML report. bool is_reportable() const { - // The XML report includes tests matching the filter, excluding those - // run in other shards. + // The XML report includes tests matching the filter. + // In the future, we may trim tests that are excluded because of + - // sharding. return matches_filter_; } From 08b323f717eace078d3b2e3d9e29e1df5db6f293 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 15 Jan 2018 18:16:11 -0500 Subject: [PATCH 13/17] Reverting some changes, need to make the merge compile --- googletest/include/gtest/gtest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index c6efae50..c4444cf6 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -709,7 +709,7 @@ class GTEST_API_ TestInfo { bool is_reportable() const { // The XML report includes tests matching the filter. // In the future, we may trim tests that are excluded because of - - // sharding. + // sharding. return matches_filter_; } From 9c82e7745c257f38d7dd7ff8a9759ea58b6a4e89 Mon Sep 17 00:00:00 2001 From: Fedor Trushkin Date: Wed, 17 Jan 2018 16:41:59 +0100 Subject: [PATCH 14/17] Expose ScopedTrace utility in public interface --- googletest/include/gtest/gtest.h | 55 ++++++++++++++++++- .../include/gtest/internal/gtest-internal.h | 43 --------------- googletest/src/gtest.cc | 39 +++++++------ googletest/test/gtest_output_test.py | 3 +- googletest/test/gtest_output_test_.cc | 7 +++ .../test/gtest_output_test_golden_lin.txt | 17 ++++-- 6 files changed, 94 insertions(+), 70 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index c4444cf6..4a8f6e0a 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -1299,9 +1299,9 @@ class GTEST_API_ UnitTest { // These classes and functions are friends as they need to access private // members of UnitTest. + friend class ScopedTrace; friend class Test; friend class internal::AssertHelper; - friend class internal::ScopedTrace; friend class internal::StreamingListenerTest; friend class internal::UnitTestRecordPropertyTestHelper; friend Environment* AddGlobalTestEnvironment(Environment* env); @@ -2102,6 +2102,57 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, #define EXPECT_NO_FATAL_FAILURE(statement) \ GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_) +// Causes a trace (including the given source file path and line number, +// and the given message) to be included in every test failure message generated +// by code in the scope of the lifetime of an instance of this class. The effect +// is undone with the destruction of the instance. +// +// The message argument can be anything streamable to std::ostream. +// +// Example: +// testing::ScopedTrace trace("file.cc", 123, "message"); +// +class GTEST_API_ ScopedTrace { + public: + // The c'tor pushes the given source file location and message onto + // a trace stack maintained by Google Test. + + // Template version. Uses Message() to convert the values into strings. + // Slow, but flexible. + template + ScopedTrace(const char* file, int line, const T& message) { + PushTrace(file, line, (Message() << message).GetString()); + } + + // Optimize for some known types. + ScopedTrace(const char* file, int line, const char* message) { + PushTrace(file, line, message ? message : "(null)"); + } + +#if GTEST_HAS_GLOBAL_STRING + ScopedTrace(const char* file, int line, const ::string& message) { + PushTrace(file, line, message); + } +#endif + + ScopedTrace(const char* file, int line, const std::string& message) { + PushTrace(file, line, message); + } + + // The d'tor pops the info pushed by the c'tor. + // + // Note that the d'tor is not virtual in order to be efficient. + // Don't inherit from ScopedTrace! + ~ScopedTrace(); + + private: + void PushTrace(const char* file, int line, std::string message); + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace); +} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its + // c'tor and d'tor. Therefore it doesn't + // need to be used otherwise. + // Causes a trace (including the source file path, the current line // number, and the given message) to be included in every test failure // message generated by code in the current scope. The effect is @@ -2118,7 +2169,7 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, // Therefore, a SCOPED_TRACE() would (correctly) only affect the // assertions in its own thread. #define SCOPED_TRACE(message) \ - ::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\ + ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\ __FILE__, __LINE__, (message)) diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 88f94c4a..843058f3 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -95,7 +95,6 @@ template namespace internal { struct TraceInfo; // Information about a trace point. -class ScopedTrace; // Implements scoped trace. class TestInfoImpl; // Opaque implementation of TestInfo class UnitTestImpl; // Opaque implementation of UnitTest @@ -151,48 +150,6 @@ class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error { #endif // GTEST_HAS_EXCEPTIONS -// A helper class for creating scoped traces in user programs. -class GTEST_API_ ScopedTrace { - public: - // The c'tor pushes the given source file location and message onto - // a trace stack maintained by Google Test. - - // Template version. Uses Message() to convert the values into strings. - // Slow, but flexible. - template - ScopedTrace(const char* file, int line, const T& message) { - PushTrace(file, line, (Message() << message).GetString()); - } - - // Optimize for some known types. - ScopedTrace(const char* file, int line, const char* message) { - PushTrace(file, line, message ? message : "(null)"); - } - -#if GTEST_HAS_GLOBAL_STRING - ScopedTrace(const char* file, int line, const ::string& message) { - PushTrace(file, line, message); - } -#endif - - ScopedTrace(const char* file, int line, const std::string& message) { - PushTrace(file, line, message); - } - - // The d'tor pops the info pushed by the c'tor. - // - // Note that the d'tor is not virtual in order to be efficient. - // Don't inherit from ScopedTrace! - ~ScopedTrace(); - - private: - void PushTrace(const char* file, int line, std::string message); - - GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace); -} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its - // c'tor and d'tor. Therefore it doesn't - // need to be used otherwise. - namespace edit_distance { // Returns the optimal edits to go from 'left' to 'right'. // All edits cost the same, with replace having lower priority than diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 0aeeb8e7..ccaf99d2 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -3835,26 +3835,6 @@ void StreamingListener::SocketWriter::MakeConnection() { // End of class Streaming Listener #endif // GTEST_CAN_STREAM_RESULTS__ -// Class ScopedTrace - -// Pushes the given source file location and message onto a per-thread -// trace stack maintained by Google Test. -void ScopedTrace::PushTrace(const char* file, int line, std::string message) { - TraceInfo trace; - trace.file = file; - trace.line = line; - trace.message.swap(message); - - UnitTest::GetInstance()->PushGTestTrace(trace); -} - -// Pops the info pushed by the c'tor. -ScopedTrace::~ScopedTrace() - GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) { - UnitTest::GetInstance()->PopGTestTrace(); -} - - // class OsStackTraceGetter const char* const OsStackTraceGetterInterface::kElidedFramesMarker = @@ -5415,4 +5395,23 @@ std::string TempDir() { #endif // GTEST_OS_WINDOWS_MOBILE } +// Class ScopedTrace + +// Pushes the given source file location and message onto a per-thread +// trace stack maintained by Google Test. +void ScopedTrace::PushTrace(const char* file, int line, std::string message) { + internal::TraceInfo trace; + trace.file = file; + trace.line = line; + trace.message.swap(message); + + UnitTest::GetInstance()->PushGTestTrace(trace); +} + +// Pops the info pushed by the c'tor. +ScopedTrace::~ScopedTrace() + GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) { + UnitTest::GetInstance()->PopGTestTrace(); +} + } // namespace testing diff --git a/googletest/test/gtest_output_test.py b/googletest/test/gtest_output_test.py index 06dbee09..78a00156 100755 --- a/googletest/test/gtest_output_test.py +++ b/googletest/test/gtest_output_test.py @@ -99,7 +99,8 @@ def RemoveLocations(test_output): 'FILE_NAME:#: '. """ - return re.sub(r'.*[/\\](.+)(\:\d+|\(\d+\))\: ', r'\1:#: ', test_output) + return re.sub(r'.*[/\\]((gtest_output_test_|gtest).cc)(\:\d+|\(\d+\))\: ', + r'\1:#: ', test_output) def RemoveStackTraceDetails(output): diff --git a/googletest/test/gtest_output_test_.cc b/googletest/test/gtest_output_test_.cc index 6aaba977..04ca5e5e 100644 --- a/googletest/test/gtest_output_test_.cc +++ b/googletest/test/gtest_output_test_.cc @@ -315,6 +315,13 @@ TEST(SCOPED_TRACETest, WorksConcurrently) { } #endif // GTEST_IS_THREADSAFE +// Tests basic functionality of the ScopedTrace utility (most of its features +// are already tested in SCOPED_TRACETest). +TEST(ScopedTraceTest, WithExplicitFileAndLine) { + testing::ScopedTrace trace("explicit_file.cc", 123, "expected trace message"); + ADD_FAILURE() << "Check that the trace is attached to a particular location."; +} + TEST(DisabledTestsWarningTest, DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning) { // This test body is intentionally empty. Its sole purpose is for diff --git a/googletest/test/gtest_output_test_golden_lin.txt b/googletest/test/gtest_output_test_golden_lin.txt index 677d9f40..48f55932 100644 --- a/googletest/test/gtest_output_test_golden_lin.txt +++ b/googletest/test/gtest_output_test_golden_lin.txt @@ -8,7 +8,7 @@ gtest_output_test_.cc:#: Failure Expected equality of these values: 2 3 -[==========] Running 66 tests from 29 test cases. +[==========] Running 67 tests from 30 test cases. [----------] Global test environment set-up. FooEnvironment::SetUp() called. BarEnvironment::SetUp() called. @@ -212,6 +212,14 @@ gtest_output_test_.cc:#: Failure Failed Expected failure #6 (in thread A, no trace alive). [ FAILED ] SCOPED_TRACETest.WorksConcurrently +[----------] 1 test from ScopedTraceTest +[ RUN ] ScopedTraceTest.WithExplicitFileAndLine +gtest_output_test_.cc:#: Failure +Failed +Check that the trace is attached to a particular location. +Google Test trace: +explicit_file.cc:123: expected trace message +[ FAILED ] ScopedTraceTest.WithExplicitFileAndLine [----------] 1 test from NonFatalFailureInFixtureConstructorTest [ RUN ] NonFatalFailureInFixtureConstructorTest.FailureInConstructor (expecting 5 failures) @@ -636,9 +644,9 @@ FooEnvironment::TearDown() called. gtest_output_test_.cc:#: Failure Failed Expected fatal failure. -[==========] 66 tests from 29 test cases ran. +[==========] 67 tests from 30 test cases ran. [ PASSED ] 22 tests. -[ FAILED ] 44 tests, listed below: +[ FAILED ] 45 tests, listed below: [ FAILED ] NonfatalFailureTest.EscapesStringOperands [ FAILED ] NonfatalFailureTest.DiffForLongStrings [ FAILED ] FatalFailureTest.FatalFailureInSubroutine @@ -651,6 +659,7 @@ Expected fatal failure. [ FAILED ] SCOPED_TRACETest.CanBeNested [ FAILED ] SCOPED_TRACETest.CanBeRepeated [ FAILED ] SCOPED_TRACETest.WorksConcurrently +[ FAILED ] ScopedTraceTest.WithExplicitFileAndLine [ FAILED ] NonFatalFailureInFixtureConstructorTest.FailureInConstructor [ FAILED ] FatalFailureInFixtureConstructorTest.FailureInConstructor [ FAILED ] NonFatalFailureInSetUpTest.FailureInSetUp @@ -684,7 +693,7 @@ Expected fatal failure. [ FAILED ] PrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2 [ FAILED ] PrintingStrings/ParamTest.Failure/a, where GetParam() = "a" -44 FAILED TESTS +45 FAILED TESTS  YOU HAVE 1 DISABLED TEST Note: Google Test filter = FatalFailureTest.*:LoggingTest.* From 354fc8d8b1889b580f46416c9bbdf5ed8453156f Mon Sep 17 00:00:00 2001 From: Fedor Trushkin Date: Thu, 18 Jan 2018 10:34:05 +0100 Subject: [PATCH 15/17] Document ScopedTrace utility --- googletest/docs/AdvancedGuide.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/googletest/docs/AdvancedGuide.md b/googletest/docs/AdvancedGuide.md index e4dd94de..6c156bbe 100644 --- a/googletest/docs/AdvancedGuide.md +++ b/googletest/docs/AdvancedGuide.md @@ -787,15 +787,17 @@ If a test sub-routine is called from several places, when an assertion inside it fails, it can be hard to tell which invocation of the sub-routine the failure is from. You can alleviate this problem using extra logging or custom failure messages, but that usually clutters up -your tests. A better solution is to use the `SCOPED_TRACE` macro: +your tests. A better solution is to use the `SCOPED_TRACE` macro or +the `ScopedTrace` utility: -| `SCOPED_TRACE(`_message_`);` | -|:-----------------------------| +| `SCOPED_TRACE(`_message_`);` | `ScopedTrace trace(`_"file\_path"_`, `_line\_number_`, `_message_`);` | +|:-----------------------------|:----------------------------------------------------------------------| -where _message_ can be anything streamable to `std::ostream`. This -macro will cause the current file name, line number, and the given -message to be added in every failure message. The effect will be -undone when the control leaves the current lexical scope. +where `message` can be anything streamable to `std::ostream`. `SCOPED_TRACE` +macro will cause the current file name, line number, and the given message to be +added in every failure message. `ScopedTrace` accepts explicit file name and +line number in arguments, which is useful for writing test helpers. The effect +will be undone when the control leaves the current lexical scope. For example, From 8e862211a24804d6635adc867f9b9199220e1128 Mon Sep 17 00:00:00 2001 From: Fedor Trushkin Date: Thu, 18 Jan 2018 10:38:25 +0100 Subject: [PATCH 16/17] Use fully qualified in examples --- googletest/docs/AdvancedGuide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/docs/AdvancedGuide.md b/googletest/docs/AdvancedGuide.md index 6c156bbe..ccb087c0 100644 --- a/googletest/docs/AdvancedGuide.md +++ b/googletest/docs/AdvancedGuide.md @@ -790,8 +790,8 @@ extra logging or custom failure messages, but that usually clutters up your tests. A better solution is to use the `SCOPED_TRACE` macro or the `ScopedTrace` utility: -| `SCOPED_TRACE(`_message_`);` | `ScopedTrace trace(`_"file\_path"_`, `_line\_number_`, `_message_`);` | -|:-----------------------------|:----------------------------------------------------------------------| +| `SCOPED_TRACE(`_message_`);` | `::testing::ScopedTrace trace(`_"file\_path"_`, `_line\_number_`, `_message_`);` | +|:-----------------------------|:---------------------------------------------------------------------------------| where `message` can be anything streamable to `std::ostream`. `SCOPED_TRACE` macro will cause the current file name, line number, and the given message to be From b1623e914474277bfe7a0ae31374ff9b33ce5c77 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Thu, 18 Jan 2018 14:32:31 -0500 Subject: [PATCH 17/17] Adding python tests to Bazel build file. --- googletest/test/BUILD.bazel | 244 +++++++++++++++++++++++++++++++++++- 1 file changed, 243 insertions(+), 1 deletion(-) diff --git a/googletest/test/BUILD.bazel b/googletest/test/BUILD.bazel index 62b88da4..3c700b15 100644 --- a/googletest/test/BUILD.bazel +++ b/googletest/test/BUILD.bazel @@ -1,4 +1,4 @@ -# Copyright 2017 Google Inc. +# Copyright 2017 Google Inc. # All Rights Reserved. # # @@ -119,3 +119,245 @@ cc_test( "//:gtest", ], ) +# Py tests + +py_library( + name = "gtest_test_utils", + testonly = 1, + srcs = ["gtest_test_utils.py"], + +) + +cc_binary( + name = "gtest_help_test_", + testonly = 1, + srcs = ["gtest_help_test_.cc"], + deps = ["//:gtest_main"], +) +py_test( + name = "gtest_help_test", + size = "small", + srcs = ["gtest_help_test.py"], + data = [":gtest_help_test_"], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_output_test_", + testonly = 1, + srcs = ["gtest_output_test_.cc"], + deps = ["//:gtest"], +) + +py_test( + name = "gtest_output_test", + size = "small", + srcs = ["gtest_output_test.py"], + data = [ + "gtest_output_test_golden_lin.txt", + ":gtest_output_test_", + ], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_color_test_", + testonly = 1, + srcs = ["gtest_color_test_.cc"], + deps = ["//:gtest"], +) +py_test( + name = "gtest_color_test", + size = "small", + srcs = ["gtest_color_test.py"], + data = [":gtest_color_test_"], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_env_var_test_", + testonly = 1, + srcs = ["gtest_env_var_test_.cc"], + deps = ["//:gtest"], +) + +py_test( + name = "gtest_env_var_test", + size = "small", + srcs = ["gtest_env_var_test.py"], + data = [":gtest_env_var_test_"], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_filter_unittest_", + testonly = 1, + srcs = ["gtest_filter_unittest_.cc"], + deps = ["//:gtest"], +) + +py_test( + name = "gtest_filter_unittest", + size = "small", + srcs = ["gtest_filter_unittest.py"], + data = [":gtest_filter_unittest_"], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_break_on_failure_unittest_", + testonly = 1, + srcs = ["gtest_break_on_failure_unittest_.cc"], + deps = ["//:gtest"], +) + +py_test( + name = "gtest_break_on_failure_unittest", + size = "small", + srcs = ["gtest_break_on_failure_unittest.py"], + data = [":gtest_break_on_failure_unittest_"], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_throw_on_failure_test_", + testonly = 1, + srcs = ["gtest_throw_on_failure_test_.cc"], + deps = ["//:gtest"], +) + +py_test( + name = "gtest_throw_on_failure_test", + size = "small", + srcs = ["gtest_throw_on_failure_test.py"], + data = [":gtest_throw_on_failure_test_"], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_list_tests_unittest_", + testonly = 1, + srcs = ["gtest_list_tests_unittest_.cc"], + deps = ["//:gtest"], +) + +py_test( + name = "gtest_list_tests_unittest", + size = "small", + srcs = ["gtest_list_tests_unittest.py"], + data = [":gtest_list_tests_unittest_"], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_shuffle_test_", + srcs = ["gtest_shuffle_test_.cc"], + deps = ["//:gtest"], +) + +py_test( + name = "gtest_shuffle_test", + size = "small", + srcs = ["gtest_shuffle_test.py"], + data = [":gtest_shuffle_test_"], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_catch_exceptions_no_ex_test_", + testonly = 1, + srcs = ["gtest_catch_exceptions_test_.cc"], + deps = ["//:gtest_main"], +) + +cc_binary( + name = "gtest_catch_exceptions_ex_test_", + testonly = 1, + srcs = ["gtest_catch_exceptions_test_.cc"], + copts = ["-fexceptions"], + deps = ["//:gtest_main"], +) + +py_test( + name = "gtest_catch_exceptions_test", + size = "small", + srcs = ["gtest_catch_exceptions_test.py"], + data = [ + ":gtest_catch_exceptions_ex_test_", + ":gtest_catch_exceptions_no_ex_test_", + ], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_xml_output_unittest_", + testonly = 1, + srcs = ["gtest_xml_output_unittest_.cc"], + deps = ["//:gtest"], +) + +cc_test( + name = "gtest_no_test_unittest", + size = "small", + srcs = ["gtest_no_test_unittest.cc"], + deps = ["//:gtest"], +) + +py_test( + name = "gtest_xml_output_unittest", + size = "small", + srcs = [ + "gtest_xml_output_unittest.py", + "gtest_xml_test_utils.py", + ], + data = [ + # We invoke gtest_no_test_unittest to verify the XML output + # when the test program contains no test definition. + ":gtest_no_test_unittest", + ":gtest_xml_output_unittest_", + ], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_xml_outfile1_test_", + testonly = 1, + srcs = ["gtest_xml_outfile1_test_.cc"], + deps = ["//:gtest_main"], +) + +cc_binary( + name = "gtest_xml_outfile2_test_", + testonly = 1, + srcs = ["gtest_xml_outfile2_test_.cc"], + deps = ["//:gtest_main"], +) + +py_test( + name = "gtest_xml_outfiles_test", + size = "small", + srcs = [ + "gtest_xml_outfiles_test.py", + "gtest_xml_test_utils.py", + ], + data = [ + ":gtest_xml_outfile1_test_", + ":gtest_xml_outfile2_test_", + ], + deps = [":gtest_test_utils"], +) + +cc_binary( + name = "gtest_uninitialized_test_", + testonly = 1, + srcs = ["gtest_uninitialized_test_.cc"], + deps = ["//:gtest"], +) + +py_test( + name = "gtest_uninitialized_test", + size = "medium", + srcs = ["gtest_uninitialized_test.py"], + data = [":gtest_uninitialized_test_"], + deps = [":gtest_test_utils"], +)