Exemple #1
0
        private static emma.coverage[] CreateCoverage(bullseye.src src, emma.@class[] classes)
        {
            Coverage cov = new Coverage();
            foreach (var cls in classes)
            {
                var covs =
                    Utils.ParseCoverages((from item in cls.Items where item is emma.coverage select (emma.coverage) item).ToArray());
                cov.Add(covs.ClassCovered, covs.ClassTotal);
            }

            return Utils.CreateCoverage(cov.Covered.ToString(), cov.Total.ToString(), src.fn_cov, src.fn_total, src.cd_cov,
                                        src.cd_total, "0", "0");
        }
Exemple #2
0
        private emma.srcfile Convert(bullseye.src src)
        {
            var classes = new Dictionary<string, ClassBuilder>();

            ForEachFn(src, fn =>
                           	{
                           		string[] names = SplitClassFunctionName(fn.name);
                           		var className = names[0];

                           		if (!classes.ContainsKey(className))
                           			classes.Add(className, new ClassBuilder(className));

                           		classes[className].Add(names[1], fn);
                           	});

            emma.srcfile result = new emma.srcfile();
            result.name = src.name;
            result.@class = (from builder in classes.Values select builder.CreateClass()).ToArray();
            result.coverage = CreateCoverage(src, result.@class);

            return result;
        }
Exemple #3
0
        private void ForEachSrc(string path, bullseye.folder folder, Action<string, bullseye.folder, bullseye.src> callback)
        {
            if (folder.Items == null)
                return;

            if (path.Length > 0)
                path += "\\";
            path += folder.name;

            foreach (var item in folder.Items)
            {
                if (item is bullseye.folder)
                    ForEachSrc(path, (bullseye.folder) item, callback);
                else if (item is bullseye.src)
                    callback(path, folder, (bullseye.src) item);
            }
        }
Exemple #4
0
            public void Add(string methodName, bullseye.fn fn)
            {
                var method = new emma.method();
                method.name = methodName;
                method.coverage = Utils.CreateCoverage(fn.fn_cov, fn.fn_total, fn.cd_cov, fn.cd_total, "0", "0");
                methods.Add(method);

                this.fn.Add(fn.fn_cov, fn.fn_total);
                this.cd.Add(fn.cd_cov, fn.cd_total);
            }
Exemple #5
0
        private void ForEachSrc(bullseye.BullseyeCoverage dc, Action<string, bullseye.folder, bullseye.src> callback)
        {
            if (dc.folder == null)
                return;

            foreach (var folder in dc.folder)
                ForEachSrc("", folder, callback);
        }
Exemple #6
0
 private void ForEachFn(bullseye.fn fn, Action<bullseye.fn> callback)
 {
     callback(fn);
 }
Exemple #7
0
        private void ForEachFn(bullseye.src folder, Action<bullseye.fn> callback)
        {
            if (folder.fn == null)
                return;

            foreach (var fn in folder.fn)
                ForEachFn(fn, callback);
        }
Exemple #8
0
 private emma.coverage[] CreateCoverage(bullseye.folder folder)
 {
     return Utils.CreateCoverage("0", "0", folder.fn_cov, folder.fn_total, folder.cd_cov, folder.cd_total, "0", "0");
 }
Exemple #9
0
        private emma.report ConvertToEmma(bullseye.BullseyeCoverage dc)
        {
            var folders = new Dictionary<string, emma.package>();

            // Create packages

            ForEachSrc(dc, (path, folder, src) =>
                           	{
                           		if (!folders.ContainsKey(path))
                           		{
                           			var package = new emma.package();
                           			package.name = ConvertPathToPackageName(path);
                           			package.coverage = CreateCoverage(folder);
                           			package.srcfile = new emma.srcfile[0];

                           			folders.Add(path, package);
                           		}

                           		var files = new List<emma.srcfile>(folders[path].srcfile);
                           		files.Add(Convert(src));
                           		folders[path].srcfile = files.ToArray();
                           	});

            // Add classes to the package

            foreach (var package in folders.Values)
            {
                Coverage classesCov = new Coverage();
                foreach (var src in package.srcfile)
                {
                    var covs = Utils.ParseCoverages(src.coverage);
                    classesCov.Add(covs.ClassCovered, covs.ClassTotal);
                }

                var packageCovs = Utils.ParseCoverages(package.coverage);

                package.coverage = Utils.CreateCoverage(classesCov.Covered, classesCov.Total, packageCovs.MethodCovered,
                                                        packageCovs.MethodTotal, packageCovs.BlockCovered, packageCovs.BlockTotal,
                                                        packageCovs.LineCovered, packageCovs.LineTotal);
            }

            return Utils.CreateReport(folders.Values);
        }