protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.57k stars 15.48k forks source link

Google_protobuf failed to run the TextFormatMapTest.DynamicMessage with release configuration and debug configuration #5136

Closed spacelg closed 3 years ago

spacelg commented 6 years ago

Environment: Windows Server 2016 + VS2017 Update 5 + Google_protobuf master branch latest srouce code

Google_protobuf failed to run the TextFormatMapTest.DynamicMessage with release configuration and debug configuration. Could you please help take a look at this? Thanks in advance!

What did you do? Steps to reproduce the behavior: 1.git clone https://github.com/google/protobuf.git D:\Google-Protobuf\src 2.Open a VS 2017 command prompt and browse to D:\Google-Protobuf 3.build_x64_ltcg && pushd build_x64_ltcg 4.cmake -G "Visual Studio 15 2017" -DCMAKE_SYSTEM_VERSION=10.0.16299.0 ..\src\cmake 5.popd 6.msbuild /p:Configuration=Debug\;Platform=x64 build_x64\protobuf.sln /t:Rebuild 7.pushd src

  1. ..\build_x64_ltcg\Debug\tests.exe --gtest_filter=TextFormatMapTest.DynamicMessage

Actual result: [ FAILED ] 1 test, listed below: [ FAILED ] TextFormatMapTest.DynamicMessage log_x64_ltcg_test_1.log

TestErrorMessage: [----------] Global test environment tear-down [==========] 2002 tests from 188 test cases ran. (15077 ms total) [ PASSED ] 2001 tests. [ FAILED ] 1 test, listed below: [ FAILED ] TextFormatMapTest.DynamicMessage 1 FAILED TEST [command took 15 seconds]

SirCosty commented 5 years ago

Have the same problem here Maybe after 1+ year they will solve it?

jozefizso commented 4 years ago

This issue is still present:

[----------] Global test environment tear-down
[==========] 2110 tests from 195 test suites ran. (79097 ms total)
[  PASSED  ] 2109 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] TextFormatMapTest.DynamicMessage
FransM commented 4 years ago

I can confirm the issue with 3.11.4 and visual studio 2017. It is a line ending issue. In the expected output are additional \r characters that are not in the received output. See below

