Adds a note in the "uninteresting mock method call" warning to advise people how to handle the warning.
Clarifies the purpose of utilities in gmock-port.h and adds guidance w.r.t. gmock-port.h vs gtest-port.h. Pulls in gtest r674.
This commit is contained in:
		
							parent
							
								
									18489fa4f8
								
							
						
					
					
						commit
						04ce8521f4
					
				| @ -30,8 +30,11 @@ | |||||||
| // Author: vadimb@google.com (Vadim Berman)
 | // Author: vadimb@google.com (Vadim Berman)
 | ||||||
| //
 | //
 | ||||||
| // Low-level types and utilities for porting Google Mock to various
 | // Low-level types and utilities for porting Google Mock to various
 | ||||||
| // platforms.  They are subject to change without notice.  DO NOT USE
 | // platforms.  All macros ending with _ and symbols defined in an
 | ||||||
| // THEM IN USER CODE.
 | // internal namespace are subject to change without notice.  Code
 | ||||||
|  | // outside Google Mock MUST NOT USE THEM DIRECTLY.  Macros that don't
 | ||||||
|  | // end with _ are part of Google Mock's public API and can be used by
 | ||||||
|  | // code outside Google Mock.
 | ||||||
| 
 | 
 | ||||||
| #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_ | #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_ | ||||||
| #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_ | #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_ | ||||||
| @ -40,8 +43,13 @@ | |||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <iostream> | #include <iostream> | ||||||
| 
 | 
 | ||||||
| // Most of the types needed for porting Google Mock are also required
 | // Most of the utilities needed for porting Google Mock are also
 | ||||||
| // for Google Test and are defined in gtest-port.h.
 | // required for Google Test and are defined in gtest-port.h.
 | ||||||
|  | //
 | ||||||
|  | // Note to maintainers: to reduce code duplication, prefer adding
 | ||||||
|  | // portability utilities to Google Test's gtest-port.h instead of
 | ||||||
|  | // here, as Google Mock depends on Google Test.  Only add a utility
 | ||||||
|  | // here if it's truly specific to Google Mock.
 | ||||||
| #include "gtest/internal/gtest-linked_ptr.h" | #include "gtest/internal/gtest-linked_ptr.h" | ||||||
| #include "gtest/internal/gtest-port.h" | #include "gtest/internal/gtest-port.h" | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -250,7 +250,14 @@ void ReportUninterestingCall(CallReaction reaction, const string& msg) { | |||||||
|       Log(kInfo, msg, 3); |       Log(kInfo, msg, 3); | ||||||
|       break; |       break; | ||||||
|     case kWarn: |     case kWarn: | ||||||
|       Log(kWarning, msg, 3); |       Log(kWarning, | ||||||
|  |           msg + | ||||||
|  |           "\nNOTE: You can safely ignore the above warning unless this " | ||||||
|  |           "call should not happen.  Do not suppress it by blindly adding " | ||||||
|  |           "an EXPECT_CALL() if you don't mean to enforce the call.  " | ||||||
|  |           "See http://code.google.com/p/googlemock/wiki/CookBook#" | ||||||
|  |           "Knowing_When_to_Expect for details.", | ||||||
|  |           3); | ||||||
|       break; |       break; | ||||||
|     default:  // FAIL
 |     default:  // FAIL
 | ||||||
