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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 # Copyright (C) 2011 Google Inc. All rights reserved. 1 # Copyright (C) 2011 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 10 matching lines...) Expand all
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 import unittest 29 import unittest
30 30
31 31 from webkitpy.common.host_mock import MockHost
32 from webkitpy.common.system import filesystem_mock 32 from webkitpy.common.system import filesystem_mock
33 from webkitpy.common.system import filesystem_unittest 33 from webkitpy.common.system import filesystem_unittest
34 from webkitpy.common.system.filesystem_mock import MockFileSystem
34 35
35 36
36 class MockFileSystemTest(unittest.TestCase, filesystem_unittest.GenericFileSyste mTests): 37 class MockFileSystemTest(unittest.TestCase, filesystem_unittest.GenericFileSyste mTests):
37 38
38 def setUp(self): 39 def setUp(self):
39 self.fs = filesystem_mock.MockFileSystem() 40 self.fs = filesystem_mock.MockFileSystem()
40 self.setup_generic_test_dir() 41 self.setup_generic_test_dir()
41 42
42 def tearDown(self): 43 def tearDown(self):
43 self.teardown_generic_test_dir() 44 self.teardown_generic_test_dir()
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 'foo/', 78 'foo/',
78 'foo/.', 79 'foo/.',
79 'foo/bar', 80 'foo/bar',
80 '/foo', 81 '/foo',
81 'foo/../bar', 82 'foo/../bar',
82 'foo/../bar/baz', 83 'foo/../bar/baz',
83 '../foo') 84 '../foo')
84 85
85 def test_relpath_win32(self): 86 def test_relpath_win32(self):
86 pass 87 pass
88
89 def test_filesystem_walk(self):
90 mock_dir = 'foo'
91 mock_files = {'foo/bar/baz': '',
92 'foo/a': '',
93 'foo/b': '',
94 'foo/c': ''}
95 host = MockHost()
96 host.filesystem = MockFileSystem(files=mock_files)
97 self.assertEquals(host.filesystem.walk(mock_dir), [('foo', ['bar'], ['a' , 'b', 'c']), ('foo/bar', [], ['baz'])])
98
99 def test_filesystem_walk_deeply_nested(self):
100 mock_dir = 'foo'
101 mock_files = {'foo/bar/baz': '',
102 'foo/bar/quux': '',
103 'foo/a/x': '',
104 'foo/a/y': '',
105 'foo/a/z/lyrics': '',
106 'foo/b': '',
107 'foo/c': ''}
108 host = MockHost()
109 host.filesystem = MockFileSystem(files=mock_files)
110 self.assertEquals(host.filesystem.walk(mock_dir), [('foo', ['a', 'bar'], ['c', 'b']),
111 ('foo/a', ['z'], ['x' , 'y']),
112 ('foo/a/z', [], ['lyr ics']),
113 ('foo/bar', [], ['quu x', 'baz'])])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698