Esempio n. 1
0
        public static void ReloadCoverage(IEnumerable <CoverageProject> projects, bool darkMode)
        {
            // reset

            ClearProcesses();

            HtmlFilePath = null;

            CoverageLines.Clear();

            // process pipeline

            projects = projects
                       .Select(project =>
            {
                project.Settings = GetSettings(project);

                if (!project.Settings.Enabled)
                {
                    project.FailureDescription = $"Disabled";
                    return(project);
                }

                if (string.IsNullOrWhiteSpace(project.ProjectFile))
                {
                    project.FailureDescription = $"Unsupported project type for DLL '{project.TestDllFileInOutputFolder}'";
                    return(project);
                }

                project.WorkOutputFolder        = Path.Combine(project.WorkFolder, "_outputfolder");
                project.CoverToolOutputFile     = Path.Combine(project.WorkOutputFolder, "_cover.tool.xml");
                project.TestDllFileInWorkFolder = Path.Combine(project.WorkFolder, Path.GetFileName(project.TestDllFileInOutputFolder));
                project.IsDotNetSdkStyle        = IsDotNetSdkStyle(project);

                return(project);
            })
                       .Select(p => p.Step("Ensure Work Folder Exists", project =>
            {
                // create folders

                var logs = new List <string>();

                if (!Directory.Exists(project.WorkFolder))
                {
                    Directory.CreateDirectory(project.WorkFolder);
                    logs.Add($"Created : {project.WorkFolder}");
                }

                if (!Directory.Exists(project.WorkOutputFolder))
                {
                    Directory.CreateDirectory(project.WorkOutputFolder);
                    logs.Add($"Created : {project.WorkOutputFolder}");
                }

                //Logger.LogWithoutTitle(logs);
            }))
                       .Select(p => p.Step("Synchronize Output Files To Work Folder", project =>
            {
                // sync files from output folder to work folder where we do the analysis

                var logs = FileSynchronizationUtil.Synchronize(project.ProjectOutputFolder, project.WorkFolder);

                //Logger.LogWithoutTitle(logs);
            }))
                       .Select(p => p.Step("Run Coverage Tool", project =>
            {
                // run the appropriate cover tool

                if (project.IsDotNetSdkStyle)
                {
                    CoverletUtil.RunCoverlet(project, true);
                }
                else
                {
                    OpenCoverUtil.RunOpenCover(project, true);
                }
            }))
                       .Where(x => !x.HasFailed)
                       .ToArray();

            // project files

            var coverOutputFiles = projects
                                   .Select(x => x.CoverToolOutputFile)
                                   .ToArray();

            if (!coverOutputFiles.Any())
            {
                return;
            }

            // run reportGenerator process

            ReportGeneratorUtil.RunReportGenerator(coverOutputFiles, darkMode, out var unifiedHtmlFile, out var unifiedXmlFile, true);

            // update CoverageLines

            CoberturaUtil.ProcessCoberturaXmlFile(unifiedXmlFile, out var coverageLines);
            CoverageLines = coverageLines;

            // update HtmlFilePath

            ReportGeneratorUtil.ProcessCoberturaHtmlFile(unifiedHtmlFile, darkMode, out var coverageHtml);
            HtmlFilePath = coverageHtml;
        }
Esempio n. 2
0
 private void SynchronizeBuildOutput()
 {
     FileSynchronizationUtil.Synchronize(ProjectOutputFolder, buildOutputPath, fccFolderName);
     TestDllFile = Path.Combine(buildOutputPath, Path.GetFileName(TestDllFile));
 }