summaryrefslogtreecommitdiff
path: root/scripts/gmock_doctor.py
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2009-05-14 20:55:30 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2009-05-14 20:55:30 +0000
commit81b0178ca3eeb56b28af98572b271eb3f973c92c (patch)
tree5d286c8a70d91a0f100523f64ad17d316e8f25f7 /scripts/gmock_doctor.py
parentc4b276af9d4f57afcea0934ba7461e3bb592737b (diff)
downloadgooglemock-81b0178ca3eeb56b28af98572b271eb3f973c92c.tar.gz
Finishes SafeMatcherCast by catching lossy arithmetic conversions at compile-time; uses ACTION_TEMPLATE to simplify the definition of many actions; makes mock object uncopyable; teaches gmock doctor about wrong MOCK_METHODn.
git-svn-id: http://googlemock.googlecode.com/svn/trunk@155 8415998a-534a-0410-bf83-d39667b30386
Diffstat (limited to 'scripts/gmock_doctor.py')
-rwxr-xr-xscripts/gmock_doctor.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/scripts/gmock_doctor.py b/scripts/gmock_doctor.py
index ca7935c..907089e 100755
--- a/scripts/gmock_doctor.py
+++ b/scripts/gmock_doctor.py
@@ -36,7 +36,7 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
import re
import sys
-_VERSION = '0.1.0.80421'
+_VERSION = '1.0.0'
_COMMON_GMOCK_SYMBOLS = [
# Matchers
@@ -148,11 +148,14 @@ Please use ReturnRef() instead."""
def _NeedToReturnSomethingDiagnoser(msg):
"""Diagnoses the NRS disease, given the error messages by gcc."""
- regex = (r'(?P<file>.*):(?P<line>\d+):\s+instantiated from here\n'
- r'.*gmock-actions\.h.*error: void value not ignored')
+ regex = (r'(?P<file>.*):(?P<line>\d+):\s+'
+ r'(instantiated from here\n.'
+ r'*gmock-actions\.h.*error: void value not ignored)'
+ r'|(error: control reaches end of non-void function)')
diagnosis = """%(file)s:%(line)s:
You are using an action that returns void, but it needs to return
-*something*. Please tell it *what* to return."""
+*something*. Please tell it *what* to return. Perhaps you can use
+the pattern DoAll(some_action, Return(some_value))?"""
return _GenericDiagnoser('NRS', 'Need to Return Something',
regex, diagnosis, msg)
@@ -324,6 +327,23 @@ Note: the line number may be off; please fix all instances of Return(NULL)."""
regex, diagnosis, msg)
+def _WrongMockMethodMacroDiagnoser(msg):
+ """Diagnoses the WMM disease, given the error messages by gcc."""
+
+ regex = (r'(?P<file>.*):(?P<line>\d+):\s+'
+ r'.*this_method_does_not_take_(?P<wrong_args>\d+)_argument.*\n'
+ r'.*\n'
+ r'.*candidates are.*FunctionMocker<[^>]+A(?P<args>\d+)\)>'
+ )
+
+ diagnosis = """%(file)s:%(line)s:
+You are using MOCK_METHOD%(wrong_args)s to define a mock method that has
+%(args)s arguments. Use MOCK_METHOD%(args)s (or MOCK_CONST_METHOD%(args)s,
+MOCK_METHOD%(args)s_T, MOCK_CONST_METHOD%(args)s_T as appropriate) instead."""
+ return _GenericDiagnoser('WMM', 'Wrong MOCK_METHODn macro',
+ regex, diagnosis, msg)
+
+
_DIAGNOSERS = [
_IncompleteByReferenceArgumentDiagnoser,
@@ -337,6 +357,7 @@ _DIAGNOSERS = [
_OverloadedFunctionMatcherDiagnoser,
_OverloadedMethodActionDiagnoser1,
_OverloadedMethodActionDiagnoser2,
+ _WrongMockMethodMacroDiagnoser,
]