예제 #1
0
        public static int Main(String[] args)
        {
            MonoCovOptions options = new MonoCovOptions();

            options.ProcessArgs(args);
            args = options.RemainingArguments;


            if (options.exportXmlDir != null)
            {
                return(handleExportXml(options, args));
            }

            if (options.exportHtmlDir != null)
            {
                return(handleExportHtml(options, args));
            }

            if (options.exportFieldStatDir != null)
            {
                return(handleExportFieldStat(options, args));
            }
                #if GUI_qt
            return(MonoCov.Gui.Qt.MonoCov.GuiMain(args));
                #else
            return(MonoCov.Gui.Gtk.MonoCovGui.GuiMain(args));
                #endif
            //return 0;
        }
예제 #2
0
        public static int Main(string[] args)
        {
            MonoCovOptions options = new MonoCovOptions();

            options.ProcessArgs(args);
            args = options.RemainingArguments;

            if (options.showHelp)
            {
                options.WriteHelp(Console.Out);
                return(0);
            }

            if (options.exportXmlDir != null)
            {
                return(handleExportXml(options, args));
            }

            if (options.exportHtmlDir != null)
            {
                return(handleExportHtml(options, args));
            }

            if (options.minClassCoverage > 0 || options.minMethodeCoverage > 0)
            {
                return(handleTestCoverage(options, args));
            }

                #if GUI_qt
            return(MonoCov.Gui.Qt.MonoCov.GuiMain(args));
                #else
            return(MonoCov.Gui.Gtk.MonoCovGui.GuiMain(args));
                #endif
        }
예제 #3
0
        private static int handleExportFieldStat(MonoCovOptions opts, string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Error: Datafile name is required when using --export-fieldstat");
                return(1);
            }

            if (!Directory.Exists(opts.exportFieldStatDir))
            {
                try {
                    Directory.CreateDirectory(opts.exportFieldStatDir);
                }
                catch (Exception ex) {
                    Console.WriteLine("Error: Destination directory '" + opts.exportFieldStatDir + "' does not exist and could not be created: " + ex);
                    return(1);
                }
            }

            CoverageModel model = new CoverageModel();

            model.ReadFromFile(args [0]);
            FieldStatExporter exporter = new FieldStatExporter();

            exporter.DestinationDir = opts.exportFieldStatDir;
            exporter.StyleSheet     = opts.styleSheet;
            exporter.Export(model);
            if (!opts.quiet)
            {
                Console.WriteLine();
                Console.WriteLine("Done.");
            }
            return(0);
        }
예제 #4
0
        public static int Main(string[] args)
        {
            MonoCovOptions options = new MonoCovOptions ();
            options.ProcessArgs (args);
            args = options.RemainingArguments;

            if (options.showHelp) {
            options.WriteHelp(Console.Out);
            return 0;
            }

            if (options.exportXmlDir != null)
            return handleExportXml (options, args);

            if (options.exportHtmlDir != null)
            return handleExportHtml (options, args);

            if (options.exportLcovDir != null)
            return handleExportLcov (options, args);

            if (options.minClassCoverage > 0 || options.minMethodeCoverage > 0)
            return handleTestCoverage (options, args);

            #if GUI_qt
            return MonoCov.Gui.Qt.MonoCov.GuiMain (args);
            #else
            return MonoCov.Gui.Gtk.MonoCovGui.GuiMain (args);
            #endif
        }
예제 #5
0
        private static int handleTestCoverage(MonoCovOptions opts, string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Error: Datafile name is required when using --minClassCoverage or --minMethodeCoverage.");
                return(1);
            }

            CoverageModel model = new CoverageModel();

            try {
                model.ReadFromFile(args[0]);
            } catch (Exception e) {
                Console.WriteLine("Error: " + e.Message);
                return(1);
            }

            foreach (ClassCoverageItem classItem in model.Classes.Values)
            {
                if (!opts.quiet)
                {
                    Console.WriteLine(String.Format("Coverage of class \"{0}\": {1:0.}%", classItem.FullName, classItem.coveragePercent * 100));
                }

                if (opts.minClassCoverage > 0 && classItem.coveragePercent < opts.minClassCoverage)
                {
                    if (!opts.quiet)
                    {
                        Console.WriteLine("Test failed.");
                    }

                    return(1);
                }

                foreach (MethodCoverageItem methodItem in classItem.Methods)
                {
                    if (!opts.quiet)
                    {
                        Console.WriteLine(String.Format("\tCoverage of method \"{0}\": {1:0.}%", methodItem.Name, methodItem.coveragePercent * 100));
                    }

                    if (opts.minMethodeCoverage > 0 && methodItem.coveragePercent < opts.minMethodeCoverage)
                    {
                        if (!opts.quiet)
                        {
                            Console.WriteLine("Test failed.");
                        }

                        return(1);
                    }
                }
            }

            return(0);
        }
