approvals / ApprovalTests.Net

ApprovalTest verification library for .Net
Other
570 stars 109 forks source link

Running on AppVeyor CI has the following exception #91

Closed robfe closed 10 years ago

robfe commented 10 years ago

This is even with

[assembly: FrontLoadedReporter(typeof(CiReporter))] //my custom Reporter that gets picked up
[assembly: UseReporter(typeof(DiffReporter))]

Since it's in the type initialiser FrontLoadedReporter doesn't help

Unhandled Exception:
32System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'ApprovalTests.Reporters.DiffReporter' threw an exception. ---> System.TypeInitializationException: The type initializer for 'ApprovalTests.Reporters.VisualStudioReporter' threw an exception. ---> System.ComponentModel.Win32Exception: Access is denied
33   at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
34   at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)
35   at System.Diagnostics.Process.get_MainModule()
36   at ApprovalTests.Reporters.VisualStudioReporter.<LaunchedFromVisualStudio>b__5(Process x)
37   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
38   at ApprovalTests.Reporters.VisualStudioReporter.LaunchedFromVisualStudio()
39   at ApprovalTests.Reporters.VisualStudioReporter.GetPath()
40   at ApprovalTests.Reporters.VisualStudioReporter..ctor()
41   at ApprovalTests.Reporters.VisualStudioReporter..cctor()
42   --- End of inner exception stack trace ---
43   at ApprovalTests.Reporters.DiffReporter..ctor()
44   at ApprovalTests.Reporters.DiffReporter..cctor()
45   --- End of inner exception stack trace ---
46 
47   --- End of inner exception stack trace ---
48 
49Server stack trace: 
50   at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized)
51   at System.Reflection.RtFieldInfo.UnsafeGetValue(Object obj)
52   at System.Reflection.RtFieldInfo.InternalGetValue(Object obj, StackCrawlMark& stackMark)
53   at System.Reflection.RtFieldInfo.GetValue(Object obj)
54   at ApprovalTests.Reporters.UseReporterAttribute.GetSingleton(Type reporter)
55   at ApprovalTests.Reporters.UseReporterAttribute..ctor(Type reporter)
56   at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
57   at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
58   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
59   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
60   at NUnit.Core.Reflect.GetAttributes(ICustomAttributeProvider member, Boolean inherit)
61   at NUnit.Core.Builders.TestAssemblyBuilder.BuildTestAssembly(Assembly assembly, String assemblyName, IList fixtures, Boolean autoSuites)
62   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
63   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
64   at NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage package)
65   at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
66   at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
67   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
68   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
69   at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
70   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
71   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
72 
73Exception rethrown at [0]: 
74   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
75   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
76   at NUnit.Core.TestRunner.Load(TestPackage package)
77   at NUnit.Util.TestDomain.Load(TestPackage package)
78   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
79   at NUnit.Util.RemoteTestAgent.AgentRunner.Load(TestPackage package)
80   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
81   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
82 
83Exception rethrown at [1]: 
84   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
85   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
86   at NUnit.Core.TestRunner.Load(TestPackage package)
87   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
88   at NUnit.Util.ProcessRunner.Load(TestPackage package)
89   at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
90   at NUnit.ConsoleRunner.Runner.Main(String[] args)
robfe commented 10 years ago

FWIW the following workaround worked: https://github.com/PowerAssert/PowerAssert.Net/commit/2aa7b64808c6c7bdc01449795fb56362c95f0731

jamesrcounts commented 10 years ago

What version of ApprovalTests are you using? We made a number of fixes for this in v3.0.6