|       Expect(false, NULL, -1, msg); |       Expect(false, NULL, -1, msg); | ||||||
|  | |||||||
| @ -2088,6 +2088,12 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture { | |||||||
|   // Tests how the flag affects uninteresting calls on a naggy mock.
 |   // Tests how the flag affects uninteresting calls on a naggy mock.
 | ||||||
|   void TestUninterestingCallOnNaggyMock(bool should_print) { |   void TestUninterestingCallOnNaggyMock(bool should_print) { | ||||||
|     NaggyMock<MockA> a; |     NaggyMock<MockA> a; | ||||||
|  |     const string note = | ||||||
|  |         "NOTE: You can safely ignore the above warning unless this " | ||||||
|  |         "call should not happen.  Do not suppress it by blindly adding " | ||||||
|  |         "an EXPECT_CALL() if you don't mean to enforce the call.  " | ||||||
|  |         "See http://code.google.com/p/googlemock/wiki/CookBook#" | ||||||
|  |         "Knowing_When_to_Expect for details."; | ||||||
| 
 | 
 | ||||||
|     // A void-returning function.
 |     // A void-returning function.
 | ||||||
|     CaptureStdout(); |     CaptureStdout(); | ||||||
| @ -2097,8 +2103,9 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture { | |||||||
|         should_print, |         should_print, | ||||||
|         "\nGMOCK WARNING:\n" |         "\nGMOCK WARNING:\n" | ||||||
|         "Uninteresting mock function call - returning directly.\n" |         "Uninteresting mock function call - returning directly.\n" | ||||||
|         "    Function call: DoA(5)\n" |         "    Function call: DoA(5)\n" + | ||||||
|         "Stack trace:\n", |         note + | ||||||
|  |         "\nStack trace:\n", | ||||||
|         "DoA"); |         "DoA"); | ||||||
| 
 | 
 | ||||||
|     // A non-void-returning function.
 |     // A non-void-returning function.
 | ||||||
| @ -2110,8 +2117,9 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture { | |||||||
|         "\nGMOCK WARNING:\n" |         "\nGMOCK WARNING:\n" | ||||||
|         "Uninteresting mock function call - returning default value.\n" |         "Uninteresting mock function call - returning default value.\n" | ||||||
|         "    Function call: Binary(2, 1)\n" |         "    Function call: Binary(2, 1)\n" | ||||||
|         "          Returns: false\n" |         "          Returns: false\n" + | ||||||
|         "Stack trace:\n", |         note + | ||||||
|  |         "\nStack trace:\n", | ||||||
|         "Binary"); |         "Binary"); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -75,6 +75,7 @@ GMOCK WARNING: | |||||||
| Uninteresting mock function call - returning default value. | Uninteresting mock function call - returning default value. | ||||||
|     Function call: Bar2(0, 1) |     Function call: Bar2(0, 1) | ||||||
|           Returns: false |           Returns: false | ||||||
|  | NOTE: You can safely ignore the above warning unless this call should not happen.  Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call.  See http://code.google.com/p/googlemock/wiki/CookBook#Knowing_When_to_Expect for details. | ||||||
| Stack trace: | Stack trace: | ||||||
| [       OK ] GMockOutputTest.UninterestingCall | [       OK ] GMockOutputTest.UninterestingCall | ||||||
| [ RUN      ] GMockOutputTest.UninterestingCallToVoidFunction | [ RUN      ] GMockOutputTest.UninterestingCallToVoidFunction | ||||||
| @ -82,6 +83,7 @@ Stack trace: | |||||||
| GMOCK WARNING: | GMOCK WARNING: | ||||||
| Uninteresting mock function call - returning directly. | Uninteresting mock function call - returning directly. | ||||||
|     Function call: Bar3(0, 1) |     Function call: Bar3(0, 1) | ||||||
|  | NOTE: You can safely ignore the above warning unless this call should not happen.  Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call.  See http://code.google.com/p/googlemock/wiki/CookBook#Knowing_When_to_Expect for details. | ||||||
| Stack trace: | Stack trace: | ||||||
| [       OK ] GMockOutputTest.UninterestingCallToVoidFunction | [       OK ] GMockOutputTest.UninterestingCallToVoidFunction | ||||||
| [ RUN      ] GMockOutputTest.RetiredExpectation | [ RUN      ] GMockOutputTest.RetiredExpectation | ||||||
| @ -266,6 +268,7 @@ Uninteresting mock function call - taking default action specified at: | |||||||
| FILE:#: | FILE:#: | ||||||
|     Function call: Bar2(2, 2) |     Function call: Bar2(2, 2) | ||||||
|           Returns: true |           Returns: true | ||||||
|  | NOTE: You can safely ignore the above warning unless this call should not happen.  Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call.  See http://code.google.com/p/googlemock/wiki/CookBook#Knowing_When_to_Expect for details. | ||||||
| Stack trace: | Stack trace: | ||||||
| 
 | 
 | ||||||
| GMOCK WARNING: | GMOCK WARNING: | ||||||
| @ -273,6 +276,7 @@ Uninteresting mock function call - taking default action specified at: | |||||||
| FILE:#: | FILE:#: | ||||||
|     Function call: Bar2(1, 1) |     Function call: Bar2(1, 1) | ||||||
|           Returns: false |           Returns: false | ||||||
|  | NOTE: You can safely ignore the above warning unless this call should not happen.  Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call.  See http://code.google.com/p/googlemock/wiki/CookBook#Knowing_When_to_Expect for details. | ||||||
| Stack trace: | Stack trace: | ||||||
| [       OK ] GMockOutputTest.UninterestingCallWithDefaultAction | [       OK ] GMockOutputTest.UninterestingCallWithDefaultAction | ||||||
| [ RUN      ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction | [ RUN      ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user