aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/testing/googletest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/testing/googletest.cc')
-rw-r--r--src/google/protobuf/testing/googletest.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/google/protobuf/testing/googletest.cc b/src/google/protobuf/testing/googletest.cc
index d72fa5c0..b8bd790b 100644
--- a/src/google/protobuf/testing/googletest.cc
+++ b/src/google/protobuf/testing/googletest.cc
@@ -65,7 +65,15 @@ namespace protobuf {
#endif
string TestSourceDir() {
-#ifdef _MSC_VER
+#ifndef GOOGLE_THIRD_PARTY_PROTOBUF
+#ifndef _MSC_VER
+ // automake sets the "srcdir" environment variable.
+ char* result = getenv("srcdir");
+ if (result != NULL) {
+ return result;
+ }
+#endif // _MSC_VER
+
// Look for the "src" directory.
string prefix = ".";
@@ -79,15 +87,8 @@ string TestSourceDir() {
}
return prefix + "/src";
#else
- // automake sets the "srcdir" environment variable.
- char* result = getenv("srcdir");
- if (result == NULL) {
- // Otherwise, the test must be run from the source directory.
- return ".";
- } else {
- return result;
- }
-#endif
+ return "third_party/protobuf/src";
+#endif // GOOGLE_THIRD_PARTY_PROTOBUF
}
namespace {
@@ -104,6 +105,10 @@ string GetTemporaryDirectoryName() {
if (HasPrefixString(result, "\\")) {
result.erase(0, 1);
}
+ // The Win32 API accepts forward slashes as a path delimiter even though
+ // backslashes are standard. Let's avoid confusion and use only forward
+ // slashes.
+ result = StringReplace(result, "\\", "/", true);
#endif // _WIN32
return result;
}