Skip to content

Commit

Permalink
Release 1.6.0 (#36)
Browse files Browse the repository at this point in the history
* Cleaned up unused nugets
* Removed the shared WPF project and moved code to VS extension project.
* Added a new filter editor tab to the VS extension
* Added better error handling in the VS extension
* It's now possible to filter mutations by code (CodeConstrain in filterItem)
* Fixed so we use the current project build configuration when running mutations in the VS extension.
  • Loading branch information
MilleBo authored Feb 22, 2020
1 parent d81aa63 commit a18db1f
Show file tree
Hide file tree
Showing 102 changed files with 1,181 additions and 1,156 deletions.
10 changes: 0 additions & 10 deletions Testura.Mutation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HelpClients", "HelpClients"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testura.Mutation.VsExtension", "src\Testura.Mutation.VsExtension\Testura.Mutation.VsExtension.csproj", "{8D4CD864-3656-48FC-8B2A-F0F710B73928}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testura.Mutation.Wpf.Shared", "src\Testura.Mutation.Wpf.Shared\Testura.Mutation.Wpf.Shared.csproj", "{30E41F1E-12E0-4231-9450-596151FD70B0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{6B5E11CF-2A04-443E-BD7D-BA8A8BAEBCB4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -63,10 +59,6 @@ Global
{8D4CD864-3656-48FC-8B2A-F0F710B73928}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D4CD864-3656-48FC-8B2A-F0F710B73928}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D4CD864-3656-48FC-8B2A-F0F710B73928}.Release|Any CPU.Build.0 = Release|Any CPU
{30E41F1E-12E0-4231-9450-596151FD70B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30E41F1E-12E0-4231-9450-596151FD70B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30E41F1E-12E0-4231-9450-596151FD70B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30E41F1E-12E0-4231-9450-596151FD70B0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -79,8 +71,6 @@ Global
{DE7878FE-0F75-44FC-8964-0B3D3E815FD9} = {D58AF013-64A5-4DFA-B248-94022A2F04F4}
{8A6DDFAB-F6BE-44D9-B58F-6139149875A5} = {6018C720-2F71-47BC-BB8C-8205C14BF262}
{8D4CD864-3656-48FC-8B2A-F0F710B73928} = {A4F21A57-015F-4673-A5A5-6AABEB01BC59}
{30E41F1E-12E0-4231-9450-596151FD70B0} = {6B5E11CF-2A04-443E-BD7D-BA8A8BAEBCB4}
{6B5E11CF-2A04-443E-BD7D-BA8A8BAEBCB4} = {A4F21A57-015F-4673-A5A5-6AABEB01BC59}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C14D27F5-1332-495A-A4BA-A03DBD925174}
Expand Down
1 change: 1 addition & 0 deletions TesturaMutationBaseConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"TestProjects":["Testura.Mutation.Tests"],"IgnoredProjects":[],"ProjectMappings":[],"Filter":{"FilterItems":[{"Resource":"*","CodeConstrain":"*Log.*","Effect":"Deny"}]},"NumberOfTestRunInstances":3,"BuildConfiguration":"debug","MaxTestTimeMin":5,"TestRunner":"DotNet","Mutators":["ConditionalBoundary","NegateCondtional","Math","NegateTypeCompability","Increment","ReturnValue","MethodCall"],"CreateBaseline":true}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Anotar.Log4Net;
using log4net;
using MediatR;
using Testura.Mutation.Core;
using Testura.Mutation.Core.Execution;
Expand All @@ -13,6 +13,8 @@ namespace Testura.Mutation.Application.Commands.Mutation.ExecuteMutations
{
public class ExecuteMutationsCommandHandler : IRequestHandler<ExecuteMutationsCommand, IList<MutationDocumentResult>>
{
private static readonly ILog Log = LogManager.GetLogger(typeof(ExecuteMutationsCommandHandler));

private readonly MutationDocumentExecutor _mutationDocumentExecutor;
private readonly MutationRunLoggerFactory _mutationRunLoggerFactory;

Expand All @@ -32,8 +34,8 @@ public async Task<IList<MutationDocumentResult>> Handle(ExecuteMutationsCommand
var mutationRunLoggers = command.Config.MutationRunLoggers?.Select(m => _mutationRunLoggerFactory.GetMutationRunLogger(m)).ToList() ?? new List<IMutationRunLogger>();
var expectedExecutionTime = GetExpectedExecutionTime(command);

LogTo.Info($"Total number of mutations generated: {numberOfMutationsLeft}");
LogTo.Info($"Expected execution time: {expectedExecutionTime}");
Log.Info($"Total number of mutations generated: {numberOfMutationsLeft}");
Log.Info($"Expected execution time: {expectedExecutionTime}");

mutationRunLoggers.ForEach(m => m.LogBeforeRun(command.MutationDocuments));

Expand All @@ -43,7 +45,7 @@ await Task.Run(() =>
{
if (cancellationToken.IsCancellationRequested)
{
LogTo.Info("Cancellation requested (mutation run)");
Log.Info("Cancellation requested (mutation run)");
return;
}

Expand All @@ -64,8 +66,8 @@ await Task.Run(() =>
}
catch (Exception ex)
{
LogTo.WarnException($"Unexpected exception when running {document.MutationName}", ex);
LogTo.Info("Will put it in the unknown category.");
Log.Warn($"Unexpected exception when running {document.MutationName}", ex);
Log.Info("Will put it in the unknown category.");

result = new MutationDocumentResult
{
Expand All @@ -85,7 +87,7 @@ await Task.Run(() =>
var unknownErrors = results.Count(r => r.UnexpectedError != null);

Interlocked.Decrement(ref numberOfMutationsLeft);
LogTo.Info($"Current progress: {{ Survived: {survived}, Killed: {killed}, CompileErrors: {compileErrors}, UnknownErrors: {unknownErrors}, MutationsLeft: {numberOfMutationsLeft} }}");
Log.Info($"Current progress: {{ Survived: {survived}, Killed: {killed}, CompileErrors: {compileErrors}, UnknownErrors: {unknownErrors}, MutationsLeft: {numberOfMutationsLeft} }}");
mutationRunLoggers.ForEach(m => m.LogAfterMutation(document, results, numberOfMutationsLeft));
}

Expand All @@ -101,12 +103,12 @@ await Task.Run(() =>

if (results.Any() && !cancellationToken.IsCancellationRequested)
{
LogTo.Info($"Your mutation score: {GetMutationScore(results)}%");
Log.Info($"Your mutation score: {GetMutationScore(results)}%");
}

if (cancellationToken.IsCancellationRequested)
{
LogTo.Info("Mutation run was cancelled");
Log.Info("Mutation run was cancelled");
}

return results;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Anotar.Log4Net;
using log4net;
using MediatR;
using Newtonsoft.Json;

namespace Testura.Mutation.Application.Commands.Project.CreateProject
{
public class CreateProjectCommandHandler : IRequestHandler<CreateProjectCommand, bool>
{
private static readonly ILog Log = LogManager.GetLogger(typeof(CreateProjectCommandHandler));

public Task<bool> Handle(CreateProjectCommand command, CancellationToken cancellationToken)
{
LogTo.Info("Creating project file");
Log.Info("Creating project file");
File.WriteAllText(command.SavePath, JsonConvert.SerializeObject(command.Config));

return Task.FromResult(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Threading;
using Anotar.Log4Net;
using log4net;
using Testura.Mutation.Application.Models;
using Testura.Mutation.Core.Config;
using Testura.Mutation.Core.Creator.Filter;
Expand All @@ -10,6 +10,8 @@ namespace Testura.Mutation.Application.Commands.Project.OpenProject.Handlers
{
public class OpenProjectGitFilterHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(OpenProjectGitFilterHandler));

private readonly MutationDocumentFilterItemGitDiffCreator _diffCreator;

public OpenProjectGitFilterHandler(MutationDocumentFilterItemGitDiffCreator diffCreator)
Expand All @@ -23,7 +25,7 @@ public OpenProjectGitFilterHandler(MutationDocumentFilterItemGitDiffCreator diff

if (fileConfig.Git != null && fileConfig.Git.GenerateFilterFromDiffWithMaster)
{
LogTo.Info("Creating filter items from git diff with master");
Log.Info("Creating filter items from git diff with master");

var filterItems = _diffCreator.GetFilterItemsFromDiff(Path.GetDirectoryName(fileConfig.SolutionPath), string.Empty);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Anotar.Log4Net;
using log4net;
using Testura.Mutation.Application.Exceptions;
using Testura.Mutation.Application.Models;
using Testura.Mutation.Core;
Expand All @@ -14,11 +14,13 @@ namespace Testura.Mutation.Application.Commands.Project.OpenProject.Handlers
{
public class OpenProjectMutatorsHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(OpenProjectMutatorsHandler));

public void InitializeMutators(MutationFileConfig fileConfig, MutationConfig applicationConfig, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();

LogTo.Info("Loading mutators..");
Log.Info("Loading mutators..");

if (fileConfig.Mutators == null || !fileConfig.Mutators.Any())
{
Expand All @@ -32,13 +34,13 @@ public class OpenProjectMutatorsHandler

private void LoadCustomMutatorList(MutationFileConfig fileConfig, MutationConfig applicationConfig)
{
LogTo.Info("..found mutators in config.");
Log.Info("..found mutators in config.");
var mutators = new List<IMutator>();
foreach (var mutationOperator in fileConfig.Mutators)
{
if (Enum.TryParse<MutationOperators>(mutationOperator, true, out var mutationOperatorEnum))
{
LogTo.Info($"Adding '{mutationOperator}' mutator");
Log.Info($"Adding '{mutationOperator}' mutator");
mutators.Add(MutationOperatorFactory.GetMutationOperator(mutationOperatorEnum));
continue;
}
Expand All @@ -52,7 +54,7 @@ private void LoadCustomMutatorList(MutationFileConfig fileConfig, MutationConfig

private void LoadDefaultMutators(MutationConfig applicationConfig)
{
LogTo.Info("..did not find any mutators in config so loading default ones.");
Log.Info("..did not find any mutators in config so loading default ones.");

applicationConfig.Mutators = new List<IMutator>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Anotar.Log4Net;
using log4net;
using Testura.Mutation.Application.Exceptions;
using Testura.Mutation.Application.Models;
using Testura.Mutation.Core.Git;
Expand All @@ -10,6 +10,8 @@ namespace Testura.Mutation.Application.Commands.Project.OpenProject.Handlers
{
public class OpenProjectSolutionExistHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(OpenProjectSolutionExistHandler));

private readonly IGitCloner _gitCloner;

public OpenProjectSolutionExistHandler(IGitCloner gitCloner)
Expand All @@ -30,7 +32,7 @@ public OpenProjectSolutionExistHandler(IGitCloner gitCloner)

if (!fileExist || (fileConfig.Git != null && fileConfig.Git.ForceClone))
{
LogTo.Info("Could not find project or force clone are enabled so we will clone project.");
Log.Info("Could not find project or force clone are enabled so we will clone project.");
await _gitCloner.CloneSolutionAsync(
fileConfig.Git.RepositoryUrl,
fileConfig.Git.Branch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Anotar.Log4Net;
using Microsoft.CodeAnalysis;
using log4net;
using Testura.Mutation.Application.Exceptions;
using Testura.Mutation.Application.Models;
using Testura.Mutation.Core.Baseline;
Expand All @@ -18,6 +17,8 @@ namespace Testura.Mutation.Application.Commands.Project.OpenProject.Handlers
{
public class OpenProjectWorkspaceHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(OpenProjectWorkspaceHandler));

private readonly BaselineCreator _baselineCreator;
private readonly ISolutionOpener _solutionOpener;

Expand Down Expand Up @@ -49,7 +50,7 @@ private void InitializeMutationProjects(MutationFileConfig fileConfig, MutationC
fileConfig.IgnoredProjects = new List<string>();
}

LogTo.Info("Setting up mutation projects.");
Log.Info("Setting up mutation projects.");
foreach (var solutionProject in config.Solution.Projects)
{
if (
Expand All @@ -60,7 +61,7 @@ private void InitializeMutationProjects(MutationFileConfig fileConfig, MutationC
continue;
}

LogTo.Info($"Grabbing output info for {solutionProject.Name}.");
Log.Info($"Grabbing output info for {solutionProject.Name}.");

config.MutationProjects.Add(new MutationProject
{
Expand Down Expand Up @@ -90,11 +91,11 @@ private void InitializeTestProjects(MutationFileConfig fileConfig, MutationConfi
{
if (fileConfig.TestProjects == null || !fileConfig.TestProjects.Any())
{
LogTo.Error("Test project list is null or empty");
Log.Error("Test project list is null or empty");
throw new ProjectSetUpException("Test project list is null or empty");
}

LogTo.Info("Setting up test projects.");
Log.Info("Setting up test projects.");
foreach (var testProjectName in fileConfig.TestProjects)
{
var testProjects = config.Solution.Projects.Where(p => Regex.IsMatch(p.Name, FormattedProjectName(testProjectName), RegexOptions.IgnoreCase));
Expand All @@ -106,19 +107,19 @@ private void InitializeTestProjects(MutationFileConfig fileConfig, MutationConfi

foreach (var testProject in testProjects)
{
LogTo.Info($"Found the test project {testProject.Name}. Grabbing output info.");
Log.Info($"Found the test project {testProject.Name}. Grabbing output info.");

if (IsIgnored(testProject.Name, fileConfig.IgnoredProjects))
{
LogTo.Info("But it was ignored. So skipping");
Log.Info("But it was ignored. So skipping");
continue;
}

if (WeTargetSpecificFrameworkThatThisProjectDontSupport(
testProject.FilePath,
fileConfig.TargetFramework))
{
LogTo.Info("Project does not target expected framework");
Log.Info("Project does not target expected framework");
continue;
}

Expand All @@ -128,7 +129,7 @@ private void InitializeTestProjects(MutationFileConfig fileConfig, MutationConfi
}

var testProjectOutput = UpdateOutputPathWithBuildConfiguration(testProject.OutputFilePath, config.BuildConfiguration);
LogTo.Info($"Wanted build configuration is \"{config.BuildConfiguration}\". Setting test project output to \"{testProjectOutput}\"");
Log.Info($"Wanted build configuration is \"{config.BuildConfiguration}\". Setting test project output to \"{testProjectOutput}\"");
config.TestProjects.Add(new TestProject
{
Project = new SolutionProjectInfo(testProject.Name, testProject.FilePath, testProjectOutput),
Expand All @@ -141,28 +142,28 @@ private void InitializeTestProjects(MutationFileConfig fileConfig, MutationConfi
private string GetTestRunner(Microsoft.CodeAnalysis.Project testProject, string fileConfigTestRunner)
{
// This is a bit hackish but it's until I fix so you can specify test runner in file config.
LogTo.Info($"Looking for test runner for {testProject.Name}..");
Log.Info($"Looking for test runner for {testProject.Name}..");
if (!string.IsNullOrEmpty(fileConfigTestRunner))
{
LogTo.Info($"..found {fileConfigTestRunner} in config.");
Log.Info($"..found {fileConfigTestRunner} in config.");
return fileConfigTestRunner;
}

if (testProject.ParseOptions.PreprocessorSymbolNames.Any(p => p.ToUpper().Contains("NETCOREAPP")))
{
LogTo.Info("..found .core in symbol names so will use dotnet.");
Log.Info("..found .core in symbol names so will use dotnet.");
return "dotnet";
}

if (testProject.MetadataReferences.Any(m => m.Display.ToLower().Contains("nunit")))
{
LogTo.Info("..found nunit in references so will use that.");
Log.Info("..found nunit in references so will use that.");
return "nunit";
}

if (testProject.MetadataReferences.Any(m => m.Display.ToLower().Contains("xunit")))
{
LogTo.Info("..found xunit in references so will use that.");
Log.Info("..found xunit in references so will use that.");
return "xunit";
}

Expand Down
Loading

0 comments on commit a18db1f

Please sign in to comment.