Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.2.39" />
<PackageVersion Include="LaunchDarkly.EventSource" Version="5.2.1" />
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageVersion Include="Microsoft.VisualStudio.SolutionPersistence" Version="1.0.52" />
<PackageVersion Include="MSTest" Version="3.11.0" />
<PackageVersion Include="MSTest.TestFramework" Version="3.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0" />
Expand Down Expand Up @@ -46,4 +47,4 @@
<PackageVersion Include="Spectre.Console.Testing" Version="0.53.0" />
<PackageVersion Include="TestableIO.System.IO.Abstractions.TestingHelpers" Version="22.0.16" />
</ItemGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions src/Stryker.Abstractions/Options/IStrykerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public interface IStrykerOptions
MutationLevel MutationLevel { get; init; }
OptimizationModes OptimizationMode { get; init; }
string OutputPath { get; init; }
string Platform { get; }
string ProjectName { get; set; }
string ProjectPath { get; init; }
string ProjectVersion { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void ShouldHandleSingleValue()
[TestMethod]
public void ShouldHandleSingleOrNoValueWithNoValue()
{
_target.ReadCommandLineConfig(new[] { "--since" }, _app, _inputs);
_target.ReadCommandLineConfig(["--since"], _app, _inputs);

_inputs.SinceInput.SuppliedInput.ShouldBe(true);
_inputs.SinceTargetInput.SuppliedInput.ShouldBe(null);
Expand All @@ -50,7 +50,7 @@ public void ShouldHandleSingleOrNoValueWithNoValue()
[TestMethod]
public void ShouldHandleSingleOrNoValueWithValue()
{
_target.ReadCommandLineConfig(new[] { "--since:test" }, _app, _inputs);
_target.ReadCommandLineConfig(["--since:test"], _app, _inputs);

_inputs.SinceInput.SuppliedInput.ShouldBe(true);
_inputs.SinceTargetInput.SuppliedInput.ShouldBe("test");
Expand All @@ -59,7 +59,7 @@ public void ShouldHandleSingleOrNoValueWithValue()
[TestMethod]
public void ShouldHandleMultiValue()
{
_target.ReadCommandLineConfig(new[] { "--reporter test", "--reporter test2" }, _app, _inputs);
_target.ReadCommandLineConfig(["--reporter test", "--reporter test2"], _app, _inputs);

_inputs.ReportersInput.SuppliedInput.Count().ShouldBe(2);
_inputs.ReportersInput.SuppliedInput.First().ShouldBe("test");
Expand Down
41 changes: 27 additions & 14 deletions src/Stryker.CLI/Stryker.CLI.UnitTest/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -909,13 +909,14 @@
"Serilog.Sinks.Console": "[6.1.1, )",
"ShellProgressBar": "[5.2.0, )",
"Spectre.Console": "[0.53.0, )",
"Stryker.Abstractions": "[4.8.1, )",
"Stryker.Configuration": "[4.8.1, )",
"Stryker.DataCollector": "[4.8.1, )",
"Stryker.Abstractions": "[1.0.0, )",
"Stryker.Configuration": "[1.0.0, )",
"Stryker.DataCollector": "[1.0.0, )",
"Stryker.Regex.Parser": "[1.0.0, )",
"Stryker.RegexMutators": "[4.8.1, )",
"Stryker.TestRunner.VsTest": "[4.8.1, )",
"Stryker.Utilities": "[4.8.1, )",
"Stryker.RegexMutators": "[1.0.0, )",
"Stryker.Solutions": "[1.0.0, )",
"Stryker.TestRunner.VsTest": "[1.0.0, )",
"Stryker.Utilities": "[1.0.0, )",
"TestableIO.System.IO.Abstractions.Wrappers": "[22.0.16, )"
}
},
Expand All @@ -938,8 +939,8 @@
"Microsoft.CodeAnalysis.CSharp": "[4.14.0, )",
"Microsoft.CodeAnalysis.Common": "[4.14.0, )",
"Serilog": "[4.3.0, )",
"Stryker.Abstractions": "[4.8.1, )",
"Stryker.Utilities": "[4.8.1, )"
"Stryker.Abstractions": "[1.0.0, )",
"Stryker.Utilities": "[1.0.0, )"
}
},
"stryker.datacollector": {
Expand All @@ -955,11 +956,17 @@
"Stryker.Regex.Parser": "[1.0.0, )"
}
},
"stryker.solutions": {
"type": "Project",
"dependencies": {
"Microsoft.VisualStudio.SolutionPersistence": "[1.0.52, )"
}
},
"stryker.testrunner": {
"type": "Project",
"dependencies": {
"Microsoft.TestPlatform.ObjectModel": "[17.14.1, )",
"Stryker.Abstractions": "[4.8.1, )"
"Stryker.Abstractions": "[1.0.0, )"
}
},
"stryker.testrunner.vstest": {
Expand All @@ -970,10 +977,10 @@
"Microsoft.TestPlatform.ObjectModel": "[17.14.1, )",
"Microsoft.TestPlatform.Portable": "[17.14.1, )",
"Microsoft.TestPlatform.TranslationLayer": "[17.14.1, )",
"Stryker.Abstractions": "[4.8.1, )",
"Stryker.DataCollector": "[4.8.1, )",
"Stryker.TestRunner": "[4.8.1, )",
"Stryker.Utilities": "[4.8.1, )",
"Stryker.Abstractions": "[1.0.0, )",
"Stryker.DataCollector": "[1.0.0, )",
"Stryker.TestRunner": "[1.0.0, )",
"Stryker.Utilities": "[1.0.0, )",
"TestableIO.System.IO.Abstractions.Wrappers": "[22.0.16, )"
}
},
Expand All @@ -986,7 +993,7 @@
"Microsoft.Extensions.Logging.Abstractions": "[9.0.10, )",
"Mono.Cecil": "[0.11.6, )",
"ResXResourceReader.NetStandard": "[1.3.0, )",
"Stryker.Abstractions": "[4.8.1, )"
"Stryker.Abstractions": "[1.0.0, )"
}
},
"Azure.Storage.Files.Shares": {
Expand Down Expand Up @@ -1129,6 +1136,12 @@
"NETStandard.Library": "2.0.0"
}
},
"Microsoft.VisualStudio.SolutionPersistence": {
"type": "CentralTransitive",
"requested": "[1.0.52, )",
"resolved": "1.0.52",
"contentHash": "oNv2JtYXhpdJrX63nibx1JT3uCESOBQ1LAk7Dtz/sr0+laW0KRM6eKp4CZ3MHDR2siIkKsY8MmUkeP5DKkQQ5w=="
},
"Microsoft.Web.LibraryManager.Build": {
"type": "CentralTransitive",
"requested": "[3.0.71, )",
Expand Down
41 changes: 27 additions & 14 deletions src/Stryker.CLI/Stryker.CLI/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -651,13 +651,14 @@
"Serilog.Sinks.Console": "[6.1.1, )",
"ShellProgressBar": "[5.2.0, )",
"Spectre.Console": "[0.53.0, )",
"Stryker.Abstractions": "[4.8.1, )",
"Stryker.Configuration": "[4.8.1, )",
"Stryker.DataCollector": "[4.8.1, )",
"Stryker.Abstractions": "[1.0.0, )",
"Stryker.Configuration": "[1.0.0, )",
"Stryker.DataCollector": "[1.0.0, )",
"Stryker.Regex.Parser": "[1.0.0, )",
"Stryker.RegexMutators": "[4.8.1, )",
"Stryker.TestRunner.VsTest": "[4.8.1, )",
"Stryker.Utilities": "[4.8.1, )",
"Stryker.RegexMutators": "[1.0.0, )",
"Stryker.Solutions": "[1.0.0, )",
"Stryker.TestRunner.VsTest": "[1.0.0, )",
"Stryker.Utilities": "[1.0.0, )",
"TestableIO.System.IO.Abstractions.Wrappers": "[22.0.16, )"
}
},
Expand All @@ -680,8 +681,8 @@
"Microsoft.CodeAnalysis.CSharp": "[4.14.0, )",
"Microsoft.CodeAnalysis.Common": "[4.14.0, )",
"Serilog": "[4.3.0, )",
"Stryker.Abstractions": "[4.8.1, )",
"Stryker.Utilities": "[4.8.1, )"
"Stryker.Abstractions": "[1.0.0, )",
"Stryker.Utilities": "[1.0.0, )"
}
},
"stryker.datacollector": {
Expand All @@ -697,11 +698,17 @@
"Stryker.Regex.Parser": "[1.0.0, )"
}
},
"stryker.solutions": {
"type": "Project",
"dependencies": {
"Microsoft.VisualStudio.SolutionPersistence": "[1.0.52, )"
}
},
"stryker.testrunner": {
"type": "Project",
"dependencies": {
"Microsoft.TestPlatform.ObjectModel": "[17.14.1, )",
"Stryker.Abstractions": "[4.8.1, )"
"Stryker.Abstractions": "[1.0.0, )"
}
},
"stryker.testrunner.vstest": {
Expand All @@ -712,10 +719,10 @@
"Microsoft.TestPlatform.ObjectModel": "[17.14.1, )",
"Microsoft.TestPlatform.Portable": "[17.14.1, )",
"Microsoft.TestPlatform.TranslationLayer": "[17.14.1, )",
"Stryker.Abstractions": "[4.8.1, )",
"Stryker.DataCollector": "[4.8.1, )",
"Stryker.TestRunner": "[4.8.1, )",
"Stryker.Utilities": "[4.8.1, )",
"Stryker.Abstractions": "[1.0.0, )",
"Stryker.DataCollector": "[1.0.0, )",
"Stryker.TestRunner": "[1.0.0, )",
"Stryker.Utilities": "[1.0.0, )",
"TestableIO.System.IO.Abstractions.Wrappers": "[22.0.16, )"
}
},
Expand All @@ -728,7 +735,7 @@
"Microsoft.Extensions.Logging.Abstractions": "[9.0.10, )",
"Mono.Cecil": "[0.11.6, )",
"ResXResourceReader.NetStandard": "[1.3.0, )",
"Stryker.Abstractions": "[4.8.1, )"
"Stryker.Abstractions": "[1.0.0, )"
}
},
"Azure.Storage.Files.Shares": {
Expand Down Expand Up @@ -862,6 +869,12 @@
"NETStandard.Library": "2.0.0"
}
},
"Microsoft.VisualStudio.SolutionPersistence": {
"type": "CentralTransitive",
"requested": "[1.0.52, )",
"resolved": "1.0.52",
"contentHash": "oNv2JtYXhpdJrX63nibx1JT3uCESOBQ1LAk7Dtz/sr0+laW0KRM6eKp4CZ3MHDR2siIkKsY8MmUkeP5DKkQQ5w=="
},
"Microsoft.Web.LibraryManager.Build": {
"type": "CentralTransitive",
"requested": "[3.0.71, )",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Buildalyzer.Construction;
using Buildalyzer.Environment;
using Moq;
using Stryker.Solutions;
using Stryker.Utilities.Buildalyzer;

namespace Stryker.Core.UnitTest.Initialisation;
Expand All @@ -27,6 +28,9 @@ public BuildAnalyzerTestsBase()
ProjectPath = FileSystem.Path.Combine(filesystemRoot, "sourceproject");
}

