Skip to content

Commit 31993df

Browse files
Abseil Teamcopybara-github
Abseil Team
authored andcommitted
Revert Optimize Google Test process startup
PiperOrigin-RevId: 612878184 Change-Id: Ia8e23da1ad09c2e0ce635a855f0c250f368f6878
1 parent b9059aa commit 31993df

File tree

6 files changed

+162
-160
lines changed

6 files changed

+162
-160
lines changed

googletest/include/gtest/gtest.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,15 @@ class GTEST_API_ TestInfo {
607607
friend class internal::UnitTestImpl;
608608
friend class internal::StreamingListenerTest;
609609
friend TestInfo* internal::MakeAndRegisterTestInfo(
610-
std::string test_suite_name, const char* name, const char* type_param,
610+
const char* test_suite_name, const char* name, const char* type_param,
611611
const char* value_param, internal::CodeLocation code_location,
612612
internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,
613613
internal::TearDownTestSuiteFunc tear_down_tc,
614614
internal::TestFactoryBase* factory);
615615

616616
// Constructs a TestInfo object. The newly constructed instance assumes
617617
// ownership of the factory object.
618-
TestInfo(std::string test_suite_name, std::string name,
618+
TestInfo(const std::string& test_suite_name, const std::string& name,
619619
const char* a_type_param, // NULL if not a type-parameterized test
620620
const char* a_value_param, // NULL if not a value-parameterized test
621621
internal::CodeLocation a_code_location,
@@ -683,7 +683,7 @@ class GTEST_API_ TestSuite {
683683
// this is not a type-parameterized test.
684684
// set_up_tc: pointer to the function that sets up the test suite
685685
// tear_down_tc: pointer to the function that tears down the test suite
686-
TestSuite(const std::string& name, const char* a_type_param,
686+
TestSuite(const char* name, const char* a_type_param,
687687
internal::SetUpTestSuiteFunc set_up_tc,
688688
internal::TearDownTestSuiteFunc tear_down_tc);
689689

googletest/include/gtest/internal/gtest-filepath.h

+1-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
4444

4545
#include <string>
46-
#include <utility>
4746

4847
#include "gtest/internal/gtest-port.h"
4948
#include "gtest/internal/gtest-string.h"
@@ -71,20 +70,15 @@ class GTEST_API_ FilePath {
7170
public:
7271
FilePath() : pathname_("") {}
7372
FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {}
74-
FilePath(FilePath&& rhs) : pathname_(std::move(rhs.pathname_)) {}
7573

76-
explicit FilePath(std::string pathname) : pathname_(std::move(pathname)) {
74+
explicit FilePath(const std::string& pathname) : pathname_(pathname) {
7775
Normalize();
7876
}
7977

8078
FilePath& operator=(const FilePath& rhs) {
8179
Set(rhs);
8280
return *this;
8381
}
84-
FilePath& operator=(FilePath&& rhs) {
85-
pathname_ = std::move(rhs.pathname_);
86-
return *this;
87-
}
8882

8983
void Set(const FilePath& rhs) { pathname_ = rhs.pathname_; }
9084

googletest/include/gtest/internal/gtest-internal.h

+17-12
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,8 @@ using SetUpTestSuiteFunc = void (*)();
474474
using TearDownTestSuiteFunc = void (*)();
475475

476476
struct CodeLocation {
477-
CodeLocation(std::string a_file, int a_line)
478-
: file(std::move(a_file)), line(a_line) {}
477+
CodeLocation(const std::string& a_file, int a_line)
478+
: file(a_file), line(a_line) {}
479479

480480
std::string file;
481481
int line;
@@ -564,7 +564,7 @@ struct SuiteApiResolver : T {
564564
// The newly created TestInfo instance will assume
565565
// ownership of the factory object.
566566
GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
567-
std::string test_suite_name, const char* name, const char* type_param,
567+
const char* test_suite_name, const char* name, const char* type_param,
568568
const char* value_param, CodeLocation code_location,
569569
TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
570570
TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory);
@@ -595,7 +595,8 @@ class GTEST_API_ TypedTestSuitePState {
595595
fflush(stderr);
596596
posix::Abort();
597597
}
598-
registered_tests_.emplace(test_name, CodeLocation(file, line));
598+
registered_tests_.insert(
599+
::std::make_pair(test_name, CodeLocation(file, line)));
599600
return true;
600601
}
601602

@@ -699,7 +700,7 @@ class TypeParameterizedTest {
699700
// specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite,
700701
// Types). Valid values for 'index' are [0, N - 1] where N is the
701702
// length of Types.
702-
static bool Register(const char* prefix, CodeLocation code_location,
703+
static bool Register(const char* prefix, const CodeLocation& code_location,
703704
const char* case_name, const char* test_names, int index,
704705
const std::vector<std::string>& type_names =
705706
GenerateNames<DefaultNameGenerator, Types>()) {
@@ -711,7 +712,8 @@ class TypeParameterizedTest {
711712
// list.
712713
MakeAndRegisterTestInfo(
713714
(std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name +
714-
"/" + type_names[static_cast<size_t>(index)]),
715+
"/" + type_names[static_cast<size_t>(index)])
716+
.c_str(),
715717
StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
716718
GetTypeName<Type>().c_str(),
717719
nullptr, // No value parameter.
@@ -723,17 +725,21 @@ class TypeParameterizedTest {
723725
new TestFactoryImpl<TestClass>);
724726

725727
// Next, recurses (at compile time) with the tail of the type list.
726-
return TypeParameterizedTest<Fixture, TestSel, typename Types::Tail>::
727-
Register(prefix, std::move(code_location), case_name, test_names,
728-
index + 1, type_names);
728+
return TypeParameterizedTest<Fixture, TestSel,
729+
typename Types::Tail>::Register(prefix,
730+
code_location,
731+
case_name,
732+
test_names,
733+
index + 1,
734+
type_names);
729735
}
730736
};
731737

732738
// The base case for the compile time recursion.
733739
template <GTEST_TEMPLATE_ Fixture, class TestSel>
734740
class TypeParameterizedTest<Fixture, TestSel, internal::None> {
735741
public:
736-
static bool Register(const char* /*prefix*/, CodeLocation,
742+
static bool Register(const char* /*prefix*/, const CodeLocation&,
737743
const char* /*case_name*/, const char* /*test_names*/,
738744
int /*index*/,
739745
const std::vector<std::string>& =
@@ -780,8 +786,7 @@ class TypeParameterizedTestSuite {
780786

781787
// Next, recurses (at compile time) with the tail of the test list.
782788
return TypeParameterizedTestSuite<Fixture, typename Tests::Tail,
783-
Types>::Register(prefix,
784-
std::move(code_location),
789+
Types>::Register(prefix, code_location,
785790
state, case_name,
786791
SkipComma(test_names),
787792
type_names);

0 commit comments

Comments
 (0)