eliben / pss

pss is a power-tool for searching inside source code files.
Other
327 stars 46 forks source link

TestFileFinder.test_ignore_dirs fails on Windows #9

Closed benhoyt closed 11 years ago

benhoyt commented 11 years ago

I'm running the current eliben/pss master on Windows 7 64-bit, and running test/all_tests.py gives this:

..F.........................
======================================================================
FAIL: test_ignore_dirs (test_filefinder.TestFileFinder)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Hoyt\Downloads\pss\test\test_filefinder.py", line 120, in test_ignore_dirs
    'simple_filefinder/partialignored/found.c'])
  File "C:\Users\Hoyt\Downloads\pss\test\test_filefinder.py", line 49, in assertPathsEqual
    list(sorted(map(os.path.normpath, second))))
AssertionError: Lists differ: ['simple_filefinder\\a.c', 'si... != ['simple_filefinder\\a.c', 'si...

First list contains 1 additional elements.
First extra element 3:
simple_filefinder\partialignored\thisoneisignored\notfound.c

  ['simple_filefinder\\a.c',
   'simple_filefinder\\c.c',
-  'simple_filefinder\\partialignored\\found.c',
?                                              ^

+  'simple_filefinder\\partialignored\\found.c']
?                                              ^

-  'simple_filefinder\\partialignored\\thisoneisignored\\notfound.c']

----------------------------------------------------------------------
Ran 28 tests in 0.166s

FAILED (failures=1)
eliben commented 11 years ago

Could you propose a patch with a fix? It's not easy for me to come up with a Windows box these days (and Travis doesn't support it yet).

benhoyt commented 11 years ago

This is happening because the ignore_dirs is specified in the test with a forward slash instead of a backslash (os.sep) on Windows. Fixed in this commit.

One could also go the other way and try to replace all slashes in dir names with backslahes on Windows, so that scripts written with slashes work the same way on Windows. But that strikes me as too clever -- callers should probably just use os.sep / os.path.join properly.

eliben commented 11 years ago

Fixed