aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
index 4e150fe3..a19ad595 100644
--- a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
-// This test insures that google/protobuf/descriptor.pb.{h,cc} match exactly
+// This test insures that net/proto2/proto/descriptor.pb.{h,cc} match exactly
// what would be generated by the protocol compiler. These files are not
// generated automatically at build time because they are compiled into the
// protocol compiler itself. So, if they were auto-generated, you'd have a
@@ -47,8 +47,10 @@
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_generator.h>
#include <google/protobuf/compiler/importer.h>
+#include <google/protobuf/test_util2.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/stl_util.h>
@@ -83,9 +85,7 @@ class MockErrorCollector : public MultiFileErrorCollector {
class MockGeneratorContext : public GeneratorContext {
public:
MockGeneratorContext() {}
- ~MockGeneratorContext() {
- STLDeleteValues(&files_);
- }
+ ~MockGeneratorContext() { STLDeleteValues(&files_); }
void ExpectFileMatches(const string& virtual_filename,
const string& physical_filename) {
@@ -95,9 +95,18 @@ class MockGeneratorContext : public GeneratorContext {
string actual_contents;
GOOGLE_CHECK_OK(
- File::GetContents(TestSourceDir() + "/" + physical_filename,
- &actual_contents, true));
- EXPECT_TRUE(actual_contents == *expected_contents)
+ File::GetContents(TestUtil::TestSourceDir() + "/" + physical_filename,
+ &actual_contents, true))
+ << physical_filename;
+ CleanStringLineEndings(&actual_contents, false);
+
+#ifdef WRITE_FILES // Define to debug mismatched files.
+ GOOGLE_CHECK_OK(
+ File::SetContents("/tmp/1.cc", *expected_contents, true));
+ GOOGLE_CHECK_OK(File::SetContents("/tmp/2.cc", actual_contents, true));
+#endif
+
+ EXPECT_EQ(*expected_contents, actual_contents)
<< physical_filename
<< " needs to be regenerated. Please run "
"generate_descriptor_proto.sh. "
@@ -118,8 +127,8 @@ class MockGeneratorContext : public GeneratorContext {
std::map<string, string*> files_;
};
-const char kDescriptorParameter[] = "dllexport_decl=LIBPROTOBUF_EXPORT";
-const char kPluginParameter[] = "dllexport_decl=LIBPROTOC_EXPORT";
+const char kDescriptorParameter[] = "dllexport_decl=PROTOBUF_EXPORT";
+const char kPluginParameter[] = "dllexport_decl=PROTOC_EXPORT";
const char kNormalParameter[] = "";
const char* test_protos[][2] = {
@@ -136,11 +145,11 @@ TEST(BootstrapTest, GeneratedFilesMatch) {
"net/proto2/z_generated_example/test_messages_proto2";
rpath_map["third_party/protobuf/src/google/protobuf/test_messages_proto3"] =
"net/proto2/z_generated_example/test_messages_proto3";
- rpath_map["google/protobuf/proto2_weak"] =
+ rpath_map["net/proto2/internal/proto2_weak"] =
"net/proto2/z_generated_example/proto2_weak";
DiskSourceTree source_tree;
- source_tree.MapPath("", TestSourceDir());
+ source_tree.MapPath("", TestUtil::TestSourceDir());
for (auto file_parameter : test_protos) {
MockErrorCollector error_collector;