public async Task <IList <BaselineInfo> > RunBaselineAsync(MutationConfig config, bool runBaseline, CancellationToken cancellationToken = default(CancellationToken)) { var baselineInfos = new List <BaselineInfo>(); if (runBaseline) { return(await _baselineCreator.CreateBaselineAsync(config, cancellationToken)); } return(baselineInfos); }
public async Task CreateBaselineAsync_WhenCreatingBaseline_ShouldGetBaselineInfoAndDeleteBaselineDirectory() { var baselineCreator = new BaselineCreator( _fileSystem, new BaselineCreatorCompileMutationProjectsHandler(ProjectCompilerCreator.CreatePositiveCompiler(_fileSystem), _fileSystem), new BaselineCreatorRunUnitTestsHandler(TestRunnerClientCreator.CreatePositive(), new TestRunnerDependencyFilesHandler(_fileSystem)), new BaselineCreatorLogSummaryHandler()); var result = await baselineCreator.CreateBaselineAsync(_config); Assert.AreEqual(1, result.Count); Assert.AreEqual("TestProject", result.First().TestProjectName); Assert.AreEqual(TimeSpan.FromSeconds(1), result.First().ExecutionTime); }
public Task <IList <BaselineInfo> > Handle(CreateBaselineCommand request, CancellationToken cancellationToken) { return(_baselineCreator.CreateBaselineAsync(request.Config)); }
public async Task <UnimaConfig> Handle(OpenProjectCommand command, CancellationToken cancellationToken) { var path = command.Path; LogTo.Info($"Opening project at {path}"); try { var fileContent = File.ReadAllText(path); LogTo.Info($"Loading configuration: {fileContent}"); var fileConfig = JsonConvert.DeserializeObject <UnimaFileConfig>(fileContent); var config = new UnimaConfig { SolutionPath = fileConfig.SolutionPath, Filter = fileConfig.Filter, NumberOfTestRunInstances = fileConfig.NumberOfTestRunInstances, BuildConfiguration = fileConfig.BuildConfiguration, MaxTestTimeMin = fileConfig.MaxTestTimeMin, DotNetPath = fileConfig.DotNetPath, MutationRunLoggers = fileConfig.MutationRunLoggers }; using (var workspace = MSBuildWorkspace.Create()) { LogTo.Info("Opening solution.."); if (!File.Exists(config.SolutionPath)) { throw new FileNotFoundException("Could not find solution", config.SolutionPath); } var solution = await workspace.OpenSolutionAsync(config.SolutionPath); if (workspace.Diagnostics.Any(w => w.Kind == WorkspaceDiagnosticKind.Failure && ContainsProjectName(w.Message, config.MutationProjects, config.TestProjects.Select(t => t.Project).ToList()))) { foreach (var workspaceDiagnostic in workspace.Diagnostics.Where(d => d.Kind == WorkspaceDiagnosticKind.Failure)) { LogTo.Error($"Workspace error: {workspaceDiagnostic.Message}"); } throw new ProjectSetUpException("Failed to open solution. View log for details."); } InitializeTestProjects(fileConfig, config, solution); InitializeMutationProjects(fileConfig, config, solution); if (command.CreateBaseline) { config.BaselineInfos = new List <BaselineInfo>(await _baselineCreator.CreateBaselineAsync(config, solution)); } workspace.CloseSolution(); LogTo.Info("Opening project finished."); } return(config); } catch (Exception ex) { LogTo.ErrorException("Failed to open project", ex); throw new OpenProjectException("Failed to open project", ex); } }