From f6f673710b19cf39630c4745a14101f9349fcc72 Mon Sep 17 00:00:00 2001 From: RedMarcher Date: Thu, 21 Nov 2024 20:37:03 +0000 Subject: [PATCH] Created new flag for machine result feature --- googletest/include/gtest/gtest.h | 4 ++++ googletest/src/gtest-internal-inl.h | 9 ++++++--- googletest/src/gtest.cc | 23 +++++++++++++++-------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index c8996695..59025d20 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -152,6 +152,10 @@ GTEST_DECLARE_int32_(stack_trace_depth); // non-zero code otherwise. For use with an external test framework. GTEST_DECLARE_bool_(throw_on_failure); +// When this flag is set, results are streamed to stdout +// without pretty-print formatting +GTEST_DECLARE_bool_(machine_results); + // When this flag is set with a "host:port" string, on supported // platforms test results are streamed to the specified port on // the specified host machine. diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index cc6f0048..fa9ab6dc 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -162,8 +162,9 @@ class GTestFlagSaver { GTEST_FLAG_GET(recreate_environments_when_repeating); shuffle_ = GTEST_FLAG_GET(shuffle); stack_trace_depth_ = GTEST_FLAG_GET(stack_trace_depth); - stream_result_to_ = GTEST_FLAG_GET(stream_result_to); throw_on_failure_ = GTEST_FLAG_GET(throw_on_failure); + machine_results_ = GTEST_FLAG_GET(machine_results); + stream_result_to_ = GTEST_FLAG_GET(stream_result_to); } // The d'tor is not virtual. DO NOT INHERIT FROM THIS CLASS. @@ -188,8 +189,9 @@ class GTestFlagSaver { recreate_environments_when_repeating_); GTEST_FLAG_SET(shuffle, shuffle_); GTEST_FLAG_SET(stack_trace_depth, stack_trace_depth_); - GTEST_FLAG_SET(stream_result_to, stream_result_to_); GTEST_FLAG_SET(throw_on_failure, throw_on_failure_); + GTEST_FLAG_SET(machine_results, machine_results_); + GTEST_FLAG_SET(stream_result_to, stream_result_to_); } private: @@ -213,8 +215,9 @@ class GTestFlagSaver { bool recreate_environments_when_repeating_; bool shuffle_; int32_t stack_trace_depth_; - std::string stream_result_to_; bool throw_on_failure_; + bool machine_results_; + std::string stream_result_to_; }; // Converts a Unicode code point to a narrow string in UTF-8 encoding. diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index c08ab419..0153ecac 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -374,13 +374,6 @@ GTEST_DEFINE_int32_( "The maximum number of stack frames to print when an " "assertion fails. The valid range is 0 through 100, inclusive."); -GTEST_DEFINE_string_( - stream_result_to, - testing::internal::StringFromGTestEnv("stream_result_to", ""), - "This flag specifies the host name and the port number on which to stream " - "test results. Example: \"localhost:555\". The flag is effective only on " - "Linux and macOS."); - GTEST_DEFINE_bool_( throw_on_failure, testing::internal::BoolFromGTestEnv("throw_on_failure", false), @@ -388,6 +381,19 @@ GTEST_DEFINE_bool_( "if exceptions are enabled or exit the program with a non-zero code " "otherwise. For use with an external test framework."); +GTEST_DEFINE_bool_( + machine_results, + testing::internal::BoolFromGTestEnv("machine_results", false), + "When this flag is specified, results are streamed to stdout " + "without pretty-printing. Uses the same format as stream_result_to"); + +GTEST_DEFINE_string_( + stream_result_to, + testing::internal::StringFromGTestEnv("stream_result_to", ""), + "This flag specifies the host name and the port number on which to stream " + "test results. Example: \"localhost:555\". The flag is effective only on " + "Linux and macOS."); + #if GTEST_USE_OWN_FLAGFILE_FLAG_ GTEST_DEFINE_string_( flagfile, testing::internal::StringFromGTestEnv("flagfile", ""), @@ -6667,8 +6673,9 @@ static bool ParseGoogleTestFlag(const char* const arg) { GTEST_INTERNAL_PARSE_FLAG(recreate_environments_when_repeating); GTEST_INTERNAL_PARSE_FLAG(shuffle); GTEST_INTERNAL_PARSE_FLAG(stack_trace_depth); - GTEST_INTERNAL_PARSE_FLAG(stream_result_to); GTEST_INTERNAL_PARSE_FLAG(throw_on_failure); + GTEST_INTERNAL_PARSE_FLAG(machine_results); + GTEST_INTERNAL_PARSE_FLAG(stream_result_to); return false; }