Skip to content

Commit 16d74ab

Browse files
committed
fix: add some log and adjust vstest settings
1 parent 67b0432 commit 16d74ab

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

src/Stryker.Core/Stryker.Core/InjectedHelpers/MutantControl.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Stryker
22
{
3-
internal static class MutantControl
3+
public static class MutantControl
44
{
55
private static System.Collections.Generic.List<int> _coveredMutants;
66
private static System.Collections.Generic.List<int> _coveredStaticdMutants;

src/Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestContextInformation.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ private string GenerateRunSettingsForDiscovery()
252252
<RunConfiguration>
253253
<MaxCpuCount>{Math.Max(1, Options.Concurrency)}</MaxCpuCount>
254254
<InIsolation>true</InIsolation>
255+
<DisableAppDomain>true</DisableAppDomain>
255256
<DesignMode>true</DesignMode>
256257
{testCaseFilter}
257258
</RunConfiguration>
@@ -290,11 +291,11 @@ public string GenerateRunSettings(int? timeout, bool forCoverage, Dictionary<int
290291
$@"<RunSettings>
291292
<RunConfiguration>
292293
<CollectSourceInformation>false</CollectSourceInformation>
293-
{(isFullFramework ? @"<DisableAppDomain>true</DisableAppDomain>
294-
" : string.Empty)} <MaxCpuCount>1</MaxCpuCount>
294+
<MaxCpuCount>1</MaxCpuCount>
295295
{timeoutSettings}{settingsForCoverage}
296296
<DesignMode>false</DesignMode>
297297
<InIsolation>true</InIsolation>
298+
<DisableAppDomain>true</DisableAppDomain>
298299
{testCaseFilter}</RunConfiguration>{dataCollectorSettings}
299300
</RunSettings>";
300301

src/Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunnerPool.cs

+6
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ private bool ConvertSingleResult(TestResult testResult, ISet<Guid> seenTestCases
154154
var (key, value) = testResult.GetProperties().FirstOrDefault(x => x.Key.Id == CoverageCollector.PropertyName);
155155
var testCaseId = testResult.TestCase.Id;
156156
var unexpected = false;
157+
var log = testResult.GetProperties().FirstOrDefault(x => x.Key.Id == CoverageCollector.Coveragelog).Value?.ToString();
158+
if (!string.IsNullOrEmpty(log))
159+
{
160+
_logger.LogError($"VsTestRunner: Coverage collector error: {log}.");
161+
}
162+
157163
if (!Context.VsTests.ContainsKey(testCaseId))
158164
{
159165
_logger.LogWarning(

src/Stryker.Core/Stryker.Core/Testing/ProcessExecutor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.Diagnostics.CodeAnalysis;
5-
using System.IO;
65
using System.Linq;
76
using System.Text;
87

src/Stryker.DataCollector/Stryker.DataCollector/CoverageCollector.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class CoverageCollector : InProcDataCollection
1717
private IDataCollectionSink _dataSink;
1818
private bool _coverageOn;
1919
private int _activeMutation = -1;
20+
private bool _reportFailure;
21+
2022
private Action<string> _logger;
2123
private readonly IDictionary<string, int> _mutantTestedBy = new Dictionary<string, int>();
2224

@@ -34,6 +36,7 @@ public class CoverageCollector : InProcDataCollection
3436

3537
public const string PropertyName = "Stryker.Coverage";
3638
public const string OutOfTestsPropertyName = "Stryker.Coverage.OutOfTests";
39+
public const string Coveragelog = "CoverageLog";
3740

3841
public string MutantList => string.Join(",", _mutantTestedBy.Values.Distinct());
3942

@@ -168,12 +171,12 @@ private void ReadConfiguration(string configuration)
168171

169172
private int GetActiveMutantForThisTest(string testId)
170173
{
171-
if (_mutantTestedBy.ContainsKey(testId))
174+
if (_mutantTestedBy.TryGetValue(testId, out var test))
172175
{
173-
return _mutantTestedBy[testId];
176+
return test;
174177
}
175178

176-
return _mutantTestedBy.ContainsKey(AnyId) ? _mutantTestedBy[AnyId] : -1;
179+
return _mutantTestedBy.TryGetValue(AnyId, out var value) ? value : -1;
177180
}
178181

179182
private void ParseTestMapping(XmlNodeList testMapping)
@@ -240,6 +243,11 @@ private void PublishCoverageData(DataCollectionContext dataCollectionContext)
240243
{
241244
// no test covered any mutations, so the controller was never properly initialized
242245
_dataSink.SendData(dataCollectionContext, PropertyName, ";");
246+
if (!_reportFailure)
247+
{
248+
_dataSink.SendData(dataCollectionContext, Coveragelog, $"Did not find type {_controlClassName}. This indicates Stryker failed to copy the mutated assembly for test.");
249+
_reportFailure = true;
250+
}
243251
return;
244252
}
245253

0 commit comments

Comments
 (0)