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

Side by Side Diff: PRESUBMIT_test_mocks.py

Issue 929043002: Add a presubmit check that warns about declaring Singleton<T> in header files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added presubmit test Created 5 years, 10 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
« no previous file with comments | « PRESUBMIT_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 json 5 import json
6 import os 6 import os
7 import re 7 import re
8 import subprocess 8 import subprocess
9 import sys 9 import sys
10 10
(...skipping 11 matching lines...) Expand all
22 self.os_path = os.path 22 self.os_path = os.path
23 self.python_executable = sys.executable 23 self.python_executable = sys.executable
24 self.subprocess = subprocess 24 self.subprocess = subprocess
25 self.files = [] 25 self.files = []
26 self.is_committing = False 26 self.is_committing = False
27 self.change = MockChange([]) 27 self.change = MockChange([])
28 28
29 def AffectedFiles(self, file_filter=None): 29 def AffectedFiles(self, file_filter=None):
30 return self.files 30 return self.files
31 31
32 def AffectedSourceFiles(self, file_filter=None):
33 return self.files
34
32 def PresubmitLocalPath(self): 35 def PresubmitLocalPath(self):
33 return os.path.dirname(__file__) 36 return os.path.dirname(__file__)
34 37
35 def ReadFile(self, filename, mode='rU'): 38 def ReadFile(self, filename, mode='rU'):
36 for file_ in self.files: 39 for file_ in self.files:
37 if file_.LocalPath() == filename: 40 if file_.LocalPath() == filename:
38 return '\n'.join(file_.NewContents()) 41 return '\n'.join(file_.NewContents())
39 # Otherwise, file is not in our mock API. 42 # Otherwise, file is not in our mock API.
40 raise IOError, "No such file or directory: '%s'" % filename 43 raise IOError, "No such file or directory: '%s'" % filename
41 44
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 104
102 This class can be used in presubmit unittests to mock the query of the 105 This class can be used in presubmit unittests to mock the query of the
103 current change. 106 current change.
104 """ 107 """
105 108
106 def __init__(self, changed_files): 109 def __init__(self, changed_files):
107 self._changed_files = changed_files 110 self._changed_files = changed_files
108 111
109 def LocalPaths(self): 112 def LocalPaths(self):
110 return self._changed_files 113 return self._changed_files
OLDNEW
« no previous file with comments | « PRESUBMIT_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698