Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
656f64ec
Unverified
Commit
656f64ec
authored
Jul 20, 2018
by
Adam Cozzette
Committed by
GitHub
Jul 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4943 from Stevie-O/fix-unit-tests-on-win32
When running unit tests, read reference files in text mode
parents
b1c55030
f5f1796c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
10 deletions
+15
-10
cpp_bootstrap_unittest.cc
src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
+1
-1
csharp_bootstrap_unittest.cc
...gle/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc
+1
-1
ruby_generator_unittest.cc
src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc
+2
-2
map_test.cc
src/google/protobuf/map_test.cc
+1
-1
file.cc
src/google/protobuf/testing/file.cc
+2
-2
file.h
src/google/protobuf/testing/file.h
+6
-1
text_format_unittest.cc
src/google/protobuf/text_format_unittest.cc
+2
-2
No files found.
src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
View file @
656f64ec
...
...
@@ -95,7 +95,7 @@ class MockGeneratorContext : public GeneratorContext {
string
actual_contents
;
GOOGLE_CHECK_OK
(
File
::
GetContents
(
TestSourceDir
()
+
"/"
+
physical_filename
,
File
::
GetContents
AsText
(
TestSourceDir
()
+
"/"
+
physical_filename
,
&
actual_contents
,
true
));
EXPECT_TRUE
(
actual_contents
==
*
expected_contents
)
<<
physical_filename
...
...
src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc
View file @
656f64ec
...
...
@@ -90,7 +90,7 @@ class MockGeneratorContext : public GeneratorContext {
string
actual_contents
;
GOOGLE_CHECK_OK
(
File
::
GetContents
(
TestSourceDir
()
+
"/"
+
physical_filename
,
File
::
GetContents
AsText
(
TestSourceDir
()
+
"/"
+
physical_filename
,
&
actual_contents
,
true
))
<<
"Unable to get "
<<
physical_filename
;
EXPECT_TRUE
(
actual_contents
==
*
expected_contents
)
...
...
src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc
View file @
656f64ec
...
...
@@ -90,12 +90,12 @@ TEST(RubyGeneratorTest, GeneratorTest) {
// Load the generated output and compare to the expected result.
string
output
;
GOOGLE_CHECK_OK
(
File
::
GetContents
(
GOOGLE_CHECK_OK
(
File
::
GetContents
AsText
(
TestTempDir
()
+
"/ruby_generated_code_pb.rb"
,
&
output
,
true
));
string
expected_output
;
GOOGLE_CHECK_OK
(
File
::
GetContents
(
GOOGLE_CHECK_OK
(
File
::
GetContents
AsText
(
ruby_tests
+
"/ruby_generated_code_pb.rb"
,
&
expected_output
,
true
));
...
...
src/google/protobuf/map_test.cc
View file @
656f64ec
...
...
@@ -3183,7 +3183,7 @@ TEST(TextFormatMapTest, Sorted) {
tester
.
SetMapFieldsViaReflection
(
&
message
);
string
expected_text
;
GOOGLE_CHECK_OK
(
File
::
GetContents
(
GOOGLE_CHECK_OK
(
File
::
GetContents
AsText
(
TestSourceDir
()
+
"/google/protobuf/"
"testdata/map_test_data.txt"
,
...
...
src/google/protobuf/testing/file.cc
View file @
656f64ec
...
...
@@ -69,9 +69,9 @@ bool File::Exists(const string& name) {
return
access
(
name
.
c_str
(),
F_OK
)
==
0
;
}
bool
File
::
ReadFileToString
(
const
string
&
name
,
string
*
output
)
{
bool
File
::
ReadFileToString
(
const
string
&
name
,
string
*
output
,
bool
text_mode
)
{
char
buffer
[
1024
];
FILE
*
file
=
fopen
(
name
.
c_str
(),
"rb"
);
FILE
*
file
=
fopen
(
name
.
c_str
(),
text_mode
?
"rt"
:
"rb"
);
if
(
file
==
NULL
)
return
false
;
while
(
true
)
{
...
...
src/google/protobuf/testing/file.h
View file @
656f64ec
...
...
@@ -50,7 +50,7 @@ class File {
// Read an entire file to a string. Return true if successful, false
// otherwise.
static
bool
ReadFileToString
(
const
string
&
name
,
string
*
output
);
static
bool
ReadFileToString
(
const
string
&
name
,
string
*
output
,
bool
text_mode
=
false
);
// Same as above, but crash on failure.
static
void
ReadFileToStringOrDie
(
const
string
&
name
,
string
*
output
);
...
...
@@ -85,6 +85,11 @@ class File {
return
ReadFileToString
(
name
,
output
);
}
static
bool
GetContentsAsText
(
const
string
&
name
,
string
*
output
,
bool
/*is_default*/
)
{
return
ReadFileToString
(
name
,
output
,
true
);
}
static
bool
SetContents
(
const
string
&
name
,
const
string
&
contents
,
bool
/*is_default*/
)
{
return
WriteStringToFile
(
contents
,
name
);
...
...
src/google/protobuf/text_format_unittest.cc
View file @
656f64ec
...
...
@@ -77,7 +77,7 @@ const string kEscapeTestStringEscaped =
class
TextFormatTest
:
public
testing
::
Test
{
public
:
static
void
SetUpTestCase
()
{
GOOGLE_CHECK_OK
(
File
::
GetContents
(
GOOGLE_CHECK_OK
(
File
::
GetContents
AsText
(
TestSourceDir
()
+
"/google/protobuf/"
"testdata/text_format_unittest_data_oneof_implemented.txt"
,
...
...
@@ -99,7 +99,7 @@ string TextFormatTest::static_proto_debug_string_;
class
TextFormatExtensionsTest
:
public
testing
::
Test
{
public
:
static
void
SetUpTestCase
()
{
GOOGLE_CHECK_OK
(
File
::
GetContents
(
TestSourceDir
()
+
GOOGLE_CHECK_OK
(
File
::
GetContents
AsText
(
TestSourceDir
()
+
"/google/protobuf/testdata/"
"text_format_unittest_extensions_data.txt"
,
&
static_proto_debug_string_
,
true
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment