Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
f972f168
Commit
f972f168
authored
Jul 24, 2015
by
kosak
Browse files
Inject GetArgvs() with a macro from custom/gtest-port.h.
parent
40bba6c9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
30 deletions
+19
-30
include/gtest/internal/gtest-internal.h
include/gtest/internal/gtest-internal.h
+0
-3
include/gtest/internal/gtest-port.h
include/gtest/internal/gtest-port.h
+4
-3
src/gtest-port.cc
src/gtest-port.cc
+1
-4
src/gtest.cc
src/gtest.cc
+14
-20
No files found.
include/gtest/internal/gtest-internal.h
View file @
f972f168
...
@@ -100,9 +100,6 @@ class ScopedTrace; // Implements scoped trace.
...
@@ -100,9 +100,6 @@ class ScopedTrace; // Implements scoped trace.
class
TestInfoImpl
;
// Opaque implementation of TestInfo
class
TestInfoImpl
;
// Opaque implementation of TestInfo
class
UnitTestImpl
;
// Opaque implementation of UnitTest
class
UnitTestImpl
;
// Opaque implementation of UnitTest
// How many times InitGoogleTest() has been called.
GTEST_API_
extern
int
g_init_gtest_count
;
// The text used in failure messages to indicate the start of the
// The text used in failure messages to indicate the start of the
// stack trace.
// stack trace.
GTEST_API_
extern
const
char
kStackTraceMarker
[];
GTEST_API_
extern
const
char
kStackTraceMarker
[];
...
...
include/gtest/internal/gtest-port.h
View file @
f972f168
...
@@ -276,6 +276,7 @@
...
@@ -276,6 +276,7 @@
#include <sstream> // NOLINT
#include <sstream> // NOLINT
#include <string> // NOLINT
#include <string> // NOLINT
#include <utility>
#include <utility>
#include <vector> // NOLINT
#include "gtest/internal/gtest-port-arch.h"
#include "gtest/internal/gtest-port-arch.h"
#include "gtest/internal/custom/gtest-port.h"
#include "gtest/internal/custom/gtest-port.h"
...
@@ -785,7 +786,6 @@ using ::std::tuple_size;
...
@@ -785,7 +786,6 @@ using ::std::tuple_size;
GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD)
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD)
# define GTEST_HAS_DEATH_TEST 1
# define GTEST_HAS_DEATH_TEST 1
# include <vector> // NOLINT
#endif
#endif
// We don't support MSVC 7.1 with exceptions disabled now. Therefore
// We don't support MSVC 7.1 with exceptions disabled now. Therefore
...
@@ -1421,14 +1421,15 @@ GTEST_API_ size_t GetFileSize(FILE* file);
...
@@ -1421,14 +1421,15 @@ GTEST_API_ size_t GetFileSize(FILE* file);
// Reads the entire content of a file as a string.
// Reads the entire content of a file as a string.
GTEST_API_
std
::
string
ReadEntireFile
(
FILE
*
file
);
GTEST_API_
std
::
string
ReadEntireFile
(
FILE
*
file
);
// All command line arguments.
GTEST_API_
const
::
std
::
vector
<
testing
::
internal
::
string
>&
GetArgvs
();
#if GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
const
::
std
::
vector
<
testing
::
internal
::
string
>&
GetInjectableArgvs
();
const
::
std
::
vector
<
testing
::
internal
::
string
>&
GetInjectableArgvs
();
void
SetInjectableArgvs
(
const
::
std
::
vector
<
testing
::
internal
::
string
>*
void
SetInjectableArgvs
(
const
::
std
::
vector
<
testing
::
internal
::
string
>*
new_argvs
);
new_argvs
);
// A copy of all command line arguments. Set by ParseGTestFlags().
extern
::
std
::
vector
<
testing
::
internal
::
string
>
g_argvs
;
#endif // GTEST_HAS_DEATH_TEST
#endif // GTEST_HAS_DEATH_TEST
...
...
src/gtest-port.cc
View file @
f972f168
...
@@ -1084,9 +1084,6 @@ std::string ReadEntireFile(FILE* file) {
...
@@ -1084,9 +1084,6 @@ std::string ReadEntireFile(FILE* file) {
#if GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
// A copy of all command line arguments. Set by InitGoogleTest().
::
std
::
vector
<
testing
::
internal
::
string
>
g_argvs
;
static
const
::
std
::
vector
<
testing
::
internal
::
string
>*
g_injected_test_argvs
=
static
const
::
std
::
vector
<
testing
::
internal
::
string
>*
g_injected_test_argvs
=
NULL
;
// Owned.
NULL
;
// Owned.
...
@@ -1100,7 +1097,7 @@ const ::std::vector<testing::internal::string>& GetInjectableArgvs() {
...
@@ -1100,7 +1097,7 @@ const ::std::vector<testing::internal::string>& GetInjectableArgvs() {
if
(
g_injected_test_argvs
!=
NULL
)
{
if
(
g_injected_test_argvs
!=
NULL
)
{
return
*
g_injected_test_argvs
;
return
*
g_injected_test_argvs
;
}
}
return
g_a
rgvs
;
return
GetA
rgvs
()
;
}
}
#endif // GTEST_HAS_DEATH_TEST
#endif // GTEST_HAS_DEATH_TEST
...
...
src/gtest.cc
View file @
f972f168
...
@@ -327,13 +327,7 @@ UInt32 Random::Generate(UInt32 range) {
...
@@ -327,13 +327,7 @@ UInt32 Random::Generate(UInt32 range) {
// GTestIsInitialized() returns true iff the user has initialized
// GTestIsInitialized() returns true iff the user has initialized
// Google Test. Useful for catching the user mistake of not initializing
// Google Test. Useful for catching the user mistake of not initializing
// Google Test before calling RUN_ALL_TESTS().
// Google Test before calling RUN_ALL_TESTS().
//
static
bool
GTestIsInitialized
()
{
return
GetArgvs
().
size
()
>
0
;
}
// A user must call testing::InitGoogleTest() to initialize Google
// Test. g_init_gtest_count is set to the number of times
// InitGoogleTest() has been called. We don't protect this variable
// under a mutex as it is only accessed in the main thread.
GTEST_API_
int
g_init_gtest_count
=
0
;
static
bool
GTestIsInitialized
()
{
return
g_init_gtest_count
!=
0
;
}
// Iterates over a vector of TestCases, keeping a running sum of the
// Iterates over a vector of TestCases, keeping a running sum of the
// results of calling a given int-returning method on each.
// results of calling a given int-returning method on each.
...
@@ -389,8 +383,16 @@ void AssertHelper::operator=(const Message& message) const {
...
@@ -389,8 +383,16 @@ void AssertHelper::operator=(const Message& message) const {
// Mutex for linked pointers.
// Mutex for linked pointers.
GTEST_API_
GTEST_DEFINE_STATIC_MUTEX_
(
g_linked_ptr_mutex
);
GTEST_API_
GTEST_DEFINE_STATIC_MUTEX_
(
g_linked_ptr_mutex
);
// Application pathname gotten in InitGoogleTest.
// A copy of all command line arguments. Set by InitGoogleTest().
std
::
string
g_executable_path
;
::
std
::
vector
<
testing
::
internal
::
string
>
g_argvs
;
const
::
std
::
vector
<
testing
::
internal
::
string
>&
GetArgvs
()
{
#if defined(GTEST_CUSTOM_GET_ARGVS_)
return
GTEST_CUSTOM_GET_ARGVS_
();
#else // defined(GTEST_CUSTOM_GET_ARGVS_)
return
g_argvs
;
#endif // defined(GTEST_CUSTOM_GET_ARGVS_)
}
// Returns the current application's name, removing directory path if that
// Returns the current application's name, removing directory path if that
// is present.
// is present.
...
@@ -398,9 +400,9 @@ FilePath GetCurrentExecutableName() {
...
@@ -398,9 +400,9 @@ FilePath GetCurrentExecutableName() {
FilePath
result
;
FilePath
result
;
#if GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
result
.
Set
(
FilePath
(
g_executable_path
).
RemoveExtension
(
"exe"
));
result
.
Set
(
FilePath
(
GetArgvs
()[
0
]
).
RemoveExtension
(
"exe"
));
#else
#else
result
.
Set
(
FilePath
(
g_executable_path
));
result
.
Set
(
FilePath
(
GetArgvs
()[
0
]
));
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
return
result
.
RemoveDirectoryName
();
return
result
.
RemoveDirectoryName
();
...
@@ -5328,24 +5330,16 @@ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {
...
@@ -5328,24 +5330,16 @@ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {
// wchar_t.
// wchar_t.
template
<
typename
CharType
>
template
<
typename
CharType
>
void
InitGoogleTestImpl
(
int
*
argc
,
CharType
**
argv
)
{
void
InitGoogleTestImpl
(
int
*
argc
,
CharType
**
argv
)
{
g_init_gtest_count
++
;
// We don't want to run the initialization code twice.
// We don't want to run the initialization code twice.
if
(
g_init_gtest_count
!=
1
)
return
;
if
(
GTestIsInitialized
()
)
return
;
if
(
*
argc
<=
0
)
return
;
if
(
*
argc
<=
0
)
return
;
internal
::
g_executable_path
=
internal
::
StreamableToString
(
argv
[
0
]);
#if GTEST_HAS_DEATH_TEST
g_argvs
.
clear
();
g_argvs
.
clear
();
for
(
int
i
=
0
;
i
!=
*
argc
;
i
++
)
{
for
(
int
i
=
0
;
i
!=
*
argc
;
i
++
)
{
g_argvs
.
push_back
(
StreamableToString
(
argv
[
i
]));
g_argvs
.
push_back
(
StreamableToString
(
argv
[
i
]));
}
}
#endif // GTEST_HAS_DEATH_TEST
ParseGoogleTestFlagsOnly
(
argc
,
argv
);
ParseGoogleTestFlagsOnly
(
argc
,
argv
);
GetUnitTestImpl
()
->
PostFlagParsingInit
();
GetUnitTestImpl
()
->
PostFlagParsingInit
();
}
}
...
...
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