Review URL: http://codereview.chromium.org/132022

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@18764 0039d316-1c4b-4281-b951-d872f2087c98
parent 46e832a0
......@@ -5,6 +5,7 @@
"""Unit tests for watchlists.py."""
import os
import unittest
import super_mox
import watchlists
......@@ -127,6 +128,32 @@ class WatchlistsTest(super_mox.SuperMoxTestBase):
wl = watchlists.Watchlists('/a/path')
self.assertEqual(wl.GetWatchersForPaths(['file_views_mac']), watchers)
def testWinPathWatchers(self):
"""Test watchers for a windows path (containing backward slashes)."""
watchers = ['abc@def.com', 'x1@xyz.org']
contents = \
"""{
'WATCHLIST_DEFINITIONS': {
'browser': {
'filepath': 'chrome/browser/.*',
},
},
'WATCHLISTS': {
'browser': %s,
},
} """ % watchers
saved_sep = os.sep
os.sep = '\\' # to pose as win32
watchlists.Watchlists._HasWatchlistsFile().AndReturn(True)
watchlists.Watchlists._ContentsOfWatchlistsFile().AndReturn(contents)
self.mox.ReplayAll()
wl = watchlists.Watchlists(r'a\path')
returned_watchers = wl.GetWatchersForPaths(
[r'chrome\browser\renderer_host\render_widget_host.h'])
os.sep = saved_sep # revert back os.sep before asserts
self.assertEqual(returned_watchers, watchers)
if __name__ == '__main__':
unittest.main()
......@@ -104,6 +104,7 @@ class Watchlists(object):
"""
watchers = set() # A set, to avoid duplicates
for path in paths:
path = path.replace(os.sep, '/')
for name, rule in self._defns.iteritems():
if name not in self._watchlists: continue
rex_str = rule.get('filepath')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment