Example #1
0
        private static void UploadCoverageBatch(Archive archive, Config config, LineCoverageMerger.CoverageBatch batch)
        {
            logger.Debug("Uploading merged line coverage from {traceFile} to {upload}",
                         string.Join(", ", batch.TraceFilePaths), batch.Upload.Describe());
            string report = LineCoverageSynthesizer.ConvertToLineCoverageReport(batch.LineCoverage);

            string traceFilePaths = string.Join(", ", batch.TraceFilePaths);

            if (config.ArchiveLineCoverage)
            {
                long timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                archive.ArchiveLineCoverage($"merged_{timestamp}.simple", report);
            }

            if (RunSync(batch.Upload.UploadLineCoverageAsync(traceFilePaths, report, batch.RevisionOrTimestamp)))
            {
                foreach (string tracePath in batch.TraceFilePaths)
                {
                    archive.ArchiveUploadedFile(tracePath);
                }
            }
            else
            {
                logger.Error("Failed to upload merged line coverage from {traceFile} to {upload}. Will retry later", traceFilePaths, batch.Upload.Describe());
            }
        }
Example #2
0
        private void ProcessLineCoverage(TraceFile trace, Archive archive, Config config, Config.ConfigForProcess processConfig, IUpload upload, LineCoverageMerger coverageMerger)
        {
            logger.Debug("Preparing line coverage from {traceFile} for {upload}", trace.FilePath, upload.Describe());
            RevisionFileUtils.RevisionOrTimestamp timestampOrRevision = ParseRevisionFile(trace, processConfig);
            Dictionary <string, FileCoverage>     lineCoverage        = ConvertTraceFileToLineCoverage(trace, archive, processConfig);

            if (timestampOrRevision == null || lineCoverage == null)
            {
                return;
            }

            if (config.ArchiveLineCoverage)
            {
                archive.ArchiveLineCoverage(Path.GetFileName(trace.FilePath) + ".simple",
                                            LineCoverageSynthesizer.ConvertToLineCoverageReport(lineCoverage));
            }

            if (processConfig.MergeLineCoverage)
            {
                logger.Debug("Merging line coverage from {traceFile} into previous line coverage", trace.FilePath);
                coverageMerger.AddLineCoverage(trace.FilePath, timestampOrRevision, upload, lineCoverage);
                return;
            }

            logger.Debug("Uploading line coverage from {traceFile} to {upload}", trace.FilePath, upload.Describe());
            string report = LineCoverageSynthesizer.ConvertToLineCoverageReport(lineCoverage);

            if (RunSync(upload.UploadLineCoverageAsync(trace.FilePath, report, timestampOrRevision)))
            {
                archive.ArchiveUploadedFile(trace.FilePath);
            }
            else
            {
                logger.Error("Failed to upload line coverage from {traceFile} to {upload}. Will retry later", trace.FilePath, upload.Describe());
            }
        }