[googlemock: 785] Building with VS10

464 views
Skip to first unread message

liam mail

unread,
Apr 25, 2010, 6:22:21 PM4/25/10
to googl...@googlegroups.com
Has anyone managed to build the last gmock with VS10?
Firstly I got a few errors which I have seen before in other libaries, basically it is from using NULL or 0 with an implicit conversion to a void pointer in a template.

The error was pointing to :
2>          ..\test\gmock-printers_test.cc(848) : see reference to function template instantiation 'std::tr1::tuple<_Arg0,_Arg1,_Arg2,_Arg3,_Arg4,_Arg5,_Arg6,_Arg7,_Arg8,_Arg9>::tuple<bool,char,int,int,int,float,double,const char*const &,int,const char(&)[3]>(_Farg0 &&,_Farg1 &&,_Farg2 &&,_Farg3 &&,_Farg4 &&,_Farg5 &&,_Farg6 &&,_Farg7,_Farg8 &&,_Farg9)' being compiled

Notice the second to last is being determined to be an int, which after changing to the following lines with a cast I get 100's of link errors.

  const char* const str = "8";
  tuple<bool, char, short, testing::internal::Int32,  // NOLINT
      testing::internal::Int64, float, double, const char*, void*, string>
      t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, static_cast<void*>(NULL), "10");
  EXPECT_EQ("(false, 'a' (97), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
            " pointing to \"8\", NULL, \"10\")",
            Print(t10));

Liam

Vlad Losev

unread,
Apr 27, 2010, 5:41:35 PM4/27/10
to Google C++ Mocking Framework
Liam,

What version of Google Mock are you using? We have recently released 1.5, which should have this issue fixed. Also, it is helpful to see the full error message.
- Vlad

liam mail

unread,
Apr 27, 2010, 6:52:13 PM4/27/10
to Vlad Losev, googl...@googlegroups.com
I tried to compile the listed 1.5 download, now I have tried the trunk and the same void* error is present.

VS10 has removed the facitily to add additional paths via VCCLCompilerTool, which are noted in the conversion log:


Conversion Report - gmock.vcproj:
Converting project file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock.vcproj'.
Done converting to new project file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock.vcxproj'.
This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.
VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.



Conversion Report - gmock_config.vsprops:
Converting propertysheet file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock_config.vsprops' for configuration 'Debug|Win32'.
Done converting to new property sheet file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock_config.vsprops' for configuration 'Debug|Win32'.
Converting propertysheet file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock_config.vsprops' for configuration 'Release|Win32'.
Done converting to new property sheet file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock_config.vsprops' for configuration 'Release|Win32'.
Attribute 'ProjectType' of 'gmock_config' is not supported in this version and has been removed during conversion.
Attribute 'Version' of 'gmock_config' is not supported in this version and has been removed during conversion.


Conversion Report - gmock_link_test.vcproj:
Converting project file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock_link_test.vcproj'.
Web deployment to the local IIS server is no longer supported. The Web Deployment build tool has been removed from your project settings.
Done converting to new project file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock_link_test.vcxproj'.
This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.
VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Attribute 'CopyLocalDependencies' of 'ProjectReference' is not supported in this version and has been removed during conversion.
Attribute 'UseDependenciesInBuild' of 'ProjectReference' is not supported in this version and has been removed during conversion.


Conversion Report - gmock_main.vcproj:
Converting project file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock_main.vcproj'.
Done converting to new project file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock_main.vcxproj'.
This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.
VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Attribute 'CopyLocalDependencies' of 'ProjectReference' is not supported in this version and has been removed during conversion.
Attribute 'UseDependenciesInBuild' of 'ProjectReference' is not supported in this version and has been removed during conversion.


