Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1367)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock_unittest.py

Issue 2029823002: Fix MockFileSystem.walk and add test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: set dry_run to False Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock_unittest.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock_unittest.py
index 561959ad5610989b637af3d5c0ee344c251afb2b..42d83c0a516dd38bc64e3c377de012bf2e1e7aa7 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock_unittest.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock_unittest.py
@@ -28,9 +28,10 @@
import unittest
-
+from webkitpy.common.host_mock import MockHost
from webkitpy.common.system import filesystem_mock
from webkitpy.common.system import filesystem_unittest
+from webkitpy.common.system.filesystem_mock import MockFileSystem
class MockFileSystemTest(unittest.TestCase, filesystem_unittest.GenericFileSystemTests):
@@ -84,3 +85,29 @@ class MockFileSystemTest(unittest.TestCase, filesystem_unittest.GenericFileSyste
def test_relpath_win32(self):
pass
+
+ def test_filesystem_walk(self):
+ mock_dir = 'foo'
+ mock_files = {'foo/bar/baz': '',
+ 'foo/a': '',
+ 'foo/b': '',
+ 'foo/c': ''}
+ host = MockHost()
+ host.filesystem = MockFileSystem(files=mock_files)
+ self.assertEquals(host.filesystem.walk(mock_dir), [('foo', ['bar'], ['a', 'b', 'c']), ('foo/bar', [], ['baz'])])
+
+ def test_filesystem_walk_deeply_nested(self):
+ mock_dir = 'foo'
+ mock_files = {'foo/bar/baz': '',
+ 'foo/bar/quux': '',
+ 'foo/a/x': '',
+ 'foo/a/y': '',
+ 'foo/a/z/lyrics': '',
+ 'foo/b': '',
+ 'foo/c': ''}
+ host = MockHost()
+ host.filesystem = MockFileSystem(files=mock_files)
+ self.assertEquals(host.filesystem.walk(mock_dir), [('foo', ['a', 'bar'], ['c', 'b']),
+ ('foo/a', ['z'], ['x', 'y']),
+ ('foo/a/z', [], ['lyrics']),
+ ('foo/bar', [], ['quux', 'baz'])])

Powered by Google App Engine
This is Rietveld 408576698