Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prig test run crashing (when a nested static, unstubbed method is called) #89

Open
andy250 opened this issue Jan 26, 2017 · 40 comments
Open

Comments

@andy250
Copy link

andy250 commented Jan 26, 2017

I have a problem with couple of my tests. I generally observed that prig has issues with static methods with optional arguments. Not always though - I tried to reproduce this on a side project but I could not. However in my tests (fairly large solution) there are a few which had optional arguments, and they crashed the whole test run. Refactoring to methods without optional arguments solved it... for some of the. There are few tests which crash even after optional args have been removed. When I am running the test in the console:
prig run -process "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow \vstest.console.exe" -arguments "PrigTests.dll"
the process crashes, I get popup "program stopped working" then I click the "debug" button and I can get this stack trace in VS:
https://www.screencast.com/t/jvesh3Yrx
This doesn't tell me much though. Anyone has a clue what might be wrong? I am willing to make further investigation and provide more details on this tomorrow.

@urasandesu
Copy link
Owner

Thank you for the reporting! But it seems a difficult problem...

Possibly, Prig was outputting some error log. By default, it is in the directory %ALLUSERSPROFILE%\chocolatey\lib\Prig\tools\log. If possible, could you share it to me?

@andy250
Copy link
Author

andy250 commented Jan 27, 2017

Here it is, but I suspect these are not the errors I was referring to:

2017/01/26 10:39:12.283066,ERROR,0x00002648,11,0x00002ef8," Weaver.cpp(175): Throw in function long __stdcall CWeaverDetail::CWeaverImpl::InitializeCore(struct IUnknown *)
Dynamic exception type: class boost::exception_detail::clone_impl
std::exception::what: The package which has the source """"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\14.0.0"""" is not found.
[struct Urasandesu::CppAnonym::tag_stack_trace *] = at ?save_object_data@?$oserializer@Vxml_woarchive@archive@boost@@VPath@filesystem@3@@detail@archive@boost@@UBEXAAVbasic_oarchive@234@PBX@Z in C:\ProgramData\chocolatey\lib\Prig\tools\x86\Urasandesu.Prig.dll
at ?save_object_data@?$oserializer@Vxml_woarchive@archive@boost@@VPath@filesystem@3@@detail@archive@boost@@UBEXAAVbasic_oarchive@234@PBX@Z in C:\ProgramData\chocolatey\lib\Prig\tools\x86\Urasandesu.Prig.dll
at GetHistoryFileDirectory in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at GetHistoryFileDirectory in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at GetHistoryFileDirectory in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at IEE in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at IEE in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at SetRuntimeInfo in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at DllRegisterServerInternal in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at SetRuntimeInfo in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at _CorExeMain in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at _CorExeMain in C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll
at _CorExeMain in C:\Windows\SYSTEM32\MSCOREE.DLL
at BaseThreadInitThunk in C:\Windows\SYSTEM32\KERNEL32.dll
at RtlSetCurrentTransaction in C:\Windows\SYSTEM32\ntdll.dll
at RtlSetCurrentTransaction in C:\Windows\SYSTEM32\ntdll.dll

