private static void Localize(
            DirectoryInfo rootDir, FileInfo resultFile,
            FileInfo recordFile, string metricsFilePath, DirectoryInfo csvDir)
        {
            var covInfoFile  = FileUtil.GetCoverageInfo(rootDir);
            var testInfoFile = FileUtil.GetTestInfo(rootDir);
            var covInfo      = CoverageInfo.Read(covInfoFile);
            var testInfo     = TestInfo.Read(testInfoFile);

            testInfo.InitializeForStoringData(true);
            ReadJUnitResult(resultFile, testInfo);
            CoverageDataReader.ReadFile(testInfo, recordFile);

            var localizeStatements = LocalizeStatements(covInfo, testInfo, metricsFilePath).ToList();

            ShowLocalizeStatements(localizeStatements,
                                   new Dictionary <FileInfo, Dictionary <int, int> >(),
                                   metricsFilePath);

            if (csvDir != null)
            {
                LocalizeStatementsCsv(csvDir, localizeStatements,
                                      new Dictionary <FileInfo, Dictionary <int, int> >());
            }
        }
Example #2
0
        private static void InsertIntoSwitchCase(
            CoverageInfo info, XElement node, LanguageSupport support, string relativePath)
        {
            var analyzer         = support.AstAnalyzer;
            var startSwitchIndex = info.TargetGroups.Count;
            var switchNodes      = analyzer.FindSwitches(node);

            foreach (var switchNode in switchNodes.ToList())
            {
                var caseElements = new List <CoverageElement>();
                var caseNodes    = analyzer.FindCaseLabelTails(switchNode);
                foreach (var caseNode in caseNodes.ToList())
                {
                    // ステートメントに測定用コードを埋め込む
                    support.AstTransformer.InsertStatementAfter(
                        caseNode, info.Targets.Count, Done, ElementType.SwitchCase);
                    // カバレッジ情報を生成
                    var covElem = new CoverageElement(relativePath, caseNode, support.Tagger);
                    info.Targets.Add(covElem);
                    caseElements.Add(covElem);
                }
                // switchのカバレッジ情報を生成
                var element = new CoverageElement(relativePath, switchNode, support.Tagger);
                // 条件分岐と論理項のカバレッジ情報をまとめる
                var elementGroup = new CoverageElementGroup(element, caseElements);
                info.TargetGroups.Add(elementGroup);
            }
            info.SwitchRanges.Add(Tuple.Create(startSwitchIndex, info.TargetGroups.Count));
        }
Example #3
0
        private static void InsertIntoBnrachAndComparison(
            CoverageInfo info, XElement root, LanguageSupport support, string relativePath)
        {
            var analyzer                  = support.AstAnalyzer;
            var branchNodes               = analyzer.FindBranches(root);
            var startBranchIndex          = info.Targets.Count;
            var startBranchConditionIndex = info.TargetGroups.Count;

            foreach (var branchNode in branchNodes.ToList())
            {
                // 全ての論理項を列挙
                var condNodeList = analyzer.FindConditions(branchNode).ToList();
                // 論理項に測定用コードを埋め込み,カバレッジ情報を生成
                var condElements = InsertIntoConditionCoverage(info, condNodeList, support,
                                                               relativePath);

                // 条件分岐のカバレッジ情報を生成
                var element = new CoverageElement(relativePath, branchNode, support.Tagger);
                // 条件分岐と論理項のカバレッジ情報をまとめる
                var elementGroup = new CoverageElementGroup(element, condElements);
                info.TargetGroups.Add(elementGroup);

                // 論理項を含む条件式か否かを判断
                support.AstTransformer.InsertPredicate(
                    branchNode, info.Targets.Count,
                    elementGroup.Targets.Count > 0
                                ? ElementType.Decision
                                : ElementType.DecisionAndCondition);
                info.Targets.Add(element);
            }
            info.BranchConditionRanges.Add(Tuple.Create(startBranchConditionIndex,
                                                        info.TargetGroups.Count));
            info.BranchRanges.Add(Tuple.Create(startBranchIndex, info.Targets.Count));
        }