protected SolutionFile BuildSolution() => SolutionFile.BuildFromProjectList(_projectCache.Keys.ToList());


/// <summary>
/// Build a simple production project
/// </summary>
Expand Down Expand Up @@ -288,6 +292,7 @@ protected Mock<IAnalyzerManager> BuildBuildAnalyzerMock(Dictionary<string, IProj
buildalyzerAnalyzerManagerMock.Setup(x => x.Projects)
.Returns(analyzerResults);
buildalyzerAnalyzerManagerMock.Setup(x => x.SetGlobalProperty(It.IsAny<string>(), It.IsAny<string>()));
buildalyzerAnalyzerManagerMock.Setup(x => x.RemoveGlobalProperty(It.IsAny<string>()));
buildalyzerAnalyzerManagerMock.Setup(x => x.SolutionFilePath).Returns((string)null);

foreach (var analyzerResult in analyzerResults)
Expand All @@ -296,7 +301,7 @@ protected Mock<IAnalyzerManager> BuildBuildAnalyzerMock(Dictionary<string, IProj
buildalyzerAnalyzerManagerMock.Setup(x => x.GetProject(filename)).Returns(analyzerResult.Value);
}

BuildalyzerProviderMock.Setup(x => x.Provide(It.IsAny<string>(), It.IsAny<AnalyzerManagerOptions>()))
BuildalyzerProviderMock.Setup(x => x.Provide(It.IsAny<AnalyzerManagerOptions>()))
.Returns(buildalyzerAnalyzerManagerMock.Object);
BuildalyzerProviderMock.Setup(x => x.Provide(It.IsAny<AnalyzerManagerOptions>()))
.Returns(buildalyzerAnalyzerManagerMock.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public void InitialBuildProcess_WithPathAsBuildCommand_ShouldThrowStrykerInputEx

var target = new InitialBuildProcess(processMock.Object, _mockFileSystem);

Should.Throw<InputException>(() => target.InitialBuild(true, null, _cProjectsExampleCsproj, null, null,
@"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe"))
Should.Throw<InputException>(() => target.InitialBuild(true, null, _cProjectsExampleCsproj, null, targetFramework: null,
msbuildPath: @"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe"))
.Details.ShouldBe("Initial build of targeted project failed. Please make sure the targeted project is buildable. You can reproduce this error yourself using: \"\"" +
@"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe" + "\" " + Path.GetFileName(_cProjectsExampleCsproj) + "\"");
}
Expand All @@ -60,7 +60,7 @@ public void InitialBuildProcess_WithPathAsBuildCommand_TriesWithMsBuildIfDotnetF

var target = new InitialBuildProcess(processMock.Object, _mockFileSystem);

Should.Throw<InputException>(() => target.InitialBuild(false, null, _cProjectsExampleCsproj, null, null, @"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe"))
Should.Throw<InputException>(() => target.InitialBuild(false, null, _cProjectsExampleCsproj, null, targetFramework: null, msbuildPath: @"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe"))
.Details.ShouldBe("Initial build of targeted project failed. Please make sure the targeted project is buildable. You can reproduce this error yourself using: \"\"" +
@"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe" + "\" " + _mockFileSystem.Path.GetFileName(_cProjectsExampleCsproj) + "\"");

Expand Down Expand Up @@ -123,7 +123,7 @@ public void InitialBuildProcess_ShouldUseCustomMsbuildIfNotNull()

var target = new InitialBuildProcess(processMock.Object, mockFileSystem);

target.InitialBuild(true, "/", "./ExampleProject.sln", null, null, CustomMsBuildPath);
target.InitialBuild(true, "/", "./ExampleProject.sln", null, targetFramework: null, msbuildPath: CustomMsBuildPath);
processMock.Verify(x => x.Start(It.IsAny<string>(),
It.Is<string>(applicationParam => applicationParam == CustomMsBuildPath),
It.Is<string>(argumentsParam => argumentsParam.Contains("ExampleProject.sln")),
Expand All @@ -132,6 +132,26 @@ public void InitialBuildProcess_ShouldUseCustomMsbuildIfNotNull()
Times.Once);
}

[TestMethod]
public void InitialBuildProcess_ShouldUseProvidedConfiguration()
{
var processMock = new Mock<IProcessExecutor>(MockBehavior.Strict);
var mockFileSystem = new MockFileSystem();

processMock.SetupProcessMockToReturn("");

var target = new InitialBuildProcess(processMock.Object, mockFileSystem);

target.InitialBuild(false, "/", "./ExampleProject.sln", "TheDebug");
processMock.Verify(x => x.Start(It.IsAny<string>(),
It.IsAny<string>(),
It.Is<string>(argumentsParam => argumentsParam.Contains("-c TheDebug")),
It.IsAny<IEnumerable<KeyValuePair<string, string>>>(),
It.IsAny<int>()),
Times.Once);
}


[TestMethod]
public void InitialBuildProcess_ShouldRunDotnetBuildIfNotDotnetFramework()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public void InitialisationProcess_ShouldThrowOnFailedInitialTestRun()
}});