Conversion Report - gmock_test.vcproj:
Converting project file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock_test.vcproj'.
Web deployment to the local IIS server is no longer supported. The Web Deployment build tool has been removed from your project settings.
Done converting to new project file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock_test.vcxproj'.
This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.
VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Attribute 'CopyLocalDependencies' of 'ProjectReference' is not supported in this version and has been removed during conversion.
Attribute 'UseDependenciesInBuild' of 'ProjectReference' is not supported in this version and has been removed during conversion.


Conversion Report - gmock-spec-builders_test.vcproj:
Converting project file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock-spec-builders_test.vcproj'.
Web deployment to the local IIS server is no longer supported. The Web Deployment build tool has been removed from your project settings.
Done converting to new project file 'C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\gmock-spec-builders_test.vcxproj'.
This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.
VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Attribute 'CopyLocalDependencies' of 'ProjectReference' is not supported in this version and has been removed during conversion.
Attribute 'UseDependenciesInBuild' of 'ProjectReference' is not supported in this version and has been removed during conversion.


-------------------------

Adding the gtest include directory and the define as in "Microsoft.cpp.<Platform>.users" as listed here: http://blogs.msdn.com/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx

Aslo adding the static_cast<void*> to the previous mentioned line generates no link errors yet conversion errors.

Error    1    error C2664: '`anonymous-namespace'::Helper' : cannot convert parameter 1 from 'const `anonymous-namespace'::Result *' to '`anonymous-namespace'::MockC *'    c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h    214
Error    2    error C2866: 'testing::internal::ImplicitlyConvertible<From,To>::value' : a const static data member of a managed type must be initialized at the point of declaration    c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h    214
Error    3    error C2664: '`anonymous-namespace'::Helper' : cannot convert parameter 1 from 'const `anonymous-namespace'::Result *' to '`anonymous-namespace'::MockC *'    c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h    214
Error    4    error C2866: 'testing::internal::ImplicitlyConvertible<From,To>::value' : a const static data member of a managed type must be initialized at the point of declaration    c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h    214
Error    5    error C2975: 'bool_value' : invalid template argument for 'testing::internal::bool_constant', expected compile-time constant expression    c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h    395