Example #4
0
            private CoverageInfo GetNextCoverageInfo()
            {
                if (this.isCanceled)
                {
                    return(null);
                }

                CoverageInfo coverageInfo = null;

                // Make sure one file provied to only one thread and all files are processed.
                var currentFilePos = this.GetAndIncrement(ref this.numOfCoverageFilesLoaded, this.coverageFiles.Length);


                if (currentFilePos < this.coverageFiles.Length)
                {
                    // Get coverage info from file.
                    coverageInfo = CoverageInfo.CreateFromFile(coverageFiles[currentFilePos]);
                    Console.WriteLine("Loading CovInfo from file:" + coverageFiles[currentFilePos]);
                }
                else
                {
                    // Get coverage info from cache.
                    coverageInfosCache.TryDequeue(out coverageInfo);
                    if (coverageInfo != null)
                    {
                        Console.WriteLine("Getting covInfo from cache:");
                    }
                }

                return(coverageInfo);
            }
Example #5
0
        public static string OnDiskMerge(string covFilesdir, string[] covFiles)
        {
            var resultedFile = Path.Combine(Path.GetDirectoryName(covFilesdir), "OnDisk-" + covFiles.Length + "-" + Guid.NewGuid().ToString().Substring(0, 5) + ".coverage");

            if (covFiles.Length < 2)
            {
                Console.WriteLine("To merge give atleast two cov files");
                return("");
            }
            string first = covFiles[0], second = covFiles[1];

            for (int i = 1; i < covFiles.Length; i++)
            {
                var tmpFile = Path.Combine(Path.GetDirectoryName(resultedFile), Path.GetFileNameWithoutExtension(resultedFile) + "-" + i + Path.GetExtension(resultedFile));
                if (i == covFiles.Length - 1)
                {
                    tmpFile = resultedFile;
                }
                Console.WriteLine("Creating merge file: " + tmpFile);
                CoverageInfo.MergeCoverageFiles(first, second, tmpFile, true);
                first = tmpFile;
                if (i != covFiles.Length - 1)
                {
                    second = covFiles[i + 1];
                }
            }
            CoverageSummary.PrintCoverageInfo(resultedFile);
            return(resultedFile);
        }
Example #6
0
            private void MergeTask()
            {
                try
                {
                    if (this.isCanceled)
                    {
                        return;
                    }

                    var first = GetNextCoverageInfo();
                    if (first == null)
                    {
                        return;
                    }
                    var second = GetNextCoverageInfo();
                    while (second != null && !this.isCanceled)
                    {
                        var third = CoverageInfo.Join(first, second);
                        first.Dispose();
                        second.Dispose();
                        first  = third;
                        second = GetNextCoverageInfo();
                    }
                    coverageInfosCache.Enqueue(first);
                    Debug.Assert(coverageInfosCache.Count <= parallelLevel,
                                 "Cache size can't be more than parallel level");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("MergeTask: failure in CovergaInfo join:" + ex);
                    this.isCanceled = true;
                }
            }
Example #7
0
        public static CoverageInfo InMemoryParallel(string[] covFiles)
        {
            InMemoryCoverageFilesMerger merger = new InMemoryCoverageFilesMerger(covFiles);
            CoverageInfo coverageInfo          = merger.MergeAllFiles();

            return(coverageInfo);
        }
Example #8
0
        public static string InMemoryMerge(string covFilesdir, string[] covFiles, bool parallel)
        {
            CoverageInfo _covinfo = null;

            if (!parallel)
            {
                _covinfo = CoverageInfo.CreateFromFile(covFiles[0], null, null);
                int batchmergefiles = covFiles.Length - 1;
                for (int i = 0; i < batchmergefiles; i++)
                {
                    Console.WriteLine("Merging file " + covFiles[i + 1]);
                    CoverageInfo covinfo2 = CoverageInfo.CreateFromFile(covFiles[i + 1], null, null);
                    CoverageInfo cs3      = CoverageInfo.Join(_covinfo, covinfo2);
                    _covinfo.Dispose();
                    covinfo2.Dispose();
                    _covinfo = cs3;
                }
            }
            else
            {
                _covinfo = InMemoryParallel(covFiles);
            }
            CoverageSummary.PrintCoverageInfo(_covinfo);
            var resultedFile = Path.Combine(Path.GetDirectoryName(covFilesdir), "InMem-" + covFiles.Length + "-" + Guid.NewGuid().ToString().Substring(0, 5) + "-is-paralel-" + parallel);

            return(resultedFile);
        }