예제 #6
0
        private static int handleExportXml(MonoCovOptions opts, string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Error: Datafile name is required when using --export-xml");
                return(1);
            }

            if (!File.Exists(args [0]))
            {
                Console.WriteLine(string.Format("Error: Datafile '{0}' not found.", args [0]));
                return(1);
            }

            if (!Directory.Exists(opts.exportXmlDir))
            {
                try {
                    Directory.CreateDirectory(opts.exportXmlDir);
                }
                catch (Exception ex) {
                    Console.WriteLine("Error: Destination directory '" + opts.exportXmlDir + "' does not exist and could not be created: " + ex);
                    return(1);
                }
            }

            try {
                CoverageModel model = new CoverageModel();
                model.ReadFromFile(args [0]);
                XmlExporter exporter = new XmlExporter();
                exporter.DestinationDir = opts.exportXmlDir;
                exporter.StyleSheet     = opts.styleSheet;
                if (!opts.quiet)
                {
                    exporter.Progress += new XmlExporter.ProgressEventHandler(progressListener);
                }
                exporter.Export(model);
            }
            catch (Exception e) {
                Console.WriteLine("Error: " + e.Message);
                return(1);
            }

            if (!opts.quiet)
            {
                Console.WriteLine();
                Console.WriteLine("Done.");
            }
            return(0);
        }
예제 #7
0
        private static int handleExportLcov(MonoCovOptions opts, string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Error: Datafile name is required when using --export-lcov");
                return(1);
            }

            if (!File.Exists(args [0]))
            {
                Console.WriteLine(string.Format("Error: Datafile '{0}' not found.", args [0]));
                return(1);
            }

            string exportDir = opts.exportLcovDir;

            if (!Directory.Exists(exportDir))
            {
                try {
                    Directory.CreateDirectory(exportDir);
                }
                catch (Exception ex) {
                    Console.WriteLine("Error: Destination directory '" + exportDir + "' does not exist and could not be created: " + ex);
                    return(1);
                }
            }

            try {
                CoverageModel model = new CoverageModel();
                model.ReadFromFile(args [0]);
                // TODO support progress in lcov export
                LcovExporter.Export(model, Path.Combine(exportDir, "lcov.info"));
            }
            catch (Exception e) {
                Console.WriteLine("Error: " + e.Message);
                return(1);
            }

            if (!opts.quiet)
            {
                Console.WriteLine();
                Console.WriteLine("Done.");
            }
            return(0);
        }
예제 #8
0
        private static int handleExportHtml(MonoCovOptions opts, string[] args)
        {
            if (args.Length == 0) {
            Console.WriteLine ("Error: Datafile name is required when using --export-html");
            return 1;
            }

            if (!File.Exists(args [0])) {
            Console.WriteLine(string.Format("Error: Datafile '{0}' not found.", args [0]));
            return 1;
            }

            if (!Directory.Exists (opts.exportHtmlDir)) {
            try {
                Directory.CreateDirectory (opts.exportHtmlDir);
            }
            catch (Exception ex) {
                Console.WriteLine ("Error: Destination directory '" + opts.exportHtmlDir + "' does not exist and could not be created: " + ex);
                return 1;
            }
            }

            try {
            CoverageModel model = new CoverageModel ();
            model.ReadFromFile (args [0]);
            HtmlExporter exporter = new HtmlExporter ();
            exporter.DestinationDir = opts.exportHtmlDir;
            exporter.StyleSheet = opts.styleSheet;
            if (!opts.quiet)
                exporter.Progress += new HtmlExporter.ProgressEventHandler (htmlProgressListener);
            exporter.Export (model);
            }
            catch (Exception e) {
            Console.WriteLine("Error: "+e.Message);
            return 1;
            }

            if (!opts.quiet) {
            Console.WriteLine ();
            Console.WriteLine ("Done.");
            }
            return 0;
        }