inputFileResolverMock.SetupGet(x => x.FileSystem).Returns(new FileSystem());
initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null, It.IsAny<string>()));
initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(),
It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(),
It.IsAny<string>(), null, It.IsAny<string>()));
testRunnerMock.Setup(x => x.GetTests(It.IsAny<IProjectAndTests>())).Returns(new TestSet());
testRunnerMock.Setup(x => x.DiscoverTests(It.IsAny<string>())).Returns(true);
initialTestProcessMock.Setup(x => x.InitialTest(It.IsAny<StrykerOptions>(), It.IsAny<IProjectAndTests>(), It.IsAny<ITestRunner>())).Throws(new InputException("")); // failing test
Expand Down Expand Up @@ -114,7 +116,9 @@ public void InitialisationProcess_ShouldThrowIfHalfTestsAreFailing()
new[] { new SourceProjectInfo { AnalyzerResult = TestHelper.SetupProjectAnalyzerResult(references: Array.Empty<string>()).Object, TestProjectsInfo = new TestProjectsInfo(new MockFileSystem()) } });

inputFileResolverMock.SetupGet(x => x.FileSystem).Returns(fileSystemMock);
initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null, It.IsAny<string>()));
initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(),
It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(),
null,It.IsAny<string>()));
var failedTest = "testid";
var ranTests = new TestIdentifierList(failedTest, "othertest");
var testSet = new TestSet();
Expand Down Expand Up @@ -166,7 +170,8 @@ public void InitialisationProcess_ShouldThrowOnTestTestIfAskedFor(bool breakOnIn
}});