Example #9
0
        public static string GetCoveragedCode(
            FileInfo codeFile, CoverageInfo info, LanguageSupport support)
        {
            string relativePath;

            return(GetCoveragedCode(codeFile, info, support, out relativePath));
        }
Example #10
0
        public void CoverageInfoMergeTest()
        {
            var coverageInfoType = new coverageInfo
            {
                level         = "first",
                live_coverage = true,
                coverage      = new[]
                {
                    new coverage {
                        includes = "coverage includes 1"
                    },
                    new coverage {
                        includes = "coverage includes 2"
                    },
                    new coverage {
                        includes = "coverage includes 3"
                    }
                },
                covered_from = "tv"
            };
            var coverageInfoDTO = new CoverageInfoDTO(coverageInfoType);
            var coverageInfo    = new CoverageInfo(coverageInfoDTO.Level, coverageInfoDTO.IsLive, coverageInfoDTO.Includes, coverageInfoDTO.CoveredFrom);

            Assert.IsNotNull(coverageInfo);
            Assert.AreEqual(coverageInfoType.level, coverageInfo.Level);
            Assert.AreEqual(coverageInfoType.live_coverage, coverageInfo.IsLive);
            Assert.AreEqual(CoveredFrom.Tv, coverageInfo.CoveredFrom);
            Assert.AreEqual(coverageInfoType.coverage.Length, coverageInfo.Includes.Count());
            Assert.AreNotEqual(coverageInfo.Includes.ToList()[0], coverageInfo.Includes.ToList()[2]);
        }
Example #11
0
        public CoverageDsParser(string dotCoveragePath)
        {
            _coverageFile = dotCoveragePath;
            CoverageInfo ci = CoverageInfo.CreateFromFile(_coverageFile);

            _summary = ci.BuildDataSet(null);
        }
Example #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ControlledRuntime"/> class.
        /// </summary>
        internal ControlledRuntime(Configuration configuration, ISchedulingStrategy strategy,
                                   IRandomValueGenerator valueGenerator)
            : base(configuration, valueGenerator)
        {
            IsExecutionControlled = true;

            this.RootTaskId         = Task.CurrentId;
            this.NameValueToActorId = new ConcurrentDictionary <string, ActorId>();

            this.CoverageInfo = new CoverageInfo();

            var scheduleTrace = new ScheduleTrace();

            if (configuration.IsLivenessCheckingEnabled)
            {
                strategy = new TemperatureCheckingStrategy(configuration, this.Monitors, strategy);
            }

            this.Scheduler      = new OperationScheduler(this, strategy, scheduleTrace, this.Configuration);
            this.TaskController = new TaskController(this, this.Scheduler);

            // Update the current asynchronous control flow with this runtime instance,
            // allowing future retrieval in the same asynchronous call stack.
            AssignAsyncControlFlowRuntime(this);
        }
Example #13
0
        static void Main(string[] args)
        {
            string wspath = Environment.CurrentDirectory.ToString();

            Regex        isString = new Regex("(['\"]?)[a-zA-Z]*\\1$");
            CoverageInfo coverage = CoverageInfo.CreateFromFile(args[0]);

            CoverageDS data = coverage.BuildDataSet(null);


            string xml = data.GetXml();


            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xml);


            XslTransform  myXslTransform = new XslTransform();
            XmlTextWriter writer         = new XmlTextWriter(wspath + @"coverage.htm", null);

            myXslTransform.Load(wspath + @"\style.xslt");
            myXslTransform.Transform(xmlDocument, null, writer);

            writer.Flush();
            writer.Close();
        }
