Beispiel #1
0
        public void ExcludedFunctionIsExcluded()
        {
            string config = "<ccm>" +
                      "  <exclude>" +
                      "    <function>Foo2</function> " +
                      "    <function>Bar2</function> " +
                      "  </exclude>" +
                      "</ccm>";

              XmlDocument doc = new XmlDocument();
              doc.LoadXml(config);

              ConfigurationFile file = new ConfigurationFile(doc);

              string code1 = "void Foo() {}";
              string code2 = "void Bar() {}";
              string code3 = "void Foo2() {}";
              string code4 = "void Bar2() {}";

              Driver driver = new Driver(file);

              driver.StartAnalyze(TestUtil.GetTextStream(code1), "file1.h");
              driver.StartAnalyze(TestUtil.GetTextStream(code2), "file2.h");
              driver.StartAnalyze(TestUtil.GetTextStream(code3), "file3.h");
              driver.StartAnalyze(TestUtil.GetTextStream(code4), "file4.h");
              driver.WaitForWorkThreadsToFinish();

              DriverTests.AssertMetric(driver.Metrics, "Foo()", 1, "file1.h");
              DriverTests.AssertMetric(driver.Metrics, "Bar()", 1, "file2.h");

              Assert.AreEqual(2, driver.Metrics.Count);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            try
              {
            Program.ValidateArgs(args);

            XmlDocument doc = Program.LoadConfiguration(args);
            ConfigurationFile config = new ConfigurationFile(doc);

            Driver driver = new Driver(config);
            driver.Drive();

            OutputterFactory(config.OutputType).Output(driver.Metrics, driver.Errors, true);
              }
              catch (Exception e)
              {
            Console.WriteLine(e.Message);
            PrintUsage();
              }
        }
Beispiel #3
0
        public void ExcludedFolderOnlyExcludesWhereNameOfFolderIsExactMatch()
        {
            string config = "<ccm>" +
                      "  <exclude>" +
                      "    <folder>Foo</folder> " +
                      "    <folder>Bar</folder> " +
                      "  </exclude>" +
                      "</ccm>";

              XmlDocument doc = new XmlDocument();
              doc.LoadXml(config);

              ConfigurationFile file = new ConfigurationFile(doc);
              Driver driver = new Driver(file);

              Assert.IsTrue(driver.PathShouldBeExcluded("c:\\code\\Foo\\file.cpp"));
              Assert.IsTrue(driver.PathShouldBeExcluded("c:\\code\\bar\\file.cpp"));
              Assert.IsFalse(driver.PathShouldBeExcluded("c:\\code\\FooBar\\fileB.cs"));
              Assert.IsFalse(driver.PathShouldBeExcluded("c:\\code\\BarA\\fileB.cs"));
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            try
              {
            Program.ValidateArgs(args);

            XmlDocument doc = Program.LoadConfiguration(args);
            ConfigurationFile config = new ConfigurationFile(doc);

            Driver driver = new Driver(config);
            driver.Drive();

            if (config.IsOutputFile)
            {
            using (StreamWriter sr = new StreamWriter(config.OutputFile))
            {
                OutputterFactory(config.OutputType,config.XmlStyleSheet).Output(sr,driver.Metrics, driver.Errors, true);
            }
            }
            else {
            OutputterFactory(config.OutputType,config.XmlStyleSheet).Output(System.Console.Out,driver.Metrics, driver.Errors, true);
            }
              }
              catch (Exception e)
              {
            Console.WriteLine(e.Message);
            PrintUsage();
              }
        }
Beispiel #5
0
        public void MultipleStreamsAnalyzed()
        {
            string code1 = "void Foo() {}";
              string code2 = "void Bar() {}";
              string code3 = "void Foo2() {}";
              string code4 = "void Bar2() {}";

              Driver driver = new Driver();

              driver.StartAnalyze(TestUtil.GetTextStream(code1), "file1.h");
              driver.StartAnalyze(TestUtil.GetTextStream(code2), "file2.cpp");
              driver.StartAnalyze(TestUtil.GetTextStream(code3), "file3.cs");
              driver.StartAnalyze(TestUtil.GetTextStream(code4), "file4.h");
              driver.WaitForWorkThreadsToFinish();

              DriverTests.AssertMetric(driver.Metrics, "Foo()", 1, "file1.h");
              DriverTests.AssertMetric(driver.Metrics, "Bar()", 1, "file2.cpp");
              DriverTests.AssertMetric(driver.Metrics, "Foo2()", 1, "file3.cs");
              DriverTests.AssertMetric(driver.Metrics, "Bar2()", 1, "file4.h");
        }
Beispiel #6
0
        public void FullFolderPathIsExcludedOnExactMatch()
        {
            string config = "<ccm>" +
                      "  <exclude>" +
                      "    <folder>c:\\code</folder> " +
                      "  </exclude>" +
                      "</ccm>";

              XmlDocument doc = new XmlDocument();
              doc.LoadXml(config);

              ConfigurationFile file = new ConfigurationFile(doc);
              Driver driver = new Driver(file);

              Assert.IsTrue(driver.PathShouldBeExcluded("c:\\code\\file.cpp"));
              Assert.IsTrue(driver.PathShouldBeExcluded("c:\\code\\sub\\file.cpp"));
              Assert.IsFalse(driver.PathShouldBeExcluded("c:\\temp\\fileB.cs"));
        }
Beispiel #7
0
        public void SingleStreamIsAnalyzed()
        {
            string code = "void Foo() {}";

              Driver driver = new Driver();

              driver.StartAnalyze(TestUtil.GetTextStream(code), "file1.h");
              driver.WaitForWorkThreadsToFinish();

              DriverTests.AssertMetric(driver.Metrics, "Foo()", 1, "file1.h");
        }