inputFileResolverMock.SetupGet(x => x.FileSystem).Returns(new FileSystem());
initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null, It.IsAny<string>()));
initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(), It.IsAny<string>(),
It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null, It.IsAny<string>()));
var failedTest = "testid";
var ranTests = new TestIdentifierList(failedTest, "othertest", "anothertest");
var testSet = new TestSet();
Expand Down Expand Up @@ -218,9 +223,9 @@ public void InitialisationProcess_ShouldRunTestSession()
inputFileResolverMock.Setup(x => x.ResolveSourceProjectInfos(It.IsAny<StrykerOptions>())).Returns(
new[] { new SourceProjectInfo() { AnalyzerResult = TestHelper.SetupProjectAnalyzerResult(references: Array.Empty<string>()).Object, TestProjectsInfo = new TestProjectsInfo(new MockFileSystem()) } });


inputFileResolverMock.SetupGet(x => x.FileSystem).Returns(new FileSystem());
initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null, It.IsAny<string>()));
initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(), It.IsAny<string>(),
It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null, It.IsAny<string>()));
var testSet = new TestSet();
testSet.RegisterTest(new TestDescription("id", "name", "test.cs"));
testRunnerMock.Setup(x => x.DiscoverTests(It.IsAny<string>())).Returns(true);
Expand Down Expand Up @@ -277,7 +282,8 @@ public void InitialisationProcess_ShouldThrowOnWhenNoTestDetected(string library
TestProjectsInfo = new TestProjectsInfo(new MockFileSystem()){TestProjects = new List<TestProject> {new(new MockFileSystem(), testProjectAnalyzerResult)}}
}});

initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null, It.IsAny<string>()));
initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(), It.IsAny<string>(),
It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null, It.IsAny<string>()));
testRunnerMock.Setup(x => x.DiscoverTests(It.IsAny<string>())).Returns(false);
testRunnerMock.Setup(x => x.GetTests(It.IsAny<IProjectAndTests>())).Returns(new TestSet());
initialTestProcessMock.Setup(x => x.InitialTest(It.IsAny<StrykerOptions>(), It.IsAny<IProjectAndTests>(), It.IsAny<ITestRunner>()))
Expand Down Expand Up @@ -328,7 +334,8 @@ public void InitialisationProcess_ShouldThrowOnWhenNoTestDetectedAndCorrectDepen
TestProjectsInfo = new TestProjectsInfo(new MockFileSystem()){TestProjects = new List<TestProject> {new(new MockFileSystem(), testProjectAnalyzerResult)}}
}});

initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null, It.IsAny<string>()));
initialBuildProcessMock.Setup(x => x.InitialBuild(It.IsAny<bool>(), It.IsAny<string>(),
It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null, It.IsAny<string>()));
testRunnerMock.Setup(x => x.DiscoverTests(It.IsAny<string>())).Returns(false);
testRunnerMock.Setup(x => x.GetTests(It.IsAny<IProjectAndTests>())).Returns(new TestSet());
initialTestProcessMock.Setup(x => x.InitialTest(It.IsAny<StrykerOptions>(), It.IsAny<IProjectAndTests>(), It.IsAny<ITestRunner>()))
Expand Down
Loading
Loading