Example #14
0
        private static void OnDiskWork(ConcurrentQueue <string> covFilesQueue, string covFilesdir, int numOfCovFiles)
        {
            var threadId     = "ThreadId " + Thread.CurrentThread.ManagedThreadId + " ";
            var resultedFile = Path.Combine(Path.GetDirectoryName(covFilesdir), "OnDisk-" + numOfCovFiles + "-" + Guid.NewGuid().ToString().Substring(0, 5) + ".coverage");

            if (numOfCovFiles < 2)
            {
                Console.WriteLine(threadId + "To merge give atleast two cov files");
            }

            string first = null, second = null;

            covFilesQueue.TryDequeue(out first);
            covFilesQueue.TryDequeue(out second);
            while (first != null && second != null)
            {
                var tmpFile = Path.Combine(Path.GetDirectoryName(resultedFile), Path.GetFileNameWithoutExtension(resultedFile) + "-" + Guid.NewGuid().ToString().Substring(0, 5) + Path.GetExtension(resultedFile));
                Console.WriteLine(threadId + "Creating merge file: " + tmpFile);
                CoverageInfo.MergeCoverageFiles(first, second, tmpFile, true);
                first = tmpFile;
                covFilesQueue.TryDequeue(out second);
            }
            if (first != null)
            {
                covFilesQueue.Enqueue(first);
            }
            if (second != null)
            {
                covFilesQueue.Enqueue(second);
            }
        }
        private static bool Analyze(DirectoryInfo rootDir, FileInfo covDataFile)
        {
            var formatter    = new BinaryFormatter();
            var covInfoFile  = FileUtil.GetCoverageInfo(rootDir);
            var testInfoFile = FileUtil.GetTestInfo(rootDir);
            var covInfo      = CoverageInfo.Read(covInfoFile, formatter);
            var testInfo     = TestInfo.Read(testInfoFile, formatter);

            testInfo.InitializeForStoringData(true);
            CoverageDataReader.ReadFile(testInfo, covDataFile);

            foreach (var testCase in testInfo.TestCases)
            {
                Console.WriteLine(
                    "**** " + testCase.RelativePath + ": " + testCase.Name + " ****");
                var stmts = testCase.Paths.Select(i => covInfo.Targets[i]);
                foreach (var stmt in stmts)
                {
                    Console.WriteLine(stmt.RelativePath + ": " + stmt.Position.SmartLineString);
                }
                Console.WriteLine();
                Console.WriteLine();
            }

            return(true);
        }
        public void Start(int port, CoverageInfo info)
        {
            var address = IPAddress.Parse("127.0.0.1");
            var server  = new TcpListener(address, port);

            server.Start();

            while (true)
            {
                var    client = server.AcceptTcpClient();
                Action action = () => {
                    using (var stream = client.GetStream()) {
                        while (true)
                        {
                            var index = (stream.ReadByte() << 24) + (stream.ReadByte() << 16) +
                                        (stream.ReadByte() << 8) + (stream.ReadByte() << 0);
                            var value = stream.ReadByte();
                            if (value == -1)
                            {
                                break;
                            }
                            info.Targets[index].UpdateState((CoverageState)value);
                        }
                    }
                };
                action.BeginInvoke(action.EndInvoke, null);
            }
        }
Example #17
0
        /// <summary>
        /// Executes the task.
        /// </summary>
        /// <returns>
        /// true if the task successfully executed; otherwise, false.
        /// </returns>
        public override bool Execute()
        {
            List <ITaskItem> results = new List <ITaskItem>();

            foreach (ITaskItem file in CoverageFiles)
            {
                try
                {
                    string sourceFile = file.ItemSpec;

                    if (File.Exists(sourceFile))
                    {
                        Log.LogMessageFromResources(MessageImportance.Normal, "ConvertingVSCoverageFile", sourceFile);

                        string symbolsDir = Path.GetDirectoryName(sourceFile);

                        if (SymbolsDirectory != null)
                        {
                            symbolsDir = SymbolsDirectory.ItemSpec;
                        }


                        using (CoverageInfo info = CoverageInfo.CreateFromFile(
                                   sourceFile, executablePaths: new [] { symbolsDir }, symbolPaths: new [] { symbolsDir }))
                        {
                            CoverageDS dataSet    = info.BuildDataSet(null);
                            string     outputFile = Path.ChangeExtension(sourceFile, "xml");

                            // Unless an output dir is specified
                            // the converted files will be stored in the same dir
                            // as the source files, with the .XML extension
                            if (OutputDirectory != null)
                            {
                                outputFile = Path.Combine(OutputDirectory.ItemSpec, Path.GetFileName(outputFile));
                            }

                            dataSet.WriteXml(outputFile);

                            Log.LogMessageFromResources(MessageImportance.Normal, "WrittenXmlCoverageFile", outputFile);
                        }

                        ITaskItem item = new TaskItem(file);
                        results.Add(item);
                    }
                    else
                    {
                        Log.LogMessageFromResources(MessageImportance.Normal, "SkippingNonExistentFile", sourceFile);
                    }
                }
                catch (Exception e)
                {
                    Log.LogErrorFromException(e, true);
                }
            }

            ConvertedFiles = results.ToArray();

            return(!Log.HasLoggedErrors);
        }