","C:\Users\urasa\Prig\Swathe\Urasandesu.Swathe\Urasandesu/Swathe/Profiling/ICorProfilerCallbackImpl.h",262,"long __stdcall CWeaverDetail::CWeaverImpl::InitializeCore(struct IUnknown *)=>Weaver.cpp,115","if (regex_search(procPath, wregex(targetProcName)))=>Weaver.cpp,139"
2017/01/26 12:00:47.667896,ERROR,0x0000264c,11,0x00002724," Weaver.cpp(175): Throw in function long __stdcall CWeaverDetail::CWeaverImpl::InitializeCore(struct IUnknown *)
Dynamic exception type: class boost::exception_detail::clone_impl
std::exception::what: The package which has the source """"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\14.0.0"""" is not found.
[struct Urasandesu::CppAnonym::tag_stack_trace *] = at ?save_object_data@?$oserializer@Vxml_woarchive@archive@boost@@VPath@filesystem@3@@detail@archive@boost@@UBEXAAVbasic_oarchive@234@PBX@Z in C:\ProgramData\chocolatey\lib\Prig\tools\x86\Urasandesu.Prig.dll
at ?save_object_data@?$oserializer@Vxml_woarchive@archive@boost@@VPath@filesystem@3@@detail@archive@boost@@UBEXAAVbasic_oarchive@234@PBX@Z in C:\ProgramData\chocolatey\lib\Prig\tools\x86\Urasandesu.Prig.dll
at GetHistoryFileDirectory in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at GetHistoryFileDirectory in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at GetHistoryFileDirectory in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at IEE in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at IEE in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at SetRuntimeInfo in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at DllRegisterServerInternal in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at SetRuntimeInfo in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at _CorExeMain in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at _CorExeMain in C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll
at _CorExeMain in C:\Windows\SYSTEM32\MSCOREE.DLL
at BaseThreadInitThunk in C:\Windows\SYSTEM32\KERNEL32.dll
at RtlSetCurrentTransaction in C:\Windows\SYSTEM32\ntdll.dll
at RtlSetCurrentTransaction in C:\Windows\SYSTEM32\ntdll.dll

","C:\Users\urasa\Prig\Swathe\Urasandesu.Swathe\Urasandesu/Swathe/Profiling/ICorProfilerCallbackImpl.h",262,"long __stdcall CWeaverDetail::CWeaverImpl::InitializeCore(struct IUnknown *)=>Weaver.cpp,115","if (regex_search(procPath, wregex(targetProcName)))=>Weaver.cpp,139"
2017/01/26 12:58:18.243092,ERROR,0x00002d2c,11,0x00001318," Weaver.cpp(175): Throw in function long __stdcall CWeaverDetail::CWeaverImpl::InitializeCore(struct IUnknown *)
Dynamic exception type: class boost::exception_detail::clone_impl
std::exception::what: The package which has the source """"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\14.0.0"""" is not found.
[struct Urasandesu::CppAnonym::tag_stack_trace *] = at ?save_object_data@?$oserializer@Vxml_woarchive@archive@boost@@VPath@filesystem@3@@detail@archive@boost@@UBEXAAVbasic_oarchive@234@PBX@Z in C:\ProgramData\chocolatey\lib\Prig\tools\x86\Urasandesu.Prig.dll
at ?save_object_data@?$oserializer@Vxml_woarchive@archive@boost@@VPath@filesystem@3@@detail@archive@boost@@UBEXAAVbasic_oarchive@234@PBX@Z in C:\ProgramData\chocolatey\lib\Prig\tools\x86\Urasandesu.Prig.dll
at GetHistoryFileDirectory in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at GetHistoryFileDirectory in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at GetHistoryFileDirectory in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at IEE in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at IEE in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at SetRuntimeInfo in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at DllRegisterServerInternal in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at SetRuntimeInfo in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at _CorExeMain in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
at _CorExeMain in C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll
at _CorExeMain in C:\Windows\SYSTEM32\MSCOREE.DLL
at BaseThreadInitThunk in C:\Windows\SYSTEM32\KERNEL32.dll
at RtlSetCurrentTransaction in C:\Windows\SYSTEM32\ntdll.dll
at RtlSetCurrentTransaction in C:\Windows\SYSTEM32\ntdll.dll

","C:\Users\urasa\Prig\Swathe\Urasandesu.Swathe\Urasandesu/Swathe/Profiling/ICorProfilerCallbackImpl.h",262,"long __stdcall CWeaverDetail::CWeaverImpl::InitializeCore(struct IUnknown *)=>Weaver.cpp,115","if (regex_search(procPath, wregex(targetProcName)))=>Weaver.cpp,139"

@andy250
Copy link
Author

andy250 commented Jan 27, 2017

I also managed to get a brief error message in visual studio when the test process crashes: it says that the heap is damaged.

@andy250
Copy link
Author

