xiaowanmay / googletest

Automatically exported from code.google.com/p/googletest
0 stars 0 forks source link

Windows accepts forward slash as directory separator, too #242

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Execute gtest-filepath_test.exe and use forward slashes in the path to 
the binary, like: C:/Users/Manuel/Documents/Build/googletest/Debug/gtest-
filepath_test.exe

What is the expected output? What do you see instead?
Expected: test passes, Is: failure

What version of the product are you using? On what operating system?
Head, Windows 7, cmake

Please provide any additional information below, such as a code snippet.
I encountered this problem while trying to execute the tests from the 
Visual Studio project file created by cmake. This uses ctest to execute the 
tests, which calls the tests with forward slashes in the path (this is 
totally fine on Windows).
The argv[0] in the started process is exactly the way the binary was 
called, so it contains forward slashes. This leads to 
result.RemoveDirectoryName not removing the path in gtest.cc:362, which 
leads to several test failures and segfaults.

I'm willing to fix this, but I don't know yet how:
We could change RemoveDirectoryName (gtest-filepath.cc:118) to also look 
for what windows calls the "alternate directory separator" (see also 
http://msdn.microsoft.com/en-
us/library/system.io.path.altdirectoryseparatorchar.aspx). There are not 
more than 10 places in gtest-filepath.cc that need to be fixed.
The alternative would be to declare this a ctest bug, but since Windows 
accepts forward slashes just fine, it's a common practice for cross-
platform tools to just use forward slashes.

Original issue reported on code.google.com by kli...@google.com on 3 Jan 2010 at 7:33

GoogleCodeExporter commented 9 years ago
I think we should just fix gtest-filepath.cc.  It doesn't seem a lot of work.

Original comment by w...@google.com on 4 Jan 2010 at 12:10

GoogleCodeExporter commented 9 years ago

Original comment by w...@google.com on 26 Feb 2010 at 8:09