Example #18
0
 private static void TransformCoverageFileToXml(String inputCoverageFileName, String outputXmlFileName)
 {
     using (CoverageInfo info = CoverageInfo.CreateFromFile(inputCoverageFileName))
     {
         var coverageDataset = info.BuildDataSet();
         coverageDataset.ExportXml(outputXmlFileName);
     }
 }
Example #19
0
        public static string WriteCoveragedCode(
            LanguageSupport support, CoverageInfo info, FileInfo codeFile, DirectoryInfo outDir)
        {
            string relativePath;
            var    code = GetCoveragedCode(codeFile, info, support, out relativePath);

            return(WriteCode(relativePath, outDir, code));
        }
Example #20
0
 private void ReadInputFiles(string referenceFolder)
 {
     CoverageInfo = CanvasSegment.ReadBedInput(InputBinPath, ForbiddenIntervalBedPath);
     if (InputVafPath != null)
     {
         LoadVAFInput(referenceFolder);
     }
 }
Example #21
0
        public ProjectElement Parse(String[] inputfiles)
        {
            ProjectElement project = new ProjectElement();

            // Open file
            using (CoverageInfo info = JoinCoverageFiles(inputfiles))
            {
                CoverageDS dataSet = info.BuildDataSet();

                Dictionary <String, PackageElement> packages = new Dictionary <String, PackageElement>();
                Dictionary <uint, string>           files    = new Dictionary <uint, string>();

                // Namespaces
                DataTable namespacesTable = dataSet.Tables["NameSpaceTable"];
                DataTable classesTable    = dataSet.Tables["Class"];
                DataTable filesTable      = dataSet.Tables["SourceFileNames"];

                CreateIndexPackages(project, namespacesTable, packages);
                CreateIndexFiles(filesTable, files);

                foreach (DataRow iclass in classesTable.Rows)
                {
                    string       className = System.Security.SecurityElement.Escape((string)iclass["ClassName"]);
                    ClassElement ce        = new ClassElement(className);

                    DataRow[] methodRows = iclass.GetChildRows("Class_Method");

                    foreach (DataRow imethod in methodRows)
                    {
                        // Get First Line in class
                        DataRow[] lineRows    = imethod.GetChildRows("Method_Lines");
                        bool      includeFile = lineRows.Length < 1 ? false : files.ContainsKey(lineRows[0].Field <uint>("SourceFileID"));

                        if (includeFile)
                        {
                            string        methodName = (string)imethod["MethodName"]; // System.Security.SecurityElement.Escape((string)imethod["MethodName"]);
                            MethodElement me         = new MethodElement(methodName);

                            uint coveredBlocks = (uint)imethod["BlocksCovered"];
                            uint totalBlocks   = coveredBlocks + (uint)imethod["BlocksNotCovered"];
                            uint coveredLines  = (uint)imethod["LinesCovered"];
                            uint totalLines    = coveredLines + (uint)imethod["LinesNotCovered"] + (uint)imethod["LinesPartiallyCovered"];
                            me.Metrics = new MethodMetrics(totalBlocks, coveredBlocks, totalLines, coveredLines);

                            ce.AddMethod(me);
                        }
                    }

                    if (packages.ContainsKey((string)iclass["NamespaceKeyName"]))
                    {
                        PackageElement pe = packages[(string)iclass["NamespaceKeyName"]];
                        pe.AddClass(ce);
                    }
                }
            }

            return(project);
        }