andy250 commented Jan 27, 2017

I have made some further investigation and the error is not caused by optional arguments. My code is set up as follows:

public void DoSomething(.....) {
....
StaticClass.StaticMethod(.....);
}

public static void StaticMethod(....) {
....
string result = AnotherStaticClass.AnotherStaticMethod("some string input");
}

The test calls DoSomething and stubs the StaticMethod with a simple delegate. As soon as I comment out the line var result = AnotherStaticClass.AnotherStaticMethod(...); and recompile prig assemblies the test starts to work. I cannot share my exact code and I am unable to reproduce this behavior on a side project unfortunately. It is strange that the crash occurrs when calling stubbed method, only if that method originally contained a call to another static method (which happens to be also avialble for stubbing).

Might there be some problem with how the classes/methods are named, or how many args they have or with naming of those args? I should also mention that AnotherStaticMethod is also added in prig settings file (so I can stub this one, and I actually do that in some other tests, which work just fine).

@andy250 andy250 changed the title Prig test run crashing (possibly method optional arguments issue) Prig test run crashing (when a nested static, unstubbed method is called) Jan 27, 2017
@urasandesu
Copy link
Owner

Here it is, but I suspect these are not the errors I was referring to:

The latest error log that is recorded at 2017/01/26 12:58:18.243092 is probably caused by that prig install command was not executed correctly, but umm... What is "IntelliTrace"? I little investigated about that, it seems the feature Visual Studio 2015 Enterprise Edition or more only has. Could you disable it?

@urasandesu
Copy link
Owner

I have made some further investigation and the error is not caused by optional arguments. My code is set up as follows:

Thank you for your deep investigation!

In the past, the complex issue around a parameter that is caused by the order of referenced assembly existed. You might be able to reproduce on a side project if you make it having plurality class libraries.

@andy250
Copy link
Author

andy250 commented Jan 30, 2017

There is one more thing I noticed: when I run the test from VS Test Explorer it works. When it is executed from ReSharper test runner, or from command line ("prig run ...") - then it crashes.

@urasandesu
Copy link
Owner

I don't have ReSharper license, so I'm investigating command line side. However, vstest.console.exe works correctly in my environment against some simple samples 😥

Now, I have requested ReSharper Ultimate Free Open Source License to JetBrains to investigate this issue. I will contact you if there is progress.

@andy250
Copy link
Author

andy250 commented Jan 30, 2017

Thanks for your support. Today I did even more investigation and it seems that the cause of the error is even different than I thought. I even can't isolate the problematic line of code now. What I'm doing is commenting/changing code within the method that is being stubbed in the test, recompiling prig assemblies and re-runing the test. There is some randomness around it, and in the end it seems that the optional parameters have something to do with the issue - when removing/changing calls to such methods I am able to make the test run or make it fail, but it doesn't seem to be consistent (or I can't see the clue).

I also tried on a side project as well, by copying quite a lot of code from my original project but without success. In the new project the test passes.

@ngjermundshaug
Copy link

I tried to run one of @andy250 's tests (we're co-workers) - and it also failed on my local PC.

When analyzing the .dmp file in DebugDiag2 - it seems it is also related to Serialization in Boost.

Exception Information

NTDLL!RTLREPORTCRITICALFAILURE+89In vstest.executionengine.x86.exe.21552.dmp the assembly instruction at ntdll!RtlReportCriticalFailure+89 in C:\Windows\System32\ntdll.dll from Microsoft Corporation has caused a corrupted heap exception (0xC0000374) when trying to perform an unknown operation on memory location 0x09b1b500 on thread 21
Thread 21 - System ID 6168

This thread is not fully resolved and may or may not be a problem. Further analysis of these threads may be required.

.NET Call Stack

[[PrestubMethodFrame] (.{error})] www.dll!Unknown 

Full Call Stack