예제 #9
0
	public static int Main (String[] args) {
		MonoCovOptions options = new MonoCovOptions ();
		options.ProcessArgs (args);
		args = options.RemainingArguments;


		if (options.exportXmlDir != null)
			return handleExportXml (options, args);

		if (options.exportHtmlDir != null)
			return handleExportHtml (options, args);

		if (options.exportFieldStatDir != null )
			return handleExportFieldStat(options, args);
		#if GUI_qt
		return MonoCov.Gui.Qt.MonoCov.GuiMain (args);
		#else
		return MonoCov.Gui.Gtk.MonoCovGui.GuiMain (args);
		#endif
		//return 0;
	}
예제 #10
0
        private static int handleTestCoverage(MonoCovOptions opts, string[] args)
        {
            if (args.Length == 0) {
            Console.WriteLine ("Error: Datafile name is required when using --minClassCoverage or --minMethodeCoverage.");
            return 1;
            }

            CoverageModel model = new CoverageModel ();

            try {
            model.ReadFromFile (args[0]);
            } catch (Exception e) {
            Console.WriteLine ("Error: " + e.Message);
            return 1;
            }

            foreach (ClassCoverageItem classItem in model.Classes.Values) {
            if (!opts.quiet)
                Console.WriteLine (String.Format ("Coverage of class \"{0}\": {1:0.}%", classItem.FullName, classItem.coveragePercent * 100));

            if (opts.minClassCoverage > 0 && classItem.coveragePercent < opts.minClassCoverage) {
                if (!opts.quiet)
                    Console.WriteLine ("Test failed.");

                return 1;
            }

            foreach (MethodCoverageItem methodItem in classItem.Methods) {
                if (!opts.quiet)
                    Console.WriteLine (String.Format ("\tCoverage of method \"{0}\": {1:0.}%", methodItem.Name, methodItem.coveragePercent * 100));

                if (opts.minMethodeCoverage > 0 && methodItem.coveragePercent < opts.minMethodeCoverage) {
                    if (!opts.quiet)
                        Console.WriteLine ("Test failed.");

                    return 1;
                }
            }
            }

            return 0;
        }
예제 #11
0
        private static int handleExportLcov(MonoCovOptions opts, string[] args)
        {
            if (args.Length == 0) {
            Console.WriteLine ("Error: Datafile name is required when using --export-lcov");
            return 1;
            }

            if (!File.Exists(args [0]))
            {
            Console.WriteLine(string.Format("Error: Datafile '{0}' not found.", args [0]));
            return 1;
            }

            string exportDir = opts.exportLcovDir;

            if (!Directory.Exists (exportDir)) {
            try {
                Directory.CreateDirectory (exportDir);
            }
            catch (Exception ex) {
                Console.WriteLine ("Error: Destination directory '" + exportDir + "' does not exist and could not be created: " + ex);
                return 1;
            }
            }

            try {
            CoverageModel model = new CoverageModel ();
            model.ReadFromFile (args [0]);
            // TODO support progress in lcov export
            LcovExporter.Export (model, Path.Combine(exportDir, "lcov.info"));
            }
            catch (Exception e) {
            Console.WriteLine("Error: "+e.Message);
            return 1;
            }

            if (!opts.quiet) {
            Console.WriteLine ();
            Console.WriteLine ("Done.");
            }
            return 0;
        }
예제 #12
0
	private static int handleExportFieldStat(MonoCovOptions opts, string[] args) {
		if (args.Length == 0) {
			Console.WriteLine ("Error: Datafile name is required when using --export-fieldstat");
			return 1;
		}

		if (!Directory.Exists (opts.exportFieldStatDir)) {
			try {
				Directory.CreateDirectory (opts.exportFieldStatDir);
			}
			catch (Exception ex) {
				Console.WriteLine ("Error: Destination directory '" + opts.exportFieldStatDir + "' does not exist and could not be created: " + ex);
				return 1;
			}
		}
		
		CoverageModel model = new CoverageModel ();
		model.ReadFromFile (args [0]);
		FieldStatExporter exporter = new FieldStatExporter();
		exporter.DestinationDir = opts.exportFieldStatDir;
		exporter.StyleSheet = opts.styleSheet;
		exporter.Export (model);
		if (!opts.quiet) {
			Console.WriteLine ();
			Console.WriteLine ("Done.");
		}
		return 0;
	}