Example #22
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                // comment once testing is done
                //args = new string[3] { @"\\hqomsws04t1a.dstest.drugstore.com\webroot\DsPayPalService\Release_DsPayPalService_16.02.24.01\bin\PP_CC.coverage", "PayPal", @"C:\QAAutomation\CoverageFiles\PayPal" };
                //args = new string[3] { @"\\hqomsws04t1a.dstest.drugstore.com\webroot\ContentCatalogService\Dev2_ContentCatalogService_16.04.19.00\bin\CC.coverage", "ConentCatalog", @"C:\QAAutomation\CoverageFiles\ContentCatalog" };
                //args = new string[3] { @"\\hqomsws04t1a.dstest.drugstore.com\webroot\ContentCatalogService\Dev2_ContentCatalogService_16.03.16.03\bin\CCProductBlurb.coverage", "ConentCatalogProductBlurb", @"C:\QAAutomation\CoverageFiles\ContentCatalog" };

                //Uncomment once testing is done
                Console.WriteLine("Invalid Arguments......");
                Console.WriteLine("Argumenst should be Coverage File Path (same as instrumented bin path), Application Name, Xml File Location");
                return;
            }

            bool   isXmlGenerated = false;
            string inputfile      = args[0];

            CoveragePath = Path.GetDirectoryName(inputfile);
            coverageFile = Path.GetFileNameWithoutExtension(inputfile);

            strAppList = args[1];

            if (File.Exists(inputfile))
            {
                Console.WriteLine("Coverage File Exist");
                Console.WriteLine("Params:{0},{1}", inputfile, strAppList);
                try
                {
                    binPaths = new List <string>();
                    binPaths.Add(CoveragePath);
                    CoverageInfo ci   = CoverageInfo.CreateFromFile(inputfile, binPaths, binPaths);
                    CoverageDS   data = ci.BuildDataSet(null);
                    masterXmlPath = GetMasterXmlFilePath(args[2]);
                    data.WriteXml(masterXmlPath);
                }
                catch (ImageNotFoundException infEx)
                {
                    Console.WriteLine("Image not found exception is caught.." + infEx.StackTrace);
                    //throw;
                }

                if (File.Exists(masterXmlPath))
                {
                    isXmlGenerated = true;
                }
            }
            else
            {
                Console.WriteLine("Coverage File does not Exist");
            }

            if (isXmlGenerated)
            {
                Console.WriteLine("Successfully coverted to Xml File :" + isXmlGenerated);
            }
            Console.ReadLine();
        }
Example #23
0
 private void ValidateCoverageData(string coverageFile)
 {
     using (var converageInfo = CoverageInfo.CreateFromFile(coverageFile))
     {
         CoverageDS coverageDs = converageInfo.BuildDataSet();
         AssertModuleCoverageCollected(coverageDs);
         AssertSourceFileName(coverageDs);
     }
 }
Example #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeCoverage"/> class. 
 /// </summary>
 /// <param name="pathToCoverageFile">
 /// The path to the coverage file (the file is typically called <c>data.coverage</c>). This value should be the full path to that file.
 /// </param>
 /// <remarks>
 /// </remarks>
 public CodeCoverage(string pathToCoverageFile)
 {
     string directory = Path.GetDirectoryName(pathToCoverageFile);
     string artifactDirectory = Path.Combine(directory, ArtifactDirectoryRelativePath);
     CoverageInfoManager.ExePath = artifactDirectory;
     CoverageInfoManager.SymPath = artifactDirectory;
     this.coverageInfo = CoverageInfoManager.CreateInfoFromFile(pathToCoverageFile);
     this.coverageXml = this.GetCoverageXml();
 }
        private static CoverageInfo JoinCoverageFiles(IEnumerable <string> files)
        {
            if (files == null)
            {
                throw new ArgumentNullException("files");
            }

            // This will represent the joined coverage files
            CoverageInfo returnItem = null;
            string       path;

            try
            {
                foreach (string sourceFile in files)
                {
                    // Create from the current file

                    path = System.IO.Path.GetDirectoryName(sourceFile);
                    CoverageInfo current = CoverageInfo.CreateFromFile(sourceFile, new string[] { path }, new string[] { path });

                    if (returnItem == null)
                    {
                        // First time through, assign to result
                        returnItem = current;
                        continue;
                    }

                    // Not the first time through, join the result with the current
                    CoverageInfo joined = null;
                    try
                    {
                        joined = CoverageInfo.Join(returnItem, current);
                    }
                    finally
                    {
                        // Dispose current and result
                        current.Dispose();
                        current = null;
                        returnItem.Dispose();
                        returnItem = null;
                    }

                    returnItem = joined;
                }
            }
            catch (Exception)
            {
                if (returnItem != null)
                {
                    returnItem.Dispose();
                }
                throw;
            }

            return(returnItem);
        }