ntdll!NtWaitForMultipleObjects+c 
ntdll!WerpWaitForCrashReporting+63 
ntdll!RtlReportExceptionHelper+2c7 
ntdll!RtlReportException+6a 
ntdll!RtlReportCriticalFailure+ad 
ntdll!RtlpReportHeapFailure+32 
ntdll!RtlpLogHeapFailure+9f 
ntdll!RtlFreeHeap+ac 
msvcr120!free+1a 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+a7024 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+a72ee 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+13038b 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+12fd67 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+130266 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+12fa41 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+12f4e5 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+129826 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+f8c0d 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+aa0b6 
Urasandesu_Prig!InstanceGettersTryRemove+1d1b 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+51765 
Urasandesu_Prig!boost::archive::detail::oserializer<boost::archive::xml_woarchive,boost::filesystem::path>::save_object_data+4f0fb 
clr!EEToProfInterfaceImpl::JITCompilationStarted+5d 
clr!MethodDesc::MakeJitWorker+2fe

@urasandesu
Copy link
Owner

@ngjermundshaug, it is strange... In the stack trace, boost::archive::xml_woarchive is appeared. This class is only used when executing prig install, prig update and prig uninstall command in Prig. Normally, these command is executed only once at the first time in each environment.

Are you wrapping prig run by any scripts? If it is true, would you share it to me?

@andy250
Copy link
Author

andy250 commented Jan 31, 2017

Basically when running from within VS "prig run" is wrapped by either ReSharper test runner or VSTest runner (which we donb't have access to). When running from command line there is no additional wrapping.

Today I can observe a bit different behavior (which is weird, to say the least):

  1. pring run -process "vstest.console.exe" -arguments "PrigTests.sll /Tests:CrashingTestName" --> test runs but the stubs are not working (original implementation is called) - which is different than it was yesterday/last week. How is this even possible?
  2. ReSharper test runner from within VS --> test crashes. ReSharper uses vstest.executionengine.x86.exe internally. The error originates in C:\Windows\SYSTEM32\ntdll.dll.

@urasandesu
Copy link
Owner

OK, I have understood that there are no any wrapper scripts. Ummmmm...

@ngjermundshaug
Copy link

Restarted PC, Opened VS, Recompiled, Ran test with VS Test Runner ==> It crashed.
So it's definitely not related to installing/uninstalling PRIG in the VS Menu.

@urasandesu
Copy link
Owner

@ngjermundshaug, thank you for the retrying.
After that, what kind of situation is Prig log of your machine?(it is in the directory %ALLUSERSPROFILE%\chocolatey\lib\Prig\tools\log)
Is it same as andy250's?

@urasandesu
Copy link
Owner

MEMO
The log message The package which has the source "..." is not found. is Prig's. However, boost::archive::xml_woarchive isn't appeared in the stack trace usually. For example, the following log will output after deleting all packages by prig uninstall all:

2017/02/02 06:59:53.993709,ERROR,0x00001d74,11,0x00003ec0,"    Weaver.cpp(175): Throw in function long __cdecl CWeaverDetail::CWeaverImpl::InitializeCore(struct IUnknown *)
Dynamic exception type: class boost::exception_detail::clone_impl<struct Urasandesu::CppAnonym::CppAnonymInvalidOperationException>
std::exception::what: The package which has the source """"C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW"""" is not found.
[struct Urasandesu::CppAnonym::tag_stack_trace * __ptr64] = at Urasandesu::CppAnonym::CppAnonymInvalidOperationException::CppAnonymInvalidOperationException in C:\ProgramData\chocolatey\lib\Prig\tools\x64\Urasandesu.Prig.dll(c:\users\urasa\prig\cppanonym\urasandesu.cppanonym\urasandesu\cppanonym\cppanonyminvalidoperationexception.cpp:50)
at CWeaverDetail::CWeaverImpl::InitializeCore in C:\ProgramData\chocolatey\lib\Prig\tools\x64\Urasandesu.Prig.dll(c:\users\urasa\prig\urasandesu.prig\weaver.cpp:175)
at Urasandesu::Swathe::Profiling::ICorProfilerCallbackImpl<ICorProfilerCallback5>::Initialize in C:\ProgramData\chocolatey\lib\Prig\tools\x64\Urasandesu.Prig.dll(c:\users\urasa\prig\swathe\urasandesu.swathe\urasandesu\swathe\profiling\icorprofilercallbackimpl.h:262)
at TranslateSecurityAttributes in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
at TranslateSecurityAttributes in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
at NGenCreateNGenWorker in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
at InitializeFusion in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
at InitializeFusion in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
at InitializeFusion in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
at InitializeFusion in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
at GetCLRFunction in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
at _CorExeMain in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
at _CorExeMain in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll
at _CorExeMain in C:\WINDOWS\SYSTEM32\MSCOREE.DLL
at BaseThreadInitThunk in C:\WINDOWS\System32\KERNEL32.dll
at RtlUserThreadStart in C:\WINDOWS\SYSTEM32\ntdll.dll

","C:\Users\urasa\Prig\Swathe\Urasandesu.Swathe\Urasandesu/Swathe/Profiling/ICorProfilerCallbackImpl.h",262,"long __cdecl CWeaverDetail::CWeaverImpl::InitializeCore(struct IUnknown *)=>Weaver.cpp,115","if (regex_search(procPath, wregex(targetProcName)))=>Weaver.cpp,139"

I guess that there is some environmental problem. Now, I have gotten ReSharper Ultimate Free Open Source License. After this, I'm going to change the investigation environment to it and continue.

@ngjermundshaug
Copy link

@urasandesu %ALLUSERSPROFILE%\chocolatey\lib\Prig\tools\log is empty on mu machine.

@urasandesu
Copy link
Owner

@ngjermundshaug, thank you for the reply!
These problems are same superficially but they possibly are different basically, aren't they?

I have installed ReSharper and started the investigation. I will contact you if there is progress.

@ngjermundshaug
Copy link

I am not running tests using Resharper, so I doubt that Resharper is causing this.. but then again you never know..

@urasandesu
Copy link
Owner

@ngjermundshaug, vstest.console.exe works fine in my environment, so I think this side has no key to progress, sorry...

@urasandesu
Copy link
Owner

@andy250, I tried to execute Quick Tour with ReSharper test runner, but I couldn't do it(it wasn't stubbed anything):

