| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import unittest | 5 import unittest |
| 6 | 6 |
| 7 from webkitpy.common.system.executive import Executive, ScriptError | 7 from webkitpy.common.system.executive import Executive, ScriptError |
| 8 from webkitpy.common.system.executive_mock import MockExecutive | 8 from webkitpy.common.system.executive_mock import MockExecutive |
| 9 from webkitpy.common.system.filesystem import FileSystem | 9 from webkitpy.common.system.filesystem import FileSystem |
| 10 from webkitpy.common.system.filesystem_mock import MockFileSystem | 10 from webkitpy.common.system.filesystem_mock import MockFileSystem |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 def _mkdtemp(self, **kwargs): | 51 def _mkdtemp(self, **kwargs): |
| 52 return str(self.filesystem.mkdtemp(**kwargs)) | 52 return str(self.filesystem.mkdtemp(**kwargs)) |
| 53 | 53 |
| 54 def _remove(self, path): | 54 def _remove(self, path): |
| 55 self.filesystem.remove(path) | 55 self.filesystem.remove(path) |
| 56 | 56 |
| 57 def _run(self, *args, **kwargs): | 57 def _run(self, *args, **kwargs): |
| 58 return self.executive.run_command(*args, **kwargs) | 58 return self.executive.run_command(*args, **kwargs) |
| 59 | 59 |
| 60 def _run_silent(self, args, **kwargs): | |
| 61 self.executive.run_command(args, **kwargs) | |
| 62 | |
| 63 def _write_text_file(self, path, contents): | 60 def _write_text_file(self, path, contents): |
| 64 self.filesystem.write_text_file(path, contents) | 61 self.filesystem.write_text_file(path, contents) |
| 65 | 62 |
| 66 def _write_binary_file(self, path, contents): | |
| 67 self.filesystem.write_binary_file(path, contents) | |
| 68 | |
| 69 def _make_diff(self, command, *args): | |
| 70 # We use this wrapper to disable output decoding. diffs should be treate
d as | |
| 71 # binary files since they may include text files of multiple different e
ncodings. | |
| 72 return self._run([command, 'diff'] + list(args), decode_output=False) | |
| 73 | |
| 74 def _git_diff(self, *args): | |
| 75 return self._make_diff('git', *args) | |
| 76 | |
| 77 def test_add_list(self): | 63 def test_add_list(self): |
| 78 self._chdir(self.untracking_checkout_path) | 64 self._chdir(self.untracking_checkout_path) |
| 79 git = self.untracking_git | 65 git = self.untracking_git |
| 80 self._mkdir('added_dir') | 66 self._mkdir('added_dir') |
| 81 self._write_text_file('added_dir/added_file', 'new stuff') | 67 self._write_text_file('added_dir/added_file', 'new stuff') |
| 82 print self._run(['ls', 'added_dir']) | 68 print self._run(['ls', 'added_dir']) |
| 83 print self._run(['pwd']) | 69 print self._run(['pwd']) |
| 84 print self._run(['cat', 'added_dir/added_file']) | 70 print self._run(['cat', 'added_dir/added_file']) |
| 85 git.add_list(['added_dir/added_file']) | 71 git.add_list(['added_dir/added_file']) |
| 86 self.assertIn('added_dir/added_file', git.added_files()) | 72 self.assertIn('added_dir/added_file', git.added_files()) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 # pylint: disable=protected-access | 225 # pylint: disable=protected-access |
| 240 git._run_git = lambda args: '\x00'.join(status_lines) + '\x00' | 226 git._run_git = lambda args: '\x00'.join(status_lines) + '\x00' |
| 241 self.assertEqual( | 227 self.assertEqual( |
| 242 git.unstaged_changes(), | 228 git.unstaged_changes(), |
| 243 { | 229 { |
| 244 'd/modified.txt': 'M', | 230 'd/modified.txt': 'M', |
| 245 'd/deleted.txt': 'D', | 231 'd/deleted.txt': 'D', |
| 246 'd/untracked.txt': '?', | 232 'd/untracked.txt': '?', |
| 247 'a': '?', | 233 'a': '?', |
| 248 }) | 234 }) |
| OLD | NEW |