-----------------
And the full listing:
1>------ Build started: Project: gmock, Configuration: Debug Win32 ------
1>  gmock.vcxproj -> C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\Debug\gmock.lib
2>------ Build started: Project: gmock_main, Configuration: Debug Win32 ------
3>------ Build started: Project: gmock-spec-builders_test, Configuration: Debug Win32 ------
3>  gmock-spec-builders_test.cc
2>  gmock_main.vcxproj -> C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\Debug\gmock_main.lib
4>------ Build started: Project: gmock_link_test, Configuration: Debug Win32 ------
3>c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h(214): error C2664: '`anonymous-namespace'::Helper' : cannot convert parameter 1 from 'const `anonymous-namespace'::Result *' to '`anonymous-namespace'::MockC *'
3>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h(394) : see reference to class template instantiation 'testing::internal::ImplicitlyConvertible<From,To>' being compiled
3>          with
3>          [
3>              From=const `anonymous-namespace'::Result *,
3>              To=const ProtocolMessage *
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-printers.h(178) : see reference to class template instantiation 'testing::internal::IsAProtocolMessage<T>' being compiled
3>          with
3>          [
3>              T=`anonymous-namespace'::Result
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-printers.h(220) : see reference to function template instantiation 'std::basic_ostream<_Elem,_Traits> &testing::internal2::operator <<<char,std::char_traits<char>,T>(std::basic_ostream<_Elem,_Traits> &,const T &)' being compiled
3>          with
3>          [
3>              _Elem=char,
3>              _Traits=std::char_traits<char>,
3>              T=`anonymous-namespace'::Result
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-printers.h(299) : see reference to function template instantiation 'void testing_internal::DefaultPrintNonContainerTo<T>(const T &,std::ostream *)' being compiled
3>          with
3>          [
3>              T=`anonymous-namespace'::Result
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-printers.h(337) : see reference to function template instantiation 'void testing::internal::DefaultPrintTo<T>(testing::internal::IsNotContainer,testing::internal::false_type,const T &,std::ostream *)' being compiled
3>          with
3>          [
3>              T=`anonymous-namespace'::Result
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-printers.h(547) : see reference to function template instantiation 'void testing::internal::PrintTo<T>(const T &,std::ostream *)' being compiled
3>          with
3>          [
3>              T=`anonymous-namespace'::Result
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-printers.h(538) : while compiling class template member function 'void testing::internal::UniversalPrinter<T>::Print(const T &,std::ostream *)'
3>          with
3>          [
3>              T=`anonymous-namespace'::Result
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-spec-builders.h(1272) : see reference to class template instantiation 'testing::internal::UniversalPrinter<T>' being compiled
3>          with
3>          [
3>              T=`anonymous-namespace'::Result
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-spec-builders.h(1270) : while compiling class template member function 'void testing::internal::ActionResultHolder<T>::PrintAsActionResult(std::ostream *) const'
3>          with
3>          [
3>              T=`anonymous-namespace'::Result
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-spec-builders.h(1746) : see reference to class template instantiation 'testing::internal::ActionResultHolder<T>' being compiled
3>          with
3>          [
3>              T=`anonymous-namespace'::Result
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-spec-builders.h(1708) : while compiling class template member function '`anonymous-namespace'::Result testing::internal::FunctionMockerBase<F>::InvokeWith(const std::tr1::tuple<_Arg0> &)'
3>          with
3>          [
3>              F=`anonymous-namespace'::Result (int),
3>              _Arg0=int
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\gmock-generated-function-mockers.h(80) : see reference to class template instantiation 'testing::internal::FunctionMockerBase<F>' being compiled
3>          with
3>          [
3>              F=`anonymous-namespace'::Result (int)
3>          ]
3>          c:\documents and settings\dmail\my documents\projects\gmock150\test\gmock-spec-builders_test.cc(111) : see reference to class template instantiation 'testing::internal::FunctionMocker<Function>' being compiled
3>          with
3>          [
3>              Function=`anonymous-namespace'::Result (int)
3>          ]
3>c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h(214): error C2866: 'testing::internal::ImplicitlyConvertible<From,To>::value' : a const static data member of a managed type must be initialized at the point of declaration
3>          with
3>          [
3>              From=const `anonymous-namespace'::Result *,
3>              To=const ProtocolMessage *
3>          ]
3>c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h(214): error C2664: '`anonymous-namespace'::Helper' : cannot convert parameter 1 from 'const `anonymous-namespace'::Result *' to '`anonymous-namespace'::MockC *'
3>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
3>          c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h(395) : see reference to class template instantiation 'testing::internal::ImplicitlyConvertible<From,To>' being compiled
3>          with
3>          [
3>              From=const `anonymous-namespace'::Result *,
3>              To=const proto2::Message *
3>          ]
3>c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h(214): error C2866: 'testing::internal::ImplicitlyConvertible<From,To>::value' : a const static data member of a managed type must be initialized at the point of declaration
3>          with
3>          [
3>              From=const `anonymous-namespace'::Result *,
3>              To=const proto2::Message *
3>          ]
3>c:\documents and settings\dmail\my documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h(395): error C2975: 'bool_value' : invalid template argument for 'testing::internal::bool_constant', expected compile-time constant expression
3>          c:\documents and settings\dmail\my documents\projects\gmock150\gtest\include\gtest\internal\gtest-port.h(1236) : see declaration of 'bool_value'
5>------ Build started: Project: gmock_test, Configuration: Debug Win32 ------
4>  gmock_link_test.vcxproj -> C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\Debug\gmock_link_test.exe
5>  gmock_test.vcxproj -> C:\Documents and Settings\dmail\My Documents\projects\gmock150\msvc\Debug\gmock_test.exe
========== Build: 4 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Liam

liam

unread,
Apr 28, 2010, 6:50:40 PM4/28/10
to Google C++ Mocking Framework
After testing the download version of 1.50 with vs9 the NiceMock tests
fail.

..\test\gmock-nice-strict_test.cc(119): error: Value of:
GetCapturedStdout().c_str()
Actual: "
Uninteresting mock function call - returning directly.
Function call: DoThis()
Stack trace:

Uninteresting mock function call - returning default value.
Function call: DoThat(true)
Returns: 0
Stack trace:
"
Expected: ""
..\test\gmock-nice-strict_test.cc(132): error: Value of:
GetCapturedStdout().c_str()
Actual: "
Uninteresting mock function call - taking default action specified at:
..\test\gmock-nice-strict_test.cc:127:
Function call: DoThis()
Stack trace:
"
Expected: ""
The program '[2024] gmock_test.exe: Native' has exited with code 1
(0x1).


There is also a warning about scope when building, neither of these
problems were present in 1.4 IIRC

5>c:\Documents and Settings\dmail\My Documents\Downloads\dev
\gmock-1.5.0MSCVv9\gmock-1.5.0\gtest\include\gtest/internal/gtest-
tuple.h(270) : warning C4413: ' ' : reference member is initialized to
a temporary that doesn't persist after the constructor exits
5> ..\test\gmock-generated-actions_test.cc(379) : see reference
to function template instantiation
'std::tr1::tuple<T0,T1,T2>::tuple<const char*,int,int>(const
std::tr1::tuple<const char *,T1,T2,T3,T4,T5,T6,T7,T8,T9> &)' being
compiled
5> with
5> [
5> T0=const
std::basic_string<char,std::char_traits<char>,std::allocator<char>> &,
5> T1=int,
5> T2=int,
5> T3=void,
5> T4=void,
5> T5=void,
5> T6=void,
5> T7=void,
5> T8=void,
5> T9=void
5> ]

Liam

Vlad Losev

unread,
May 1, 2010, 5:47:07 PM5/1/10
to liam mail, googl...@googlegroups.com
Hi Liam,

This seems like a compiler bug to me. If the compiler is unable to cast the argument to be usable by the overload defined in gmock-internal-utils.h:201 it should not issue an error but instead use the overload defined in line 202. Zhanyong, what's your opinion on the matter?

The rest of the errors seem to be induced by this one. 
Regards,
Vlad

Vlad Losev

unread,
May 1, 2010, 5:50:12 PM5/1/10
to liam mail, Zhanyong Wan, googl...@googlegroups.com
[Adding Zhanyong explicitly]

Vlad Losev

unread,
May 1, 2010, 5:57:16 PM5/1/10
to Google C++ Mocking Framework
Hi,

On Wed, Apr 28, 2010 at 3:50 PM, liam <liam...@googlemail.com> wrote:
After testing the download version of 1.50 with vs9 the NiceMock tests
fail.

..\test\gmock-nice-strict_test.cc(119): error: Value of:
GetCapturedStdout().c_str()
 Actual: "
Uninteresting mock function call - returning directly.
   Function call: DoThis()
Stack trace:

Uninteresting mock function call - returning default value.
   Function call: DoThat(true)
         Returns: 0
Stack trace:
"
Expected: ""
..\test\gmock-nice-strict_test.cc(132): error: Value of:
GetCapturedStdout().c_str()
 Actual: "
Uninteresting mock function call - taking default action specified at:
..\test\gmock-nice-strict_test.cc:127:
   Function call: DoThis()
Stack trace:
"
Expected: ""
The program '[2024] gmock_test.exe: Native' has exited with code 1
(0x1).

Unfortunately, I wasn't able to reproduce the failures you report; gmock-nice-strict_test passes fine for me. Here are all the compiler options I use:
cl /c test\gmock_test.cc -wd4413 -wd4373 /TP -GS -W4 -WX -RTCs -RTCu -nologo -J -Zi -Od -MTd -wd4127 /DGTEST_HAS_TR1_TUPLE=1 /DGTEST_USE_OWN_TR1_TUPLE=0 /D_UNICODE /DUNICODE /DWIN32 /D_WIN32 /DSTRICT /DWIN32_LEAN_AND_MEAN /D_HAS_EXCEPTIONS=0 /DDEBUG /D_DEBUG /I. /Iinclude /Igtest\include


There is also a warning about scope when building, neither of these
problems were present in 1.4 IIRC

5>c:\Documents and Settings\dmail\My Documents\Downloads\dev
\gmock-1.5.0MSCVv9\gmock-1.5.0\gtest\include\gtest/internal/gtest-
tuple.h(270) : warning C4413: ' ' : reference member is initialized to
a temporary that doesn't persist after the constructor exits

This is a valid warning, which generally marks some dangerous code. The code is OK in this context, and you can ignore it here.
 
5>        ..\test\gmock-generated-actions_test.cc(379) : see reference
to function template instantiation
'std::tr1::tuple<T0,T1,T2>::tuple<const char*,int,int>(const
std::tr1::tuple<const char *,T1,T2,T3,T4,T5,T6,T7,T8,T9> &)' being
compiled
5>        with
5>        [
5>            T0=const
std::basic_string<char,std::char_traits<char>,std::allocator<char>> &,
5>            T1=int,
5>            T2=int,
5>            T3=void,
5>            T4=void,
5>            T5=void,
5>            T6=void,
5>            T7=void,
5>            T8=void,
5>            T9=void
5>        ]

I also see this warning, and it looks like a bogus one to me. The constructor in question doesn't initialize any references.

Liam

- Vlad

Serhiy Yakovyn

unread,
May 4, 2010, 1:51:19 PM5/4/10
to Google C++ Mocking Framework
Hi,

I have also the same 2 tests failed when running gmock_test.exe built with
VS2008 SP 1.

Thanks,
Serhiy Y

Serhiy Yakovyn

unread,
May 4, 2010, 2:57:58 PM5/4/10
to Google C++ Mocking Framework
I have found the issue's root.

d:\C++\gmock-1.5.0\test\gmock-internal-utils_test.cc at line 565 contains

// Tests that when the stack_frames_to_skip parameter is negative,
// Log() doesn't include the stack trace in the output.
TEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) {
GMOCK_FLAG(verbose) = kInfoVerbosity;
CaptureStdout();
Log(INFO, "Test log.\n", -1);
EXPECT_STREQ("\nTest log.\n", GetCapturedStdout().c_str());
}

And the test above leaves GMOCK_FLAG(verbose) equal to "kInfoVerbosity"

In turn, d:\C++\gmock-1.5.0\test\gmock-nice-strict_test.cc at line 112
contains

// Tests that a nice mock generates no warning for uninteresting calls.
TEST(NiceMockTest, NoWarningForUninterestingCall) {
NiceMock<MockFoo> nice_foo;

CaptureStdout();
nice_foo.DoThis();
nice_foo.DoThat(true);
EXPECT_STREQ("", GetCapturedStdout().c_str());
}

Which depends on GMOCK_FLAG(verbose) value and produce not empty string when
GMOCK_FLAG(verbose) equal to "kInfoVerbosity"

As a result EXPECT_STREQ("", GetCapturedStdout().c_str()) from the test
above fails.


There is also another test that doesn't restore global value of
GMOCK_FLAG(verbose) and can cause similar issues.

It is in d:\C++\gmock-1.5.0\test\gmock-nice-strict_test.cc at line 135 (see
below):

// Tests that a nice mock generates informational logs for
// uninteresting calls.
TEST(NiceMockTest, InfoForUninterestingCall) {
NiceMock<MockFoo> nice_foo;

GMOCK_FLAG(verbose) = "info";
CaptureStdout();
nice_foo.DoThis();
EXPECT_THAT(GetCapturedStdout(),
HasSubstr("Uninteresting mock function call"));

CaptureStdout();
nice_foo.DoThat(true);
EXPECT_THAT(GetCapturedStdout(),
HasSubstr("Uninteresting mock function call"));
}


Serhiy Y

-----Original Message-----
From: Serhiy Yakovyn [mailto:syak...@gmail.com]
Sent: Tuesday, May 04, 2010 8:51 PM
To: 'Google C++ Mocking Framework'
Subject: RE: [googlemock: 790] Re: Building with VS10

Hi,

I have also the same 2 tests failed when running gmock_test.exe built with
VS2008 SP 1.

Thanks,
Serhiy Y

-----Original Message-----
From: googl...@googlegroups.com [mailto:googl...@googlegroups.com] On
Behalf Of liam
Sent: Thursday, April 29, 2010 1:51 AM
To: Google C++ Mocking Framework
Subject: [googlemock: 790] Re: Building with VS10

Serhiy Yakovyn

unread,
May 4, 2010, 3:09:05 PM5/4/10
to Google C++ Mocking Framework
To fix the issue it is enough to change TEST(LogTest,
NoStackTraceWhenStackFramesToSkipIsNegative) as shown below:

// Tests that when the stack_frames_to_skip parameter is negative,
// Log() doesn't include the stack trace in the output.
TEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) {
const string old_flag = GMOCK_FLAG(verbose);
GMOCK_FLAG(verbose) = kInfoVerbosity;
CaptureStdout();
Log(INFO, "Test log.\n", -1);
EXPECT_STREQ("\nTest log.\n", GetCapturedStdout().c_str());
GMOCK_FLAG(verbose) = old_flag;
}

I will try to incorporate this as a patch, but don't know when I will have
free time again to do that.

Vlad Losev

unread,
May 4, 2010, 4:10:28 PM5/4/10
to Google C++ Mocking Framework
Hi Serhiy,

Thanks for the through investigation. I've added issue 110 to track this problem.

Regards,
Vlad

Vlad Losev

unread,
May 5, 2010, 3:57:04 PM5/5/10
to Google C++ Mocking Framework
On Tue, May 4, 2010 at 1:10 PM, Vlad Losev <vl...@losev.com> wrote:
Hi Serhiy,

Thanks for the through investigation. I've added issue 110 to track this problem.

This has been fixed in SVN r293. 

liam mail

unread,
May 5, 2010, 4:35:45 PM5/5/10
to Vlad Losev, googl...@googlegroups.com
On 5 May 2010 20:57, Vlad Losev <vl...@losev.com> wrote:


On Tue, May 4, 2010 at 1:10 PM, Vlad Losev <vl...@losev.com> wrote:
Hi Serhiy,

Thanks for the through investigation. I've added issue 110 to track this problem.

This has been fixed in SVN r293. 
 

Thanks.
Next time I boot into Windows I will check out and compile for vs9 and also have a look and see if I can create a minimal none working sample of the vs10 error, it would not be the first conversion error I have seen in vs10 which is bogus.

Before posting to the list I tried to extract the code and force the error. Replace the lines with code I know compiles on the platform, as I use very similar code to the lines you point out above, yet had no joy.
Liam

 

Niall

unread,
May 9, 2010, 11:14:10 AM5/9/10
to Google C++ Mocking Framework
On May 2, 9:47 am, Vlad Losev <vladlo...@gmail.com> wrote:

[snip]

> > 3>c:\documents and settings\dmail\my
> > documents\projects\gmock150\include\gmock\internal\gmock-internal-utils.h(2 14):
> > error C2664: '`anonymous-namespace'::Helper' : cannot convert parameter 1
> > from 'const `anonymous-namespace'::Result *' to
> > '`anonymous-namespace'::MockC *'
>
> This seems like a compiler bug to me. If the compiler is unable to cast the
> argument to be usable by the overload defined in gmock-internal-utils.h:201
> it should not issue an error but instead use the overload defined in line
> 202. Zhanyong, what's your opinion on the matter?
>
> The rest of the errors seem to be induced by this one.
>

Not sure if this is a compiler bug or not (what does the c++ standard
have to say about overloading varargs methods?), but it's easily
fixable by using the new std::is_convertible available in VS10:

template <typename From, typename To>
class ImplicitlyConvertible {
public:
static const bool value = std::is_convertible<From, To>::value;
};

Niall.

Vlad Losev

unread,
May 9, 2010, 4:21:16 PM5/9/10
to Google C++ Mocking Framework
Niall,

We don't currently have access to VS10 and thus cannot test code for it. Would you like to write a patch that provides VS10 support? Please see http://code.google.com/p/googlemock/wiki/DevGuide#Contributing_Code on how to submit one.
Cheers,
Vlad

liam mail

unread,
May 9, 2010, 4:45:25 PM5/9/10
to googl...@googlegroups.com
Sorry I did not realise you never had access to vs10 and I have been in no hurry to boot windows :)
Without checking it and also assuming Niall has not, I do not think std::is_convertible will solve the problem, due to the reason I stated earlier that I use very similar code which compiles no problem in VS10.
I will boot into windows at the first chance I get, but you do realise you can download the express version which is free or the full version as a trial.
Liam