quicktourcannotrun

Probably, you have changed some options of ReSharper to be able to execute your test project. Would you give me those information? For example,

  • Testing framework and its version(NUnit? xUnit.net? MsTest?)
  • Project platform architecture(Any CPU? x86? x64?)
  • .NET Framework version(CLR2.0? CLR4.0? CLR4.5?)
  • Is enabled shadow-copy assemblies?
  • Is enabled separated AppDomain testing?
  • Where is the test work directory?($(TargetDir)? or another?)
  • Is used Test Settings File?

@andy250
Copy link
Author

andy250 commented Feb 3, 2017

I really haven't changed anything to run from R#. Here are the information:

  • MsTest (assembly referenced: Microsoft.VisualStudio.QualityTools.UnitTestFramework)
  • AnyCPU
  • 4.6
  • I guess not - where can I find this setting/information?
  • I guess not - where can I find this setting/information?
  • Not sure about the work directory: I just compile tests in VS and then run from VS, so I guess bin/Debug
  • Nothing that I know of

Be sure to enable Prig Adapter for TestProject - I failed to do so in the beginning (or I enabled the adapter for some other project accidentally) - in that case nothing was stubbed for me.

Also as @ngjermundshaug mentioned this is not a R# specific issue. I am getting the same when executing prig run ... from command line.

@urasandesu
Copy link
Owner

@andy250, thank you for the information!

Now I have investigated from these information, and I have found out that there are some issues when executing tests in MsTest. As far as I have grasped, #90 and #91 have been found.

As you and @ngjermundshaug pointed out, this isn't R# specific issue.

@andy250
Copy link
Author

andy250 commented Feb 6, 2017

@urasandesu Do you think fixing #90 and #91 will fix the current problem too?

@urasandesu
Copy link
Owner