9>E:\protobuf_3.11.4_32\protobuf\src\google\protobuf\map_test.cc(3271): error : Expected equality of these values: 9> message->DebugString() 9> Which is: "map_int32_int32 {\n key: 0\n value: 0\n}\nmap_int32_int32 {\n key: 1\n value: 1\n}\nmap_int64_int64 {\n key: 0\n value: 0\n}\nmap_int64_int64 {\n key: 1\n value: 1\n}\nmap_uint32_uint32 {\n key: 0\n value: 0\n}\nmap_uint32_uint32 {\n key: 1\n value: 1\n}\nmap_uint64_uint64 {\n key: 0\n value: 0\n}\nmap_uint64_uint64 {\n key: 1\n value: 1\n}\nmap_sint32_sint32 {\n key: 0\n value: 0\n}\nmap_sint32_sint32 {\n key: 1\n value: 1\n}\nmap_sint64_sint64 {\n key: 0\n value: 0\n}\nmap_sint64_sint64 {\n key: 1\n value: 1\n}\nmap_fixed32_fixed32 {\n key: 0\n value: 0\n}\nmap_fixed32_fixed32 {\n key: 1\n value: 1\n}\nmap_fixed64_fixed64 {\n key: 0\n value: 0\n}\nmap_fixed64_fixed64 {\n key: 1\n value: 1\n}\nmap_sfixed32_sfixed32 {\n key: 0\n value: 0\n}\nmap_sfixed32_sfixed32 {\n key: 1\n value: 1\n}\nmap_sfixed64_sfixed64 {\n key: 0\n value: 0\n}\nmap_sfixed64_sfixed64 {\n key: 1\n value: 1\n}\nmap_int32_float {\n key: 0\n value: 0\n}\nmap_int32_float {\n key: 1\n value: 1\n}\nmap_int32_double {\n key: 0\n value: 0\n}\nmap_int32_double {\n key: 1\n value: 1\n}\nmap_bool_bool {\n key: false\n value: false\n}\nmap_bool_bool {\n key: true\n value: true\n}\nmap_string_string {\n key: \"0\"\n value: \"0\"\n}\nmap_string_string {\n key: \"1\"\n value: \"1\"\n}\nmap_int32_bytes {\n key: 0\n value: \"0\"\n}\nmap_int32_bytes {\n key: 1\n value: \"1\"\n}\nmap_int32_enum {\n key: 0\n value: MAP_ENUM_BAR\n}\nmap_int32_enum {\n key: 1\n value: MAP_ENUM_BAZ\n}\nmap_int32_foreign_message {\n key: 0\n value {\n c: 0\n }\n}\nmap_int32_foreign_message {\n key: 1\n value {\n c: 1\n }\n}\n" 9> expected_text 9> Which is: "map_int32_int32 {\r\n key: 0\r\n value: 0\r\n}\r\nmap_int32_int32 {\r\n key: 1\r\n value: 1\r\n}\r\nmap_int64_int64 {\r\n key: 0\r\n value: 0\r\n}\r\nmap_int64_int64 {\r\n key: 1\r\n value: 1\r\n}\r\nmap_uint32_uint32 {\r\n key: 0\r\n value: 0\r\n}\r\nmap_uint32_uint32 {\r\n key: 1\r\n value: 1\r\n}\r\nmap_uint64_uint64 {\r\n key: 0\r\n value: 0\r\n}\r\nmap_uint64_uint64 {\r\n key: 1\r\n value: 1\r\n}\r\nmap_sint32_sint32 {\r\n key: 0\r\n value: 0\r\n}\r\nmap_sint32_sint32 {\r\n key: 1\r\n value: 1\r\n}\r\nmap_sint64_sint64 {\r\n key: 0\r\n value: 0\r\n}\r\nmap_sint64_sint64 {\r\n key: 1\r\n value: 1\r\n}\r\nmap_fixed32_fixed32 {\r\n key: 0\r\n value: 0\r\n}\r\nmap_fixed32_fixed32 {\r\n key: 1\r\n value: 1\r\n}\r\nmap_fixed64_fixed64 {\r\n key: 0\r\n value: 0\r\n}\r\nmap_fixed64_fixed64 {\r\n key: 1\r\n value: 1\r\n}\r\nmap_sfixed32_sfixed32 {\r\n key: 0\r\n value: 0\r\n}\r\nmap_sfixed32_sfixed32 {\r\n key: 1\r\n value: 1\r\n}\r\nmap_sfixed64_sfixed64 {\r\n key: 0\r\n value: 0\r\n}\r\nmap_sfixed64_sfixed64 {\r\n key: 1\r\n value: 1\r\n}\r\nmap_int32_float {\r\n key: 0\r\n value: 0\r\n}\r\nmap_int32_float {\r\n key: 1\r\n value: 1\r\n}\r\nmap_int32_double {\r\n key: 0\r\n value: 0\r\n}\r\nmap_int32_double {\r\n key: 1\r\n value: 1\r\n}\r\nmap_bool_bool {\r\n key: false\r\n value: false\r\n}\r\nmap_bool_bool {\r\n key: true\r\n value: true\r\n}\r\nmap_string_string {\r\n key: \"0\"\r\n value: \"0\"\r\n}\r\nmap_string_string {\r\n key: \"1\"\r\n value: \"1\"\r\n}\r\nmap_int32_bytes {\r\n key: 0\r\n value: \"0\"\r\n}\r\nmap_int32_bytes {\r\n key: 1\r\n value: \"1\"\r\n}\r\nmap_int32_enum {\r\n key: 0\r\n value: MAP_ENUM_BAR\r\n}\r\nmap_int32_enum {\r\n key: 1\r\n value: MAP_ENUM_BAZ\r\n}\r\nmap_int32_foreign_message {\r\n key: 0\r\n value {\r\n c: 0\r\n }\r\n}\r\nmap_int32_foreign_message {\r\n key: 1\r\n value {\r\n c: 1\r\n }\r\n}\r\n"

cqjjjzr commented 4 years ago

This is due to the line endings when commiting on Windows with autocrlf = true settings in Git. The Git will automatically convert the src/google/protobuf/testdata/map_test_data.txt to use CRLF line endings. However, in the code the generated data to compare against expected data (read directly from map_test_data.txt) uses LF line endings, leading to the error.

Temporary workaround:

  1. Create .gitattributes in the project root directory with contents below:
    # Text data.
    *.txt text eol=lf
  2. Delete src/google/protobuf/testdata/map_test_data.txt
  3. Use git checkout or git reset to re-checkout the repository.

Then, the map_test_data.txt will be checked out with LF line endings. You can check it with notepad3 or other tools.

A better solution may be to ignore line endings in the test code.

elharo commented 3 years ago

fixed