private (MutationFileConfig fileConfig, MutationConfig applicationConfig) LoadConfigs( string path, MutationFileConfig fileConfig) { if (fileConfig == null) { var fileContent = File.ReadAllText(path); Log.Info($"Loading configuration: {fileContent}"); fileConfig = JsonConvert.DeserializeObject <MutationFileConfig>(fileContent); } var config = new MutationConfig { Filter = fileConfig.Filter ?? new MutationDocumentFilter(), NumberOfTestRunInstances = fileConfig.NumberOfTestRunInstances, BuildConfiguration = fileConfig.BuildConfiguration, MaxTestTimeMin = fileConfig.MaxTestTimeMin, DotNetPath = fileConfig.DotNetPath, MutationRunLoggers = fileConfig.MutationRunLoggers, }; return(fileConfig, config); }
public IList <MutationProject> CreateMutationProjects(MutationFileConfig fileConfig, Solution solution, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); var mutationProjects = new List <MutationProject>(); Log.Info("Setting up mutation projects."); foreach (var solutionProject in solution.Projects) { if ( IsIgnored(solutionProject.Name, fileConfig.IgnoredProjects) || IsTestProject(solutionProject.Name, fileConfig.TestProjects)) { continue; } Log.Info($"Grabbing output info for {solutionProject.Name}."); mutationProjects.Add(new MutationProject { Project = new SolutionProjectInfo(solutionProject.Name, solutionProject.FilePath, UpdateOutputPathWithBuildConfiguration(solutionProject.OutputFilePath, fileConfig.BuildConfiguration)), MappedTestProjects = GetMappedProjects(solutionProject.Name, fileConfig.ProjectMappings) }); } return(mutationProjects); }
public void SetUp() { _fileSystem = new MockFileSystem(); _fileConfig = ConfigCreator.CreateFileConfig(); _config = ConfigCreator.CreateConfig(_fileSystem); _openProjectWorkspaceHandler = new OpenProjectWorkspaceHandler(); }
public void SetUp() { _fileSystem = new MockFileSystem(); _config = ConfigCreator.CreateConfig(_fileSystem); _fileConfig = ConfigCreator.CreateFileConfig(); _openProjectCommandHandler = new OpenProjectCommandHandler( new OpenProjectSolutionHandler(_fileSystem, new SolutionOpenerStub(_config.Solution)), new OpenProjectMutatorsHandler(), new OpenProjectGitFilterHandler(new MutationDocumentFilterItemGitDiffCreator(new GitDiffStub())), new OpenProjectWorkspaceHandler(), new OpenProjectBaselineHandler(BaselineCreatorCreator.CreatePositiveBaseline(_fileSystem))); }
public List <TestProject> CreateTestProjects(MutationFileConfig fileConfig, Solution solution, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); var testProjects = new List <TestProject>(); if (fileConfig.TestProjects == null || !fileConfig.TestProjects.Any()) { Log.Error("Test project list is null or empty"); throw new ProjectSetUpException("Test project list is null or empty"); } Log.Info("Setting up test projects."); foreach (var testProjectName in fileConfig.TestProjects) { var matchedTestProjects = solution.Projects.Where(p => Regex.IsMatch(p.Name, FormattedProjectName(testProjectName), RegexOptions.IgnoreCase)); if (!matchedTestProjects.Any()) { throw new ProjectSetUpException($"Could not find any project with the name {testProjectName} in the solution. List of project names: {string.Join(", ", solution.Projects.Select(p => p.Name))}"); } foreach (var testProject in matchedTestProjects) { Log.Info($"Found the test project {testProject.Name}. Grabbing output info."); if (IsIgnored(testProject.Name, fileConfig.IgnoredProjects)) { Log.Info("But it was ignored. So skipping"); continue; } if (testProjects.Any(t => t.Project.Name == testProject.Name)) { continue; } var testProjectOutput = UpdateOutputPathWithBuildConfiguration(testProject.OutputFilePath, fileConfig.BuildConfiguration); Log.Info($"Wanted build configuration is \"{fileConfig.BuildConfiguration}\". Setting test project output to \"{testProjectOutput}\""); testProjects.Add(new TestProject { Project = new SolutionProjectInfo(testProject.Name, testProject.FilePath, testProjectOutput), TestRunner = GetTestRunner(testProject, fileConfig.TestRunner) }); } } return(testProjects); }
private async void CreateProject() { var projectPath = Path.Combine(ProjectPath, $"{ProjectName}.json"); var config = new MutationFileConfig { IgnoredProjects = new List <string>(), SolutionPath = SolutionPath, TestProjects = SelectedTestProjectInSolution.Where(s => s.IsSelected).Select(s => s.ProjectInfo.Name).ToList(), TestRunner = TestRunnerTypes[SelectedTestRunnerIndex] }; await _mediator.Send(new CreateProjectCommand(projectPath, config)); await _mediator.Send(new AddProjectHistoryCommand(projectPath)); _mutationModuleTabOpener.OpenOverviewTab(await _mediator.Send(new OpenProjectCommand(projectPath))); }
public async Task <MutationConfig> Handle(OpenProjectCommand command, CancellationToken cancellationToken) { var path = command.Path; MutationConfig applicationConfig = null; MutationFileConfig fileConfig = null; Log.Info($"Opening project at {command.Config?.SolutionPath ?? path}"); try { (fileConfig, applicationConfig) = LoadConfigs(path, command.Config); // Solution and mutators applicationConfig.Solution = await _solutionHandler.OpenSolutionAsync(fileConfig.SolutionPath, fileConfig.BuildConfiguration, cancellationToken); applicationConfig.Mutators = _mutatorsHandler.InitializeMutators(fileConfig.Mutators, cancellationToken); // Filter applicationConfig.Filter.FilterItems.AddRange(_gitFilterHandler.CreateGitFilterItems(fileConfig.SolutionPath, fileConfig.Git, cancellationToken)); // Projects applicationConfig.MutationProjects = _workspaceHandler.CreateMutationProjects(fileConfig, applicationConfig.Solution, cancellationToken); applicationConfig.TestProjects = _workspaceHandler.CreateTestProjects(fileConfig, applicationConfig.Solution, cancellationToken); // Baseline applicationConfig.BaselineInfos = await _baselineHandler.RunBaselineAsync(applicationConfig, fileConfig.CreateBaseline, cancellationToken); Log.Info("Opening project finished."); return(applicationConfig); } catch (OperationCanceledException) { Log.Info("Open project was cancelled by request"); return(applicationConfig); } catch (Exception ex) { Log.Error("Failed to open project"); Log.Error(ex.Message); throw new OpenProjectException("Failed to open project", ex); } }
public CreateProjectCommand(string savePath, MutationFileConfig config) { SavePath = savePath; Config = config; }
public OpenProjectCommand(MutationFileConfig config) { Config = config; }