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

Side by Side Diff: PRESUBMIT_test.py

Issue 1114593002: [android log] Add documentation and presubmit checks for log usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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.py ('k') | base/android/java/src/org/chromium/base/README_logging.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 802
803 output = PRESUBMIT._CheckUserActionUpdate(input_api, MockOutputApi()) 803 output = PRESUBMIT._CheckUserActionUpdate(input_api, MockOutputApi())
804 self.assertEqual( 804 self.assertEqual(
805 ('File %s line %d: %s is missing in ' 805 ('File %s line %d: %s is missing in '
806 'tools/metrics/actions/actions.xml. Please run ' 806 'tools/metrics/actions/actions.xml. Please run '
807 'tools/metrics/actions/extract_actions.py to update.' 807 'tools/metrics/actions/extract_actions.py to update.'
808 % (file_with_user_action, 1, 'NotInActionsXml')), 808 % (file_with_user_action, 1, 'NotInActionsXml')),
809 output[0].message) 809 output[0].message)
810 810
811 811
812 class LogUsageTest(unittest.TestCase):
813
814 def testCheckNoNewUtilLogUsage(self):
815 mock_input_api = MockInputApi()
816 mock_output_api = MockOutputApi()
817
818 mock_input_api.files = [
819 MockAffectedFile('RandomStuff.java', [
820 'random stuff'
821 ]),
822 MockAffectedFile('HasCrLog.java', [
823 'import org.chromium.base.Log;',
824 'some random stuff',
825 'Log.d("TAG", "foo");',
826 ]),
827 MockAffectedFile('HasAndroidLog.java', [
828 'import android.util.Log;',
829 'some random stuff',
830 'Log.d("TAG", "foo");',
831 ]),
832 MockAffectedFile('HasExplicitLog.java', [
833 'some random stuff',
834 'android.util.Log.d("TAG", "foo");',
835 ]),
836 MockAffectedFile('HasBothLog.java', [
837 'import org.chromium.base.Log;',
838 'some random stuff',
839 'Log.d("TAG", "foo");',
840 'android.util.Log.d("TAG", "foo");',
841 ]),
842 ]
843
844 warnings = PRESUBMIT._CheckNoNewUtilLogUsage(
845 mock_input_api, mock_output_api)
846
847 self.assertEqual(1, len(warnings))
848 self.assertEqual(2, len(warnings[0].items))
849 self.assertTrue('HasAndroidLog.java' in warnings[0].items[0])
850 self.assertTrue('HasExplicitLog.java' in warnings[0].items[1])
851
852
812 if __name__ == '__main__': 853 if __name__ == '__main__':
813 unittest.main() 854 unittest.main()
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | base/android/java/src/org/chromium/base/README_logging.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698