Chromium Code Reviews| Index: third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock.py |
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock.py |
| index 44c7d8043d507f9dad2c683232b2e28ea01e5dd7..d457d2c4f91b93282a643318b506fa9ad2b1066a 100644 |
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock.py |
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_mock.py |
| @@ -49,6 +49,7 @@ class MockFileSystem(object): |
| not exist. |
| """ |
| self.files = files or {} |
| + self.perms = {} |
|
qyearsley
2016/06/14 21:47:02
Although it's nice that `perms` is the same length
|
| self.written_files = {} |
| self.last_tmpdir = None |
| self.current_tmpno = 0 |
| @@ -56,11 +57,12 @@ class MockFileSystem(object): |
| self.dirs = set(dirs or []) |
| self.dirs.add(cwd) |
| for f in self.files: |
| + self.perms[f] = '-rwxrwxrwx' |
| + for f in self.files: |
| d = self.dirname(f) |
| while not d in self.dirs: |
| self.dirs.add(d) |
| d = self.dirname(d) |
| - |
| def clear_written_files(self): |
| # This function can be used to track what is written between steps in a test. |
| self.written_files = {} |
| @@ -75,6 +77,34 @@ class MockFileSystem(object): |
| return path.rsplit(self.sep, 1) |
| return ('', path) |
| + def chmod(self, file_path, mode): |
| + # Incomplete implementation of os.chmod |
| + # only supports number modes |
| + mode_list = [] |
| + for i in range(0, 3): |
| + temp = mode % 10 |
| + mode_list.append(temp) |
| + mode /= 10 |
| + temp = i |
| + temp_perms = '-' |
| + temp_perms += self.chmod_options(mode_list[0]) |
| + temp_perms += self.chmod_options(mode_list[1]) |
| + temp_perms += self.chmod_options(mode_list[2]) |
| + self.perms[file_path] = temp_perms |
|
qyearsley
2016/06/14 21:47:02
List comprehensions (and related expressions) are
|
| + |
| + def chmod_options(self, arg): |
|
qyearsley
2016/06/14 21:47:02
1. The variable name `arg` could perhaps be improv
|
| + switcher = { |
| + 0: '---', |
| + 1: '--x', |
| + 2: '-w-', |
| + 3: '-wx', |
| + 4: 'r--', |
| + 5: 'r-x', |
| + 6: 'rw-', |
| + 7: 'rwx', |
| + } |
| + return switcher.get(arg, None) |
|
qyearsley
2016/06/14 21:47:02
None is the default default for dict.get, so this
|
| + |
| def abspath(self, path): |
| if os.path.isabs(path): |
| return self.normpath(path) |