| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import glob | 6 import glob |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import subprocess | 10 import subprocess |
| 11 import sys | 11 import sys |
| 12 import unittest | 12 import unittest |
| 13 | 13 |
| 14 import PRESUBMIT | 14 import PRESUBMIT |
| 15 | 15 |
| 16 | 16 |
| 17 _TEST_DATA_DIR = 'base/test/data/presubmit' | 17 _TEST_DATA_DIR = 'base/test/data/presubmit' |
| 18 | 18 |
| 19 | 19 |
| 20 class MockInputApi(object): | 20 class MockInputApi(object): |
| 21 def __init__(self): | 21 def __init__(self): |
| 22 self.json = json | 22 self.json = json |
| 23 self.re = re | 23 self.re = re |
| 24 self.os_path = os.path | 24 self.os_path = os.path |
| 25 self.python_executable = sys.executable | 25 self.python_executable = sys.executable |
| 26 self.subprocess = subprocess | 26 self.subprocess = subprocess |
| 27 self.files = [] | 27 self.files = [] |
| 28 self.is_committing = False | 28 self.is_committing = False |
| 29 | 29 |
| 30 def AffectedFiles(self): | 30 def AffectedFiles(self, file_filter=None): |
| 31 return self.files | 31 return self.files |
| 32 | 32 |
| 33 def PresubmitLocalPath(self): | 33 def PresubmitLocalPath(self): |
| 34 return os.path.dirname(__file__) | 34 return os.path.dirname(__file__) |
| 35 | 35 |
| 36 def ReadFile(self, filename, mode='rU'): | 36 def ReadFile(self, filename, mode='rU'): |
| 37 for file_ in self.files: | 37 for file_ in self.files: |
| 38 if file_.LocalPath() == filename: | 38 if file_.LocalPath() == filename: |
| 39 return '\n'.join(file_.NewContents()) | 39 return '\n'.join(file_.NewContents()) |
| 40 # Otherwise, file is not in our mock API. | 40 # Otherwise, file is not in our mock API. |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 } | 756 } |
| 757 for master, bots in bots.iteritems(): | 757 for master, bots in bots.iteritems(): |
| 758 for bot in bots: | 758 for bot in bots: |
| 759 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), | 759 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), |
| 760 'bot=%s: expected %s, computed %s' % ( | 760 'bot=%s: expected %s, computed %s' % ( |
| 761 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) | 761 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) |
| 762 | 762 |
| 763 | 763 |
| 764 if __name__ == '__main__': | 764 if __name__ == '__main__': |
| 765 unittest.main() | 765 unittest.main() |
| OLD | NEW |