Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
611e8a99
Commit
611e8a99
authored
May 02, 2017
by
Gennadiy Civil
Browse files
Changes to make TempDir() public
Fixes #1076.
parent
aa148eb2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
22 deletions
+29
-22
googletest/include/gtest/gtest.h
googletest/include/gtest/gtest.h
+4
-0
googletest/include/gtest/internal/gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+5
-3
googletest/src/gtest-port.cc
googletest/src/gtest-port.cc
+0
-18
googletest/src/gtest.cc
googletest/src/gtest.cc
+19
-0
googletest/test/gtest_unittest.cc
googletest/test/gtest_unittest.cc
+1
-1
No files found.
googletest/include/gtest/gtest.h
View file @
611e8a99
...
@@ -2217,6 +2217,10 @@ bool StaticAssertTypeEq() {
...
@@ -2217,6 +2217,10 @@ bool StaticAssertTypeEq() {
GTEST_TEST_(test_fixture, test_name, test_fixture, \
GTEST_TEST_(test_fixture, test_name, test_fixture, \
::testing::internal::GetTypeId<test_fixture>())
::testing::internal::GetTypeId<test_fixture>())
// Returns a path to temporary directory.
// Tries to determine an appropriate directory for the platform.
GTEST_API_
std
::
string
TempDir
();
}
// namespace testing
}
// namespace testing
// Use this function in main() to run all tests. It returns 0 if all
// Use this function in main() to run all tests. It returns 0 if all
...
...
googletest/include/gtest/internal/gtest-port.h
View file @
611e8a99
...
@@ -1428,9 +1428,6 @@ GTEST_API_ std::string GetCapturedStderr();
...
@@ -1428,9 +1428,6 @@ GTEST_API_ std::string GetCapturedStderr();
#endif // GTEST_HAS_STREAM_REDIRECTION
#endif // GTEST_HAS_STREAM_REDIRECTION
// Returns a path to temporary directory.
GTEST_API_
std
::
string
TempDir
();
// Returns the size (in bytes) of a file.
// Returns the size (in bytes) of a file.
GTEST_API_
size_t
GetFileSize
(
FILE
*
file
);
GTEST_API_
size_t
GetFileSize
(
FILE
*
file
);
...
@@ -2559,6 +2556,11 @@ GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
...
@@ -2559,6 +2556,11 @@ GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
std
::
string
StringFromGTestEnv
(
const
char
*
flag
,
const
char
*
default_val
);
std
::
string
StringFromGTestEnv
(
const
char
*
flag
,
const
char
*
default_val
);
}
// namespace internal
}
// namespace internal
// Returns a path to temporary directory.
// Tries to determine an appropriate directory for the platform.
GTEST_API_
std
::
string
TempDir
();
}
// namespace testing
}
// namespace testing
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
googletest/src/gtest-port.cc
View file @
611e8a99
...
@@ -1055,24 +1055,6 @@ std::string GetCapturedStderr() {
...
@@ -1055,24 +1055,6 @@ std::string GetCapturedStderr() {
#endif // GTEST_HAS_STREAM_REDIRECTION
#endif // GTEST_HAS_STREAM_REDIRECTION
std
::
string
TempDir
()
{
#if GTEST_OS_WINDOWS_MOBILE
return
"
\\
temp
\\
"
;
#elif GTEST_OS_WINDOWS
const
char
*
temp_dir
=
posix
::
GetEnv
(
"TEMP"
);
if
(
temp_dir
==
NULL
||
temp_dir
[
0
]
==
'\0'
)
return
"
\\
temp
\\
"
;
else
if
(
temp_dir
[
strlen
(
temp_dir
)
-
1
]
==
'\\'
)
return
temp_dir
;
else
return
std
::
string
(
temp_dir
)
+
"
\\
"
;
#elif GTEST_OS_LINUX_ANDROID
return
"/sdcard/"
;
#else
return
"/tmp/"
;
#endif // GTEST_OS_WINDOWS_MOBILE
}
size_t
GetFileSize
(
FILE
*
file
)
{
size_t
GetFileSize
(
FILE
*
file
)
{
fseek
(
file
,
0
,
SEEK_END
);
fseek
(
file
,
0
,
SEEK_END
);
return
static_cast
<
size_t
>
(
ftell
(
file
));
return
static_cast
<
size_t
>
(
ftell
(
file
));
...
...
googletest/src/gtest.cc
View file @
611e8a99
...
@@ -5385,4 +5385,23 @@ void InitGoogleTest(int* argc, wchar_t** argv) {
...
@@ -5385,4 +5385,23 @@ void InitGoogleTest(int* argc, wchar_t** argv) {
#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
}
}
std
::
string
TempDir
()
{
#if GTEST_OS_WINDOWS_MOBILE
return
"
\\
temp
\\
"
;
#elif GTEST_OS_WINDOWS
const
char
*
temp_dir
=
internal
::
posix
::
GetEnv
(
"TEMP"
);
if
(
temp_dir
==
NULL
||
temp_dir
[
0
]
==
'\0'
)
return
"
\\
temp
\\
"
;
else
if
(
temp_dir
[
strlen
(
temp_dir
)
-
1
]
==
'\\'
)
return
temp_dir
;
else
return
std
::
string
(
temp_dir
)
+
"
\\
"
;
#elif GTEST_OS_LINUX_ANDROID
return
"/sdcard/"
;
#else
return
"/tmp/"
;
#endif // GTEST_OS_WINDOWS_MOBILE
}
}
// namespace testing
}
// namespace testing
googletest/test/gtest_unittest.cc
View file @
611e8a99
...
@@ -6411,7 +6411,7 @@ class FlagfileTest : public InitGoogleTestTest {
...
@@ -6411,7 +6411,7 @@ class FlagfileTest : public InitGoogleTestTest {
InitGoogleTestTest
::
SetUp
();
InitGoogleTestTest
::
SetUp
();
testdata_path_
.
Set
(
internal
::
FilePath
(
testdata_path_
.
Set
(
internal
::
FilePath
(
internal
::
TempDir
()
+
internal
::
GetCurrentExecutableName
().
string
()
+
testing
::
TempDir
()
+
internal
::
GetCurrentExecutableName
().
string
()
+
"_flagfile_test"
));
"_flagfile_test"
));
testing
::
internal
::
posix
::
RmDir
(
testdata_path_
.
c_str
());
testing
::
internal
::
posix
::
RmDir
(
testdata_path_
.
c_str
());
EXPECT_TRUE
(
testdata_path_
.
CreateFolder
());
EXPECT_TRUE
(
testdata_path_
.
CreateFolder
());
...
...
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