Ejemplo n.º 1
0
        /// <summary>
        /// Finds the referencedProjects and looks for all files that should be mutated in those projects
        /// </summary>
        public ProjectInfo ResolveInput(StrykerOptions options)
        {
            var projectInfo = new ProjectInfo();
            // Determine test projects
            var    testProjectFiles = new List <string>();
            string projectUnderTest = null;

            if (options.TestProjects != null && options.TestProjects.Any())
            {
                testProjectFiles = options.TestProjects.Select(FindTestProject).ToList();
            }
            else
            {
                testProjectFiles.Add(FindTestProject(options.BasePath));
            }

            _logger.LogInformation("Identifying project to mutate.");
            var testProjectAnalyzerResults = new List <ProjectAnalyzerResult>();

            foreach (var testProjectFile in testProjectFiles)
            {
                // Analyze the test project
                testProjectAnalyzerResults.Add(_projectFileReader.AnalyzeProject(testProjectFile, options.SolutionPath));
            }
            projectInfo.TestProjectAnalyzerResults = testProjectAnalyzerResults;

            // Determine project under test
            projectUnderTest = FindProjectUnderTest(projectInfo.TestProjectAnalyzerResults, options.ProjectUnderTestNameFilter);

            _logger.LogInformation("The project {0} will be mutated.", projectUnderTest);

            // Analyze project under test
            projectInfo.ProjectUnderTestAnalyzerResult = _projectFileReader.AnalyzeProject(projectUnderTest, options.SolutionPath);

            // if we are in devmode, dump all properties as it can help diagnosing build issues for user project.
            if (projectInfo.ProjectUnderTestAnalyzerResult.Properties != null && options.DevMode)
            {
                _logger.LogInformation("**** Buildalyzer properties. ****");
                // dump properties
                foreach (var keyValuePair in projectInfo.ProjectUnderTestAnalyzerResult.Properties)
                {
                    _logger.LogInformation("{0}={1}", keyValuePair.Key, keyValuePair.Value);
                }

                _logger.LogInformation("**** Buildalyzer properties. ****");
            }

            IProjectComponent inputFiles = new CsharpProjectComponentsBuilder(projectInfo, options, _foldersToExclude, _logger, _fileSystem).Build();

            projectInfo.ProjectContents = inputFiles;

            ValidateTestProjectsCanBeExecuted(projectInfo, options);
            _logger.LogInformation("Analysis complete.");

            return(projectInfo);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds the referencedProjects and looks for all files that should be mutated in those projects
        /// </summary>
        public ProjectInfo ResolveInput(IStrykerOptions options)
        {
            var projectInfo = new ProjectInfo();
            // Determine test projects
            var    testProjectFiles = new List <string>();
            string projectUnderTest = null;

            if (options.TestProjects != null && options.TestProjects.Any())
            {
                testProjectFiles = options.TestProjects.Select(FindTestProject).ToList();
            }
            else
            {
                testProjectFiles.Add(FindTestProject(options.BasePath));
            }

            var testProjectAnalyzerResults = new List <IAnalyzerResult>();

            foreach (var testProjectFile in testProjectFiles)
            {
                // Analyze the test project
                testProjectAnalyzerResults.Add(_projectFileReader.AnalyzeProject(testProjectFile, options.SolutionPath));
            }
            projectInfo.TestProjectAnalyzerResults = testProjectAnalyzerResults;

            // Determine project under test
            if (options.TestProjects != null && options.TestProjects.Any())
            {
                projectUnderTest = FindProjectFile(options.BasePath);
            }
            else
            {
                projectUnderTest = FindProjectUnderTest(projectInfo.TestProjectAnalyzerResults, options.ProjectUnderTestNameFilter);
            }

            _logger.LogInformation("The project {0} will be mutated.", projectUnderTest);

            // Analyze project under test
            projectInfo.ProjectUnderTestAnalyzerResult = _projectFileReader.AnalyzeProject(projectUnderTest, options.SolutionPath);

            IProjectComponent inputFiles = new CsharpProjectComponentsBuilder(projectInfo, options, _foldersToExclude, _logger, _fileSystem).Build();

            projectInfo.ProjectContents = inputFiles;

            ValidateTestProjectsCanBeExecuted(projectInfo, options);
            _logger.LogInformation("Analysis complete.");

            return(projectInfo);
        }