Tiki

unread,
May 21, 2010, 6:05:35 PM5/21/10
to Google C++ Mocking Framework
Hi Niall and others,

I managed to get the gmock-1.5.0 to work with VS10. Here is a list of
changes I had to make after converting the project:

- gmock-printers_test.cc (line 848): NULL pointer for the tuple
constructor has to be cast with static_cast<void*>(NULL), otherwise it
will be treated as int
- gmock-internal-utils.h (lines 201, 202, 214 218): Helper function
has to be renamed to get around a compiler bug - the VS10 compiler
confuses the ImplicitlyConvertible<From, To>::Helper to 'anonymous-
namespace'::Helper declared in gmock-spec-builders_test.cc (line 2362)
when using the type MockC* in the tests (I tried using
ImplicitlyConvertible<From, To>::Helper instead of just Helper to
force the correct one but that didn't work either). I didn't try the
std::is_convertible (which might work) but simply renaming the Helper
to ConvertHelper fixed the problem.
- gmock_test.vcxproj: add reference to the gmock project (VS10 project
conversion seems to lose library dependencies every now and then?)
- gmock-internal-utils_test.cc:
NoStackTraceWhenStackFramesToSkipIsNegative has to be changed
according to Serhiy's example above to make all tests pass

Hope someone will find this information useful.

cheers,
Tiki

liam mail

unread,
May 29, 2010, 5:57:55 PM5/29/10
to googl...@googlegroups.com
Yes I got it to compile aswell yet I did not see the point of posting the information here as the first error which was mentioned over a month ago has still not been fixed and committed to svn; instead it was just moved to gtest and ignored!!

http://code.google.com/p/googletest/source/browse/trunk/test/gtest-printers_test.cc


Vlad Losev

unread,
May 29, 2010, 8:17:36 PM5/29/10
to googl...@googlegroups.com
Hi Liam,
It makes no sense for us to write code (including fixes) for platforms where we cannot test it. As I've already said in this conversation, VS10 is one of those systems - we don't have access to it. However, if you submit a patch  for such a platform, and can vouch for it passing tests there, we'll gladly accept it, test it on the platforms we do have access to, and merge it into the trunk.

If you do wish to submit such a patch, please see the wiki page that describes the process. Don't be afraid - people have already done this for C++ Builder, SunStudio on Solaris, and AIX, among others.

Regards,
Vlad
Reply all
Reply to author
Forward
0 new messages