diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index ae6b87e4ad..f858141977 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -394,10 +394,6 @@ class CommandLineInterface::ErrorPrinter std::ostream& out) { std::string dfile; if ( -#ifndef PROTOBUF_OPENSOURCE - // Print full path when running under MSVS - format_ == CommandLineInterface::ERROR_FORMAT_MSVS && -#endif // !PROTOBUF_OPENSOURCE tree_ != nullptr && tree_->VirtualFileToDiskFile(filename, &dfile)) { out << dfile; } else { diff --git a/src/google/protobuf/compiler/command_line_interface_tester.cc b/src/google/protobuf/compiler/command_line_interface_tester.cc index 1586ee1df6..e965d27348 100644 --- a/src/google/protobuf/compiler/command_line_interface_tester.cc +++ b/src/google/protobuf/compiler/command_line_interface_tester.cc @@ -122,8 +122,8 @@ void CommandLineInterfaceTester::ExpectNoErrors() { void CommandLineInterfaceTester::ExpectErrorText( absl::string_view expected_text) { EXPECT_NE(0, return_code_); - EXPECT_EQ(absl::StrReplaceAll(expected_text, {{"$tmpdir", temp_directory_}}), - error_text_); + EXPECT_THAT(error_text_, HasSubstr(absl::StrReplaceAll( + expected_text, {{"$tmpdir", temp_directory_}}))); } void CommandLineInterfaceTester::ExpectErrorSubstring( diff --git a/src/google/protobuf/compiler/command_line_interface_tester.h b/src/google/protobuf/compiler/command_line_interface_tester.h index b77dfa32b9..5f428c8193 100644 --- a/src/google/protobuf/compiler/command_line_interface_tester.h +++ b/src/google/protobuf/compiler/command_line_interface_tester.h @@ -25,6 +25,7 @@ #include "absl/strings/string_view.h" #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/command_line_interface.h" +#include "google/protobuf/testing/file.h" // Must be included last. #include "google/protobuf/port_def.inc" @@ -76,12 +77,10 @@ class CommandLineInterfaceTester : public testing::Test { // Creates a subdirectory within temp_directory_. void CreateTempDir(absl::string_view name); -#ifdef PROTOBUF_OPENSOURCE // Changes working directory to temp directory. void SwitchToTempDirectory() { File::ChangeWorkingDirectory(temp_directory_); } -#endif // !PROTOBUF_OPENSOURCE // ----------------------------------------------------------------- // Methods to check the test results (called after Run()). diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 787d56fbf0..436e8ce760 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -2618,7 +2618,6 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileGivenTwoInputs) { "Can only process one input file when using --dependency_out=FILE.\n"); } -#ifdef PROTOBUF_OPENSOURCE TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFile) { CreateTempFile("foo.proto", "syntax = \"proto2\";\n" @@ -2630,7 +2629,8 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFile) { " optional Foo foo = 1;\n" "}\n"); - std::string current_working_directory = getcwd(nullptr, 0); + char current_dir[PATH_MAX]; + ASSERT_EQ(getcwd(current_dir, sizeof(current_dir)), current_dir); SwitchToTempDirectory(); Run("protocol_compiler --dependency_out=manifest --test_out=. " @@ -2642,12 +2642,8 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFile) { "bar.proto.MockCodeGenerator.test_generator: " "foo.proto\\\n bar.proto"); - File::ChangeWorkingDirectory(current_working_directory); + File::ChangeWorkingDirectory(current_dir); } -#else // !PROTOBUF_OPENSOURCE -// TODO: Figure out how to change and get working directory in -// google3. -#endif // !PROTOBUF_OPENSOURCE TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileForAbsolutePath) { CreateTempFile("foo.proto", @@ -2771,9 +2767,12 @@ TEST_F(CommandLineInterfaceTest, ParseErrorsMultipleFiles) { "--proto_path=$tmpdir foo.proto"); ExpectErrorText( - "bar.proto:2:1: Expected top-level statement (e.g. \"message\").\n" - "baz.proto:2:1: Import \"bar.proto\" was not found or had errors.\n" - "foo.proto:2:1: Import \"bar.proto\" was not found or had errors.\n" + "bar.proto:2:1: Expected top-level statement (e.g. \"message\").\n"); + ExpectErrorText( + "baz.proto:2:1: Import \"bar.proto\" was not found or had errors.\n"); + ExpectErrorText( + "foo.proto:2:1: Import \"bar.proto\" was not found or had errors.\n"); + ExpectErrorText( "foo.proto:3:1: Import \"baz.proto\" was not found or had errors.\n"); } diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index cd1ad9846c..58c5c2bddd 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -1206,11 +1206,6 @@ PROTOBUF_ALWAYS_INLINE inline MessageLite* MessageCreator::PlacementNew( // - We know the minimum size is 16. We have a fallback for when it is not. // - We can "underflow" the buffer because those are the MessageLite bytes // we will set later. -#ifndef PROTO2_OPENSOURCE - // This manual handling shows a 1.85% improvement in the parsing - // microbenchmark. - // TODO: Verify this is still the case. -#endif // !PROTO2_OPENSOUCE if (as_tag == kZeroInit) { // Make sure the input is really all zeros. ABSL_DCHECK(std::all_of(src + sizeof(MessageLite), src + size, diff --git a/src/google/protobuf/testing/file.cc b/src/google/protobuf/testing/file.cc index 277e0f23d4..a75872c528 100644 --- a/src/google/protobuf/testing/file.cc +++ b/src/google/protobuf/testing/file.cc @@ -196,8 +196,8 @@ void File::DeleteRecursively(const std::string& name, void* dummy1, #endif } -bool File::ChangeWorkingDirectory(const std::string& new_working_directory) { - return chdir(new_working_directory.c_str()) == 0; +bool File::ChangeWorkingDirectory(absl::string_view new_working_directory) { + return chdir(new_working_directory.data()) == 0; } } // namespace protobuf diff --git a/src/google/protobuf/testing/file.h b/src/google/protobuf/testing/file.h index 74dfdbf98a..7cfc7d2197 100644 --- a/src/google/protobuf/testing/file.h +++ b/src/google/protobuf/testing/file.h @@ -63,7 +63,7 @@ class File { void* dummy2); // Change working directory to given directory. - static bool ChangeWorkingDirectory(const std::string& new_working_directory); + static bool ChangeWorkingDirectory(absl::string_view new_working_directory); static absl::Status GetContents(const std::string& name, std::string* output, bool /*is_default*/) {