@andy250, yes, I think so. Specially, if I fix #91, other issues will also be fixed at same time.

@urasandesu
Copy link
Owner

@andy250, now I have created VSIX that contains the commit to fix #90 and #91. Would you try this?: Prig.zip

@andy250
Copy link
Author

andy250 commented Feb 13, 2017

@urasandesu thanks for the new package. I got 2 issues:

  1. When instaling new vsix I got error about duplicate package when calling nuget sources add -name "Prig Source". To fix this I had to run nuget sources remove -name "Prig Source".
  2. When running the test I am getting an exception:

Initialization method PrigTests.SomeTest.Initialize threw exception. System.EntryPointNotFoundException: System.EntryPointNotFoundException: DLL 'Urasandesu.Prig.dll' cannot find entry point named 'InstanceGettersTryGet'..
w Urasandesu.Prig.Framework.InstanceGetters.TryGet(String key, IntPtr& ppFuncPtr)
w Urasandesu.Prig.Framework.LooseCrossDomainAccessor1.GetOrRegisterHolder() w Urasandesu.Prig.Framework.LooseCrossDomainAccessor1.get_HolderOrRegistered()
w Urasandesu.Prig.Framework.LooseCrossDomainAccessor.GetOrRegisterT
w Urasandesu.Prig.Framework.TypedBehaviorPreparableImpl.set_BodyCore(Delegate value)
w Urasandesu.Prig.Framework.TypedBehaviorPreparableImpl.set_Body(Delegate value)
w Urasandesu.Prig.Framework.TypedBehaviorPreparable`1.set_Body(TDelegate value)

It seems that this happens as soon as I call any PMyClass.GetInfo().Body = ....

@urasandesu
Copy link
Owner

@andy250, the exception is caused by the uninstallation failure against previous. Please check the following point:

  • From empty Visual Studio, select PRIG - Unregister Prig (Needs Restarting) and Register Prig (Needs Restarting) again.
  • In your sln directory, remove packages directory and all obj, bin directories.
  • In your test project, open packages.config and replace Prig entry version 2.3.1 to 2.3.2.
  • Rebuild your sln.

@andy250
Copy link
Author

andy250 commented Feb 13, 2017

@urasandesu I can confirm the new version fixed the crash. This is awesome! Thanks for your support.

When can we expect new prig version in chocolatey gallery?

@urasandesu
Copy link
Owner

@andy250, I'm glad 😌

Now I'm adding some tests for the extent of the impact. I'll finish new Prig version this month if there is no problem. Please wait for a little longer.

@andy250
Copy link
Author

andy250 commented Feb 13, 2017

Sure no problem. I actually have one more minor issue - when I run from the console (prig run -process "vstest.console.exe" "MyTests.dll") it seems that stubs are not used - original implementation gets called. When I run it from Visual Studio it is OK (TestExplorer + MSTest). Any ideas?

I have prig.exe in C:\ProgramData\chocolatey\lib\Prig\tools. It looks like it has been updated today.

@urasandesu
Copy link
Owner

Did you set environment variables?

When Prig is executed from Visual Studio, some special environment variables are set automatically like the bellow:

  • URASANDESU_PRIG_CURRENT_DIRECTORY
    Working directory for Prig. Default value is set to $(TargetDir) (output directory for build results).
  • URASANDESU_PRIG_TARGET_PROCESS_NAME
    The target process name that Prig should attach. Default value is set to '(vstest\.executionengine)|(te\.processhost\.managed[^/]+/role=testexecution).

Our Wiki also explains to collect coverage by prig and OpenCover with these variables. It might be helpful to you.

@andy250
Copy link
Author

andy250 commented Feb 14, 2017

Tried setting the variables (process name set to "vstest.console.exe") but with no effect. I remember it worked at the very beginning just after I installed 2.3.1 few weeks ago. I think it stopped working even before I installed your new vsix. What else could have been modified in my environment?

EDIT: I am even more puzzled now --> upgraded prig on our TeamCity server to 2.3.2 but it crashes as it did before upgrading :( It crashes both inside VS and when executed from console. So that also means that on TeamCity server "pring run" attaches properly (and stubs the methods) without any environmental variables being set. On my local machine "pring run" does not attach.

@urasandesu
Copy link
Owner

Where is vstest.console.exe installed on your local machine?

In v2.3.2, Prig searches VSxxxCOMNTOOLS environment variables and installs necessary DLLs to all location of Visual Studio Test Tools that also contains vstest.console.exe normally (e.g. %VS140COMNTOOLS%..\IDE\CommonExtensions\Microsoft\TestWindow).

You can check the install information for Prig by the following commands in PowerShell:

PS C:\> prig list | ConvertFrom-Json | fc

For example, this is my local machine Prig install information:
untitled

Source property is the directory of the process that Prig can attach. Is there difference compared to the location of vstest.console.exe?

@andy250
Copy link
Author

andy250 commented Feb 14, 2017

The configuration looks OK. It points to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow where vstest.console.exe resides. In that folder there are also symlinks to dlls, which point to C:\ProgramData\chocolatey\lib\Prig\lib. Only the x64 subfolder does not contain vstest.console.exe at all (but contains symlinks). I looked at TeamCity server - configuration also looks correct there.

@urasandesu
Copy link
Owner

What is going on... 😵

Well, Prig has debug trace mode. We might be able to find the problem if enabling that. Set environment variable URASANDESU_CPPANONYM_LOGGING_SEVERITY to 0 when executing vstest.console.exe. For example,

CMD C:\> SET URASANDESU_CPPANONYM_LOGGING_SEVERITY=0

CMD C:\> prig run -process "%VS120COMNTOOLS%..\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" -arguments UnitTestProject1.dll
Microsoft (R) Test Execution Command Line Tool Version 12.0.30723.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
Passed   TestMethod1

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 0.9470 Seconds

CMD C:\> 

After this, debug level log will be outputted to the directory %ALLUSERSPROFILE%\chocolatey\lib\Prig\tools\log. For example, this is the log of my environment: app_20170215.zip

Note the following and check the log:

  1. Find the Current Process Path: record. Is it intended path of vstest.console.exe?
  2. Find the Indirection DLL: record. Is it intended Prig Assembly?
  3. Find the Current Path: record. Is it the path that is same as the location that unit test DLL and Prig Assembly are located?
  4. Find the This method is marked by IndirectableAttribute. record. Does it exist?

@andy250
Copy link
Author

andy250 commented Feb 16, 2017

Thx for the tips. You pointed me in the right direction with the Current Path - I didn't know I need to cd to the folder with test dll and prig assembly! My log file was missing Indirection DLL. After I changed working directory the Indirection DLL appeared in the log and the stubbing seems to take place now... but I get a crash, the same way as it did before upgrade to 2.3.2. So it seems my local machine has same problem as TeamCity server. Only place where it works is VisualSTudio test runner. So we are one step ahead, but I need to make this work from the command line now. Would the trace-mode log file be of any help?

EDIT I will check if Debug vs Release mode changes anything (I think previously it was Debug, now Im testing only Release, and also Release is used on TeamCity).

@urasandesu
Copy link
Owner

Umm... I can't think of a solution right away. Sorry to cause you trouble.

In addition, today it turned out that there are some problems if applying current correction way (FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401) will occur in some situation). I'm going to investigate it this weekend, so you might have better try again after that.

@andy250
Copy link
Author

andy250 commented Feb 28, 2017

Sorry to say, but we have decided to revert back to fakes. Apart from couple of tests crashing we had trouble running tests stable under TeamCity (especially recently stubbing stopped working at all). If you can improve TeamCity support and fix the crashes we are more than happy to try it out again in near future. Thanks again for your efforts and great support.

@urasandesu
Copy link
Owner

I'm the one who should apologize. Thanks to you, I was able to also find other new issues. I will continue to improve this framework. If there is an opportunity, please try Prig again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants