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
611e8a99
Commit
611e8a99
authored
May 02, 2017
by
Gennadiy Civil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes to make TempDir() public
Fixes #1076.
parent
aa148eb2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
22 deletions
+29
-22
gtest.h
googletest/include/gtest/gtest.h
+4
-0
gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+5
-3
gtest-port.cc
googletest/src/gtest-port.cc
+0
-18
gtest.cc
googletest/src/gtest.cc
+19
-0
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() {
GTEST_TEST_(test_fixture, test_name, 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
// 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();
#endif // GTEST_HAS_STREAM_REDIRECTION
// Returns a path to temporary directory.
GTEST_API_
std
::
string
TempDir
();
// Returns the size (in bytes) of a file.
GTEST_API_
size_t
GetFileSize
(
FILE
*
file
);
...
...
@@ -2559,6 +2556,11 @@ GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
std
::
string
StringFromGTestEnv
(
const
char
*
flag
,
const
char
*
default_val
);
}
// namespace internal
// Returns a path to temporary directory.
// Tries to determine an appropriate directory for the platform.
GTEST_API_
std
::
string
TempDir
();
}
// namespace testing
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
googletest/src/gtest-port.cc
View file @
611e8a99
...
...
@@ -1055,24 +1055,6 @@ std::string GetCapturedStderr() {
#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
)
{
fseek
(
file
,
0
,
SEEK_END
);
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) {
#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
googletest/test/gtest_unittest.cc
View file @
611e8a99
...
...
@@ -6411,7 +6411,7 @@ class FlagfileTest : public InitGoogleTestTest {
InitGoogleTestTest
::
SetUp
();
testdata_path_
.
Set
(
internal
::
FilePath
(
internal
::
TempDir
()
+
internal
::
GetCurrentExecutableName
().
string
()
+
testing
::
TempDir
()
+
internal
::
GetCurrentExecutableName
().
string
()
+
"_flagfile_test"
));
testing
::
internal
::
posix
::
RmDir
(
testdata_path_
.
c_str
());
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