Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
3663d671
Commit
3663d671
authored
Sep 11, 2017
by
Gennadiy Civil
Committed by
GitHub
Sep 11, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1203 from eidosmontreal/user_logger_instead_of_printf
User logger GTEST_LOG instead of printf in gtest.cc to log errors
parents
def0b321
900cc4bc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
26 deletions
+19
-26
gtest.cc
googletest/src/gtest.cc
+19
-26
No files found.
googletest/src/gtest.cc
View file @
3663d671
...
@@ -2569,10 +2569,10 @@ void ReportInvalidTestCaseType(const char* test_case_name,
...
@@ -2569,10 +2569,10 @@ void ReportInvalidTestCaseType(const char* test_case_name,
<<
"probably rename one of the classes to put the tests into different
\n
"
<<
"probably rename one of the classes to put the tests into different
\n
"
<<
"test cases."
;
<<
"test cases."
;
fprintf
(
stderr
,
"%s %s"
,
GTEST_LOG_
(
ERROR
)
FormatFileLocation
(
code_location
.
file
.
c_str
(),
<<
FormatFileLocation
(
code_location
.
file
.
c_str
(),
code_location
.
line
)
.
c_str
(),
code_location
.
line
)
errors
.
GetString
().
c_str
()
);
<<
" "
<<
errors
.
GetString
(
);
}
}
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_HAS_PARAM_TEST
...
@@ -3449,9 +3449,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
...
@@ -3449,9 +3449,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
XmlUnitTestResultPrinter
::
XmlUnitTestResultPrinter
(
const
char
*
output_file
)
XmlUnitTestResultPrinter
::
XmlUnitTestResultPrinter
(
const
char
*
output_file
)
:
output_file_
(
output_file
)
{
:
output_file_
(
output_file
)
{
if
(
output_file_
.
c_str
()
==
NULL
||
output_file_
.
empty
())
{
if
(
output_file_
.
c_str
()
==
NULL
||
output_file_
.
empty
())
{
fprintf
(
stderr
,
"XML output file may not be null
\n
"
);
GTEST_LOG_
(
FATAL
)
<<
"XML output file may not be null"
;
fflush
(
stderr
);
exit
(
EXIT_FAILURE
);
}
}
}
}
...
@@ -3476,11 +3474,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
...
@@ -3476,11 +3474,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// 3. To interpret the meaning of errno in a thread-safe way,
// 3. To interpret the meaning of errno in a thread-safe way,
// we need the strerror_r() function, which is not available on
// we need the strerror_r() function, which is not available on
// Windows.
// Windows.
fprintf
(
stderr
,
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
"Unable to open file
\"
%s
\"\n
"
,
<<
output_file_
<<
"
\"
"
;
output_file_
.
c_str
());
fflush
(
stderr
);
exit
(
EXIT_FAILURE
);
}
}
std
::
stringstream
stream
;
std
::
stringstream
stream
;
PrintXmlUnitTest
(
&
stream
,
unit_test
);
PrintXmlUnitTest
(
&
stream
,
unit_test
);
...
@@ -4431,9 +4426,9 @@ void UnitTestImpl::ConfigureXmlOutput() {
...
@@ -4431,9 +4426,9 @@ void UnitTestImpl::ConfigureXmlOutput() {
listeners
()
->
SetDefaultXmlGenerator
(
new
XmlUnitTestResultPrinter
(
listeners
()
->
SetDefaultXmlGenerator
(
new
XmlUnitTestResultPrinter
(
UnitTestOptions
::
GetAbsolutePathToOutputFile
().
c_str
()));
UnitTestOptions
::
GetAbsolutePathToOutputFile
().
c_str
()));
}
else
if
(
output_format
!=
""
)
{
}
else
if
(
output_format
!=
""
)
{
printf
(
"WARNING: unrecognized output format
\"
%s
\"
ignored.
\n
"
,
GTEST_LOG_
(
WARNING
)
<<
"WARNING: unrecognized output format
\"
"
output_format
.
c_str
());
<<
output_format
fflush
(
stdout
)
;
<<
"
\"
ignored."
;
}
}
}
}
...
@@ -4448,9 +4443,9 @@ void UnitTestImpl::ConfigureStreamingOutput() {
...
@@ -4448,9 +4443,9 @@ void UnitTestImpl::ConfigureStreamingOutput() {
listeners
()
->
Append
(
new
StreamingListener
(
target
.
substr
(
0
,
pos
),
listeners
()
->
Append
(
new
StreamingListener
(
target
.
substr
(
0
,
pos
),
target
.
substr
(
pos
+
1
)));
target
.
substr
(
pos
+
1
)));
}
else
{
}
else
{
printf
(
"WARNING: unrecognized streaming target
\"
%s
\"
ignored.
\n
"
,
GTEST_LOG_
(
WARNING
)
<<
"unrecognized streaming target
\"
"
target
.
c_str
());
<<
target
fflush
(
stdout
)
;
<<
"
\"
ignored."
;
}
}
}
}
}
}
...
@@ -4579,9 +4574,9 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
...
@@ -4579,9 +4574,9 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
bool
UnitTestImpl
::
RunAllTests
()
{
bool
UnitTestImpl
::
RunAllTests
()
{
// Makes sure InitGoogleTest() was called.
// Makes sure InitGoogleTest() was called.
if
(
!
GTestIsInitialized
())
{
if
(
!
GTestIsInitialized
())
{
printf
(
"%s"
,
GTEST_LOG_
(
ERROR
)
<<
"
\n
This test program did NOT call ::testing::InitGoogleTest "
"
\n
This test program did NOT call ::testing::InitGoogleTest "
"before calling RUN_ALL_TESTS(). Please fix it.
\n
"
)
;
"before calling RUN_ALL_TESTS(). Please fix it."
;
return
false
;
return
false
;
}
}
...
@@ -5281,11 +5276,9 @@ bool ParseGoogleTestFlag(const char* const arg) {
...
@@ -5281,11 +5276,9 @@ bool ParseGoogleTestFlag(const char* const arg) {
void
LoadFlagsFromFile
(
const
std
::
string
&
path
)
{
void
LoadFlagsFromFile
(
const
std
::
string
&
path
)
{
FILE
*
flagfile
=
posix
::
FOpen
(
path
.
c_str
(),
"r"
);
FILE
*
flagfile
=
posix
::
FOpen
(
path
.
c_str
(),
"r"
);
if
(
!
flagfile
)
{
if
(
!
flagfile
)
{
fprintf
(
stderr
,
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
"Unable to open file
\"
%s
\"\n
"
,
<<
GTEST_FLAG
(
flagfile
)
GTEST_FLAG
(
flagfile
).
c_str
());
<<
"
\"
"
;
fflush
(
stderr
);
exit
(
EXIT_FAILURE
);
}
}
std
::
string
contents
(
ReadEntireFile
(
flagfile
));
std
::
string
contents
(
ReadEntireFile
(
flagfile
));
posix
::
FClose
(
flagfile
);
posix
::
FClose
(
flagfile
);
...
...
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