Dot cover fails randomly on team city

Answered

We've started randomly getting errors in our buildscripts using dot cover. Tests are written in xunit or nunit using full framework or net core. They are ran on team city using cake. It seems like the cause of the error is dotcover crashing, but we can't determine the cause of the error. I'm unsure if the crash happens while running the tests, running coverage or in the merging of the coverage reports afterwards.

[06:50:16] : [Run test coverage] Starting test execution, please wait...
[06:50:16] : [Run test coverage]
[06:50:16] : [Run test coverage] A total of 1 test files matched the specified pattern.
[06:50:17] : [Run test coverage] [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.1 (64-bit .NET Core 3.1.4)
[06:51:02]W: [Run test coverage] The active test run was aborted. Reason: Test host process crashed : Fatal error. Internal CLR error. (0x80131506)
[06:51:02]W: [Run test coverage] at System.Reflection.RuntimeModule.GetTypes(System.Reflection.RuntimeModule)
[06:51:02]W: [Run test coverage] at System.Reflection.RuntimeModule.GetDefinedTypes()
[06:51:02]W: [Run test coverage] at System.Reflection.RuntimeAssembly.get_DefinedTypes()
[06:51:02]W: [Run test coverage] at Xunit.Runner.VisualStudio.VsTestRunner.GetAvailableRunnerReporters(System.Collections.Generic.IEnumerable`1<System.String>)
[06:51:02]W: [Run test coverage] at Xunit.Runner.VisualStudio.VsTestRunner+<>c__DisplayClass23_0.<GetRunnerReporter>b__0()
[06:51:02]W: [Run test coverage] at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ViaFactory(System.Threading.LazyThreadSafetyMode)
[06:51:02]W: [Run test coverage] at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecutionAndPublication(System.LazyHelper, Boolean)
[06:51:02]W: [Run test coverage] at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].CreateValue()
[06:51:02]W: [Run test coverage] at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].get_Value()
[06:51:02]W: [Run test coverage] at Xunit.Runner.VisualStudio.VsTestRunner.GetRunnerReporter(LoggerHelper, Xunit.Runner.VisualStudio.RunSettings, System.Collections.Generic.IEnumerable`1<System.String>)
[06:51:02]W: [Run test coverage] at Xunit.Runner.VisualStudio.VsTestRunner.RunTests(Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle, LoggerHelper, Xunit.Runner.VisualStudio.TestPlatformContext, Xunit.Runner.VisualStudio.RunSettings, System.Func`1<System.Collections.Generic.List`1<Xunit.Runner.VisualStudio.AssemblyRunInfo>>)
[06:51:02]W: [Run test coverage] at Xunit.Runner.VisualStudio.VsTestRunner.Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ITestExecutor.RunTests(System.Collections.Generic.IEnumerable`1<System.String>, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle)
[06:51:02]W: [Run test coverage] at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.RunTestsWithSources.InvokeExecutor(Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities.LazyExtension`2<Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ITestExecutor,Microsoft.VisualStudio.TestPlatform.Common.Interfaces.ITestExecutorCapabilities>, System.Tuple`2<System.Uri,System.String>, Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter.RunContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle)
[06:51:02]W: [Run test coverage] at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTestInternalWithExecutors(System.Collections.Generic.IEnumerable`1<System.Tuple`2<System.Uri,System.String>>, Int64)
[06:51:02]W: [Run test coverage] at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTestsInternal()
[06:51:02]W: [Run test coverage] at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTests()
[06:51:02]W: [Run test coverage] at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.ExecutionManager.StartTestRun(System.Collections.Generic.Dictionary`2<System.String,System.Collections.Generic.IEnumerable`1<System.String>>, System.String, System.String, Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol.TestExecutionContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ITestCaseEventsHandler, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestRunEventsHandler)
[06:51:02]W: [Run test coverage] at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TestRequestHandler+<>c__DisplayClass30_3.<OnMessageReceived>b__3()
[06:51:02]W: [Run test coverage] at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TestRequestHandler+<>c.<.ctor>b__18_1(System.Action)
[06:51:02]W: [Run test coverage] at Microsoft.VisualStudio.TestPlatform.Utilities.JobQueue`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].SafeProcessJob(System.__Canon)
[06:51:02]W: [Run test coverage] at Microsoft.VisualStudio.TestPlatform.Utilities.JobQueue`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].BackgroundJobProcessor()
[06:51:02]W: [Run test coverage] at Microsoft.VisualStudio.TestPlatform.Utilities.JobQueue`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<.ctor>b__12_0()
[06:51:02]W: [Run test coverage] at System.Threading.Tasks.Task.InnerInvoke()
[06:51:02]W: [Run test coverage] at System.Threading.Tasks.Task+<>c.<.cctor>b__274_0(System.Object)
[06:51:02]W: [Run test coverage] at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
[06:51:02]W: [Run test coverage] at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
[06:51:02]W: [Run test coverage] at System.Threading.Tasks.Task.ExecuteEntryUnsafe(System.Threading.Thread)
[06:51:02]W: [Run test coverage] at System.Threading.Tasks.ThreadPoolTaskScheduler+<>c.<.cctor>b__10_0(System.Object)
[06:51:02]W: [Run test coverage] at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
[06:51:02]W: [Run test coverage] at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
[06:51:02]W: [Run test coverage] at System.Threading.ThreadHelper.ThreadStart(System.Object)
[06:51:02]W: [Run test coverage]
[06:51:02] : [Run test coverage] Results File: D:\BuildAgent1\work\8d922da462b19f2f\Tests\TestResults\TestResults.xml
[06:51:02] : [Run test coverage]
[06:51:02]W: [Run test coverage] Test Run Aborted.
[06:51:02] : [Run test coverage]
[06:51:02] : [Run test coverage] Build FAILED.
[06:51:02] : [Run test coverage] 0 Warning(s)
[06:51:02] : [Run test coverage] 0 Error(s)
[06:51:02] : [Run test coverage]
[06:51:02] : [Run test coverage] Time Elapsed 00:00:48.17
[06:51:04]W: [Run test coverage] [JetBrains dotCover] Analyzed application exited with code '1'
[06:51:04] : [Run test coverage] [JetBrains dotCover] Coverage session finished [15.06.2020 06:51:04]
[06:51:04]E: [Run test coverage] [JetBrains dotCover] Coverage session finished with errors: File is corrupt
Failed to get nullable module interface
[location] = c:\buildagent\work\ef275f8f93549f08\profiler\kernel\windows\native\solution\core\src\profilers\../MetaData/MetaDataUtil.h(67)
[function] = struct jb::com_ptr<struct IMetaDataEmit> __cdecl jbprof::get_module_metadata_nullable<struct IMetaDataEmit>(const struct jb::com_ptr<struct ICorProfilerInfo> &,const unsigned __int64)
[HResult] = 8013110E
[module ID] = 00007FFC0652D498.
[06:51:05]E: [Step 1/1] Error message is logged
[06:51:04]W: [Run test coverage] An error occurred when executing task 'testCoverage'.
[06:51:04] : [Run test coverage] JetBrains dotCover Console Runner 2019.2.1. Build 777.0.20190816.143429
[06:51:04] : [Run test coverage] Copyright (c) 2009-2020 JetBrains s.r.o. All rights reserved.
[06:51:04] : [Run test coverage] [JetBrains dotCover] Snapshot merging started. Source snapshots number: 1 [15.06.2020 06:51:04]
[06:51:05] : [Run test coverage] [JetBrains dotCover] Snapshot merging finished [15.06.2020 06:51:05]
[06:51:05]i: [Run test coverage] ##teamcity[dotNetCoverage dotcover_home='D:/BuildAgent1/work/8d922da462b19f2f/build/tools/JetBrains.dotCover.CommandLineTools.2019.2.1/tools']
[06:51:05]W: [Run test coverage] Error: One or more errors occurred.
[06:51:05]i: [Run test coverage] ##teamcity[importData type='dotNetCoverage' tool='dotcover' path='D:/BuildAgent1/work/8d922da462b19f2f/testresult/result.dcvr']
[06:51:05]W: [Run test coverage] DotCover: Process returned an error (exit code -2).
[06:51:05] : [Step 1/1] Importing data from 'D:/BuildAgent1/work/8d922da462b19f2f/testresult/result.dcvr' (518.45 KB) with 'dotNetCoverage' processor
[06:51:05]W: [Step 1/1] Process exited with code 1
[06:51:05]E: [Step 1/1] Process exited with code 1 (Step: Invoke Cake (PowerShell))
[06:51:05]E: [Step 1/1] Step Invoke Cake (PowerShell) failed
[06:51:05] : Waiting for 1 service processes to complete
[06:51:05] : Processing 1 coverage report(s)
[06:51:05] : Generating coverage report by dotcover for files: [D:\BuildAgent1\work\8d922da462b19f2f\testresult\result.dcvr]
[06:51:05] : Get dotCover version
[06:51:05] : [Get dotCover version] Started dotCover: D:\BuildAgent1\work\8d922da462b19f2f\build\tools\JetBrains.dotCover.CommandLineTools.2019.2.1\tools\dotCover.exe version D:\BuildAgent1\temp\agentTmp\dotNetCoverageResults\dotCover2725265177050327922Version
[06:51:05] : [Get dotCover version] Output: JetBrains dotCover Console Runner 2019.2.1. Build 777.0.20190816.143429
Copyright (c) 2009-2020 JetBrains s.r.o. All rights reserved.

0
1 comment

If I were you I'd try to view the contents of this file on the build agent: D:\BuildAgent1\work\8d922da462b19f2f\Tests\TestResults\TestResults.xml and see if there's something obviously corrupt about it, otherwise share it here with TeamCity people.

We have had similar issues before like this, but it was caused by NUnit runner itself throwing an exit code > 0 because it can't destroy it's container (called an app domain) because some piece of code in the test is still running or holding on to a resource. We fixed it by changing the version of the NUnit Console to 3.10.0 which had a fix for this. However in your case I think it's the file is your problem, we've had this too and it was caused by a recursive test blowing out the size of the file.

0

Please sign in to leave a comment.