Example #26
0
            public void ConvertToXml(string outputFile)
            {
                var          master = CoverageFiles.First();
                var          others = CoverageFiles.Skip(1);
                CoverageInfo ci     = CoverageInfo.CreateFromFile(master, BinaryPaths, BinaryPaths);

                CoverageDS data = ci.BuildDataSet(null);

                data.WriteXml(outputFile);
            }
        public static string InsertInstrumentationCode(LanguageSupport mode, string fileName)
        {
            var info = new CoverageInfo(
                Fixture.GetCoverageInputPath(), mode.Name, SharingMethod.SharedMemory);
            var inPath = Path.Combine(Fixture.GetCoverageInputPath(), fileName);
            var code   = OccfCodeGenerator.GetCoveragedCode(new FileInfo(inPath), info, mode);

            File.WriteAllText(Fixture.GetOutputPath(fileName), code);
            return(code);
        }
        private static void WriteInfoFiles(DirectoryInfo rootDir, CoverageInfo covInfo, TestInfo testInfo)
        {
            var formatter = new BinaryFormatter();

            covInfo.Write(rootDir, formatter);
            if (testInfo == null)
            {
                return;
            }
            testInfo.Write(rootDir, formatter);
        }
Example #29
0
        /// <summary>
        /// Parses the arguments.
        /// </summary>
        private static bool TryParseArgs(string[] args, out List <CoverageInfo> inputFiles)
        {
            inputFiles       = new List <CoverageInfo>();
            OutputFilePrefix = "merged";

            if (args.Length == 0)
            {
                Console.WriteLine("Usage: CoyoteMergeCoverageReports.exe file1.sci file2.sci ... [/output:prefix]");
                return(false);
            }

            foreach (var arg in args)
            {
                if (arg.StartsWith("/output:"))
                {
                    OutputFilePrefix = arg.Substring("/output:".Length);
                    continue;
                }
                else if (arg.StartsWith("/"))
                {
                    Console.WriteLine("Error: Unknown flag {0}", arg);
                    return(false);
                }
                else
                {
                    // Check the suffix.
                    if (!arg.EndsWith(".sci"))
                    {
                        Console.WriteLine("Error: Only sci files accepted as input, got {0}", arg);
                        return(false);
                    }

                    // Check if the file exists?
                    if (!File.Exists(arg))
                    {
                        Console.WriteLine("Error: File {0} not found", arg);
                        return(false);
                    }

                    try
                    {
                        CoverageInfo info = CoverageInfo.Load(arg);
                        inputFiles.Add(info);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error: got exception while trying to read input objects: {0}", e.Message);
                        return(false);
                    }
                }
            }

            return(true);
        }
Example #30
0
 static void Main(string[] args)
 {
     using (CoverageInfo info = CoverageInfo.CreateFromFile(
                "PATH_OF_YOUR_*.coverage_FILE",
                new string[] { @"DIRECTORY_OF_YOUR_DLL_OR_EXE" },
                new string[] { }))
     {
         CoverageDS data = info.BuildDataSet();
         data.WriteXml("converted.coveragexml");
     }
 }
Example #31
0
        public void CoverageInfoDTOMappingTest()
        {
            var coverageInfoFeed = RMF.GetCoverageInfo(10);
            var coverageInfo     = new CoverageInfo(new CoverageInfoCI(new CoverageInfoDTO(coverageInfoFeed)));

            Assert.IsNotNull(coverageInfo);
            Assert.AreEqual(coverageInfoFeed.level, coverageInfo.Level);
            Assert.AreEqual(coverageInfoFeed.live_coverage, coverageInfo.IsLive);
            Assert.AreEqual(CoveredFrom.Tv, coverageInfo.CoveredFrom);
            Assert.AreEqual(coverageInfoFeed.coverage.Length, coverageInfo.Includes.Count());
            Assert.AreNotEqual(coverageInfo.Includes.ToList()[0], coverageInfo.Includes.ToList()[2]);
        }