-----Original Message----- From: "robfe" notifications@github.com Sent: ‎7/‎18/‎2014 3:55 PM To: "approvals/ApprovalTests.Net" ApprovalTests.Net@noreply.github.com Subject: [ApprovalTests.Net] Running on AppVeyor CI has the followingexception (#91)

This is even with [assembly: FrontLoadedReporter(typeof(CiReporter))] //my custom Reporter that gets picked up [assembly: UseReporter(typeof(DiffReporter))] Since it's in the type initialiser FrontLoadedReporter doesn't help Unhandled Exception: 32System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'ApprovalTests.Reporters.DiffReporter' threw an exception. ---> System.TypeInitializationException: The type initializer for 'ApprovalTests.Reporters.VisualStudioReporter' threw an exception. ---> System.ComponentModel.Win32Exception: Access is denied 33 at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited) 34 at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly) 35 at System.Diagnostics.Process.get_MainModule() 36 at ApprovalTests.Reporters.VisualStudioReporter.b__5(Process x) 37 at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source, Func2 predicate) 38 at ApprovalTests.Reporters.VisualStudioReporter.LaunchedFromVisualStudio() 39 at ApprovalTests.Reporters.VisualStudioReporter.GetPath() 40 at ApprovalTests.Reporters.VisualStudioReporter..ctor() 41 at ApprovalTests.Reporters.VisualStudioReporter..cctor() 42 --- End of inner exception stack trace --- 43 at ApprovalTests.Reporters.DiffReporter..ctor() 44 at ApprovalTests.Reporters.DiffReporter..cctor() 45 --- End of inner exception stack trace --- 46 47 --- End of inner exception stack trace --- 48 49Server stack trace: 50 at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized) 51 at System.Reflection.RtFieldInfo.UnsafeGetValue(Object obj) 52 at System.Reflection.RtFieldInfo.InternalGetValue(Object obj, StackCrawlMark& stackMark) 53 at System.Reflection.RtFieldInfo.GetValue(Object obj) 54 at ApprovalTests.Reporters.UseReporterAttribute.GetSingleton(Type reporter) 55 at ApprovalTests.Reporters.UseReporterAttribute..ctor(Type reporter) 56 at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte* ppBlob, Byte* pEndBlob, Int32\ pcNamedArgs) 57 at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs) 58 at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) 59 at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) 60 at NUnit.Core.Reflect.GetAttributes(ICustomAttributeProvider member, Boolean inherit) 61 at NUnit.Core.Builders.TestAssemblyBuilder.BuildTestAssembly(Assembly assembly, String assemblyName, IList fixtures, Boolean autoSuites) 62 at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites) 63 at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites) 64 at NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage package) 65 at NUnit.Core.TestSuiteBuilder.Build(TestPackage package) 66 at NUnit.Core.SimpleTestRunner.Load(TestPackage package) 67 at NUnit.Core.ProxyTestRunner.Load(TestPackage package) 68 at NUnit.Core.ProxyTestRunner.Load(TestPackage package) 69 at NUnit.Core.RemoteTestRunner.Load(TestPackage package) 70 at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) 71 at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) 72 73Exception rethrown at [0]: 74 at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 75 at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 76 at NUnit.Core.TestRunner.Load(TestPackage package) 77 at NUnit.Util.TestDomain.Load(TestPackage package) 78 at NUnit.Core.ProxyTestRunner.Load(TestPackage package) 79 at NUnit.Util.RemoteTestAgent.AgentRunner.Load(TestPackage package) 80 at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) 81 at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) 82 83Exception rethrown at [1]: 84 at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 85 at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 86 at NUnit.Core.TestRunner.Load(TestPackage package) 87 at NUnit.Core.ProxyTestRunner.Load(TestPackage package) 88 at NUnit.Util.ProcessRunner.Load(TestPackage package) 89 at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options) 90 at NUnit.ConsoleRunner.Runner.Main(String[] args) — Reply to this email directly or view it on GitHub.

robfe commented 10 years ago

3.0.7

jamesrcounts commented 10 years ago

I see the issue. In visual studio reporter we are catching that exception but the only recovering when the message refers to a 64/32 bit conflict. However, your problem is 'Access denied.' So we are rethrowing it. On Jul 18, 2014 4:45 PM, "robfe" notifications@github.com wrote:

3.0.7

— Reply to this email directly or view it on GitHub https://github.com/approvals/ApprovalTests.Net/issues/91#issuecomment-49491911 .

jamesrcounts commented 10 years ago

bdbda64e7ec129cb899f60dc29d98fd0af9d5701 makes the exception handler more general.

raleighbuckner commented 9 years ago

Is this change scheduled to be released on NuGet?

The issue has been blocking builds in TeamCity with the currently-released 3.0.7 available on NuGet.

Downloading the latest CI build (3.0.7-CI00009) from MyGet fixes the issue, but it requires the ApprovalTests DLLs to be added manually to the solution - taking them out of the NuGet process. I'd much rather keep everything in NuGet if possible.

Thanks!