Author: lluis
Date: 2005-11-15 11:59:26 -0500 (Tue, 15 Nov 2005)
New Revision: 53076

Modified:
   trunk/monodevelop/Extras/NUnit/ChangeLog
   trunk/monodevelop/Extras/NUnit/Gui/TestResultsPad.cs
   trunk/monodevelop/Extras/NUnit/MonoDevelopNUnit.addin.xml
   trunk/monodevelop/Extras/NUnit/Services/ExternalTestRunner.cs
   trunk/monodevelop/Extras/NUnit/Services/NUnitAssemblyTestSuite.cs
   trunk/monodevelop/Extras/NUnit/Services/NUnitTestCase.cs
   trunk/monodevelop/Extras/NUnit/Services/NUnitTestSuite.cs
   trunk/monodevelop/Extras/NUnit/Services/UnitTest.cs
   trunk/monodevelop/Extras/NUnit/Services/XmlResultsStore.cs
Log:
2005-11-15  Lluis Sanchez Gual  <[EMAIL PROTECTED]> 

        * Services/NUnitTestCase.cs:
        * Services/NUnitTestSuite.cs:
        * Services/NUnitAssemblyTestSuite.cs:
        * Services/ExternalTestRunner.cs: Properly handle the case when it's
        running a single test case.
        
        * Services/UnitTest.cs: Save the inherited store if needed.
        * Services/XmlResultsStore.cs: Reset the modified flag once the
        store is saved.
        * Gui/TestResultsPad.cs: Clear the output buffer when refreshing the
        results list.
        * MonoDevelopNUnit.addin.xml: Added dependency.



Modified: trunk/monodevelop/Extras/NUnit/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/NUnit/ChangeLog    2005-11-15 16:58:34 UTC (rev 
53075)
+++ trunk/monodevelop/Extras/NUnit/ChangeLog    2005-11-15 16:59:26 UTC (rev 
53076)
@@ -1,3 +1,18 @@
+2005-11-15  Lluis Sanchez Gual  <[EMAIL PROTECTED]> 
+
+       * Services/NUnitTestCase.cs:
+       * Services/NUnitTestSuite.cs:
+       * Services/NUnitAssemblyTestSuite.cs:
+       * Services/ExternalTestRunner.cs: Properly handle the case when it's
+       running a single test case.
+       
+       * Services/UnitTest.cs: Save the inherited store if needed.
+       * Services/XmlResultsStore.cs: Reset the modified flag once the
+       store is saved.
+       * Gui/TestResultsPad.cs: Clear the output buffer when refreshing the
+       results list.
+       * MonoDevelopNUnit.addin.xml: Added dependency.
+
 2005-10-11  Lluis Sanchez Gual  <[EMAIL PROTECTED]> 
 
        * MonoDevelopNUnit.addin.xml: Fixed addin header information.

Modified: trunk/monodevelop/Extras/NUnit/Gui/TestResultsPad.cs
===================================================================
--- trunk/monodevelop/Extras/NUnit/Gui/TestResultsPad.cs        2005-11-15 
16:58:34 UTC (rev 53075)
+++ trunk/monodevelop/Extras/NUnit/Gui/TestResultsPad.cs        2005-11-15 
16:59:26 UTC (rev 53076)
@@ -428,6 +428,7 @@
                void RefreshList ()
                {
                        failuresStore.Clear ();
+                       outputView.Buffer.Clear ();
                        AddStartMessage ();
                                
                        foreach (ResultRecord res in results) {

Modified: trunk/monodevelop/Extras/NUnit/MonoDevelopNUnit.addin.xml
===================================================================
--- trunk/monodevelop/Extras/NUnit/MonoDevelopNUnit.addin.xml   2005-11-15 
16:58:34 UTC (rev 53075)
+++ trunk/monodevelop/Extras/NUnit/MonoDevelopNUnit.addin.xml   2005-11-15 
16:59:26 UTC (rev 53076)
@@ -12,6 +12,7 @@
        </Runtime>
        
        <Dependencies>
+               <AddIn id="MonoDevelop.Projects" version="0.9.0"/>
                <AddIn id="MonoDevelop.Ide" version="0.9.0"/>
        </Dependencies>
 

Modified: trunk/monodevelop/Extras/NUnit/Services/ExternalTestRunner.cs
===================================================================
--- trunk/monodevelop/Extras/NUnit/Services/ExternalTestRunner.cs       
2005-11-15 16:58:34 UTC (rev 53075)
+++ trunk/monodevelop/Extras/NUnit/Services/ExternalTestRunner.cs       
2005-11-15 16:59:26 UTC (rev 53076)
@@ -45,9 +45,11 @@
                StringWriter stdout = new StringWriter ();
                StringWriter stderr = new StringWriter ();
                
-               public TestResult Run (EventListener listener, IFilter filter, 
string path, string suiteName, string testName)
+               public TestResult Run (EventListener listener, IFilter filter, 
string path, string suiteName)
                {
                        TestSuite rootTS = LoadTestSuite (path, suiteName);
+                       if (rootTS == null)
+                               throw new Exception ("Test suite '" + suiteName 
+ "' not found.");
 
                        TextWriter origStdout = Console.Out;
                        TextWriter origStderr = Console.Error;
@@ -56,22 +58,9 @@
                        
                        string cdir = Environment.CurrentDirectory;
                        Environment.CurrentDirectory = Path.GetDirectoryName 
(path);
-               
+                       
                        try {
-                               Test nt = null;
-                               if (testName != null) {
-                                       foreach (Test t in rootTS.Tests)
-                                               if (t.Name == testName) {
-                                                       nt = t;
-                                                       break;
-                                               }
-                               } else
-                                       nt = rootTS;
-                                       
-                               if (nt == null)
-                                       throw new Exception ("Test " + 
suiteName + "." + testName + " not found.");
-                                       
-                               return nt.Run (listener, filter);
+                               return rootTS.Run (listener, filter);
                        } finally {
                                Environment.CurrentDirectory = cdir;
                                Console.SetOut (origStdout);
@@ -162,13 +151,19 @@
                string rootFullName;
                ExternalTestRunner runner;
                UnitTest runningTest;
+               bool singleTestRun;
+               Hashtable outputText = new Hashtable ();
+               Hashtable errorText = new Hashtable ();
                
-               public LocalTestMonitor (TestContext context, 
ExternalTestRunner runner, UnitTest rootTest, string rootFullName)
+               internal UnitTestResult SingleTestResult;
+               
+               public LocalTestMonitor (TestContext context, 
ExternalTestRunner runner, UnitTest rootTest, string rootFullName, bool 
singleTestRun)
                {
                        this.runner = runner;
                        this.rootFullName = rootFullName;
                        this.rootTest = rootTest;
                        this.context = context;
+                       this.singleTestRun = singleTestRun;
                }
                
                public UnitTest RunningTest {
@@ -193,7 +188,13 @@
 
                void EventListener.TestStarted (TestCase testCase)
                {
+                       if (singleTestRun)
+                               return;
+                       
                        UnitTest t = GetLocalTest (testCase);
+                       if (t == null)
+                               return;
+                       
                        runningTest = t;
                        context.Monitor.BeginTest (t);
                        t.Status = TestStatus.Running;
@@ -201,10 +202,22 @@
                        
                void EventListener.TestFinished (TestCaseResult result)
                {
+                       outputText [result] = runner.ResetTestConsoleOutput ();
+                       errorText [result] = runner.ResetTestConsoleError ();
+                       
+                       if (singleTestRun) {
+                               SingleTestResult = GetLocalTestResult (result);
+                               return;
+                       }
+                       
                        UnitTest t = GetLocalTest ((Test) result.Test);
+                       if (t == null)
+                               return;
+                       
                        UnitTestResult res = GetLocalTestResult (result);
-                       res.ConsoleOutput = runner.ResetTestConsoleOutput ();
-                       res.ConsoleError = runner.ResetTestConsoleError ();
+                       if (res == null)
+                               return;
+                       
                        t.RegisterResult (context, res);
                        context.Monitor.EndTest (t, res);
                        t.Status = TestStatus.Ready;
@@ -213,14 +226,26 @@
 
                void EventListener.SuiteStarted (TestSuite suite)
                {
+                       if (singleTestRun)
+                               return;
+                       
                        UnitTest t = GetLocalTest (suite);
+                       if (t == null)
+                               return;
+                       
                        t.Status = TestStatus.Running;
                        context.Monitor.BeginTest (t);
                }
 
                void EventListener.SuiteFinished (TestSuiteResult result)
                {
+                       if (singleTestRun)
+                               return;
+                       
                        UnitTest t = GetLocalTest ((Test) result.Test);
+                       if (t == null)
+                               return;
+                       
                        UnitTestResult res = GetLocalTestResult (result);
                        t.RegisterResult (context, res);
                        t.Status = TestStatus.Ready;
@@ -291,6 +316,9 @@
                        res.Message = t.Message;
                        res.StackTrace = t.StackTrace;
                        res.Time = TimeSpan.FromSeconds (t.Time);
+                       res.ConsoleOutput = (string) outputText [t];
+                       res.ConsoleError = (string) errorText [t];
+                       
                        return res;
                }
                

Modified: trunk/monodevelop/Extras/NUnit/Services/NUnitAssemblyTestSuite.cs
===================================================================
--- trunk/monodevelop/Extras/NUnit/Services/NUnitAssemblyTestSuite.cs   
2005-11-15 16:58:34 UTC (rev 53075)
+++ trunk/monodevelop/Extras/NUnit/Services/NUnitAssemblyTestSuite.cs   
2005-11-15 16:59:26 UTC (rev 53076)
@@ -249,21 +249,25 @@
                
                protected override UnitTestResult OnRun (TestContext 
testContext)
                {
-                       return RunUnitTest (this, "", testContext);
+                       return RunUnitTest (this, "", null, testContext);
                }
                
-               internal UnitTestResult RunUnitTest (UnitTest test, string 
suiteName, TestContext testContext)
+               internal UnitTestResult RunUnitTest (UnitTest test, string 
suiteName, string testName, TestContext testContext)
                {
                        ExternalTestRunner runner = (ExternalTestRunner) 
Runtime.ProcessService.CreateExternalProcessObject (typeof(ExternalTestRunner), 
false);
-                       LocalTestMonitor localMonitor = new LocalTestMonitor 
(testContext, runner, test, suiteName);
+                       LocalTestMonitor localMonitor = new LocalTestMonitor 
(testContext, runner, test, suiteName, testName != null);
                        
                        IFilter filter = null;
                        
-                       NUnitCategoryOptions categoryOptions = 
(NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions));
-                       if (categoryOptions.EnableFilter && 
categoryOptions.Categories.Count > 0) {
-                               string[] cats = new string 
[categoryOptions.Categories.Count];
-                               categoryOptions.Categories.CopyTo (cats, 0);
-                               filter = new CategoryFilter (cats, 
categoryOptions.Exclude);
+                       if (testName != null) {
+                               filter = new TestNameFilter (testName);
+                       } else {
+                               NUnitCategoryOptions categoryOptions = 
(NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions));
+                               if (categoryOptions.EnableFilter && 
categoryOptions.Categories.Count > 0) {
+                                       string[] cats = new string 
[categoryOptions.Categories.Count];
+                                       categoryOptions.Categories.CopyTo 
(cats, 0);
+                                       filter = new CategoryFilter (cats, 
categoryOptions.Exclude);
+                               }
                        }
                        
                        RunData rd = new RunData ();
@@ -274,8 +278,11 @@
                        UnitTestResult result;
                        
                        try {
-                               TestResult res = runner.Run (localMonitor, 
filter, AssemblyPath, suiteName, null);
-                               result = localMonitor.GetLocalTestResult (res);
+                               TestResult res = runner.Run (localMonitor, 
filter, AssemblyPath, suiteName);
+                               if (testName != null)
+                                       result = localMonitor.SingleTestResult;
+                               else
+                                       result = 
localMonitor.GetLocalTestResult (res);
                        } catch (Exception ex) {
                                Console.WriteLine (ex);
                                if (localMonitor.RunningTest != null) {
@@ -404,6 +411,27 @@
                        public DateTime LastWriteTime;
                        public TestInfo Info;
                }
+               
+               [Serializable]
+               public class TestNameFilter: IFilter
+               {
+                       string name;
+                       
+                       public TestNameFilter (string name)
+                       {
+                               this.name = name;
+                       }
+                       
+                       public bool Pass (TestSuite suite)
+                       {
+                               return true;
+                       }
+                       
+                       public bool Pass (TestCase test)
+                       {
+                               return test.Name == name;
+                       }
+               }
        }
 }
 

Modified: trunk/monodevelop/Extras/NUnit/Services/NUnitTestCase.cs
===================================================================
--- trunk/monodevelop/Extras/NUnit/Services/NUnitTestCase.cs    2005-11-15 
16:58:34 UTC (rev 53075)
+++ trunk/monodevelop/Extras/NUnit/Services/NUnitTestCase.cs    2005-11-15 
16:59:26 UTC (rev 53076)
@@ -38,13 +38,11 @@
        class NUnitTestCase: UnitTest
        {
                NUnitAssemblyTestSuite rootSuite;
-               string fullName;
                string className;
                
                public NUnitTestCase (NUnitAssemblyTestSuite rootSuite, 
TestInfo tinfo): base (tinfo.Name)
                {
                        className = tinfo.PathName;
-                       fullName = tinfo.PathName + "." + tinfo.Name;
                        this.rootSuite = rootSuite;
                }
                
@@ -54,7 +52,7 @@
                
                protected override UnitTestResult OnRun (TestContext 
testContext)
                {
-                       return rootSuite.RunUnitTest (this, fullName, 
testContext);
+                       return rootSuite.RunUnitTest (this, className, Name, 
testContext);
                }
                
                public override SourceCodeLocation SourceCodeLocation {

Modified: trunk/monodevelop/Extras/NUnit/Services/NUnitTestSuite.cs
===================================================================
--- trunk/monodevelop/Extras/NUnit/Services/NUnitTestSuite.cs   2005-11-15 
16:58:34 UTC (rev 53075)
+++ trunk/monodevelop/Extras/NUnit/Services/NUnitTestSuite.cs   2005-11-15 
16:59:26 UTC (rev 53076)
@@ -54,7 +54,7 @@
                
                protected override UnitTestResult OnRun (TestContext 
testContext)
                {
-                       return rootSuite.RunUnitTest (this, fullName, 
testContext);
+                       return rootSuite.RunUnitTest (this, fullName, null, 
testContext);
                }
                
                protected override void OnCreateTests ()

Modified: trunk/monodevelop/Extras/NUnit/Services/UnitTest.cs
===================================================================
--- trunk/monodevelop/Extras/NUnit/Services/UnitTest.cs 2005-11-15 16:58:34 UTC 
(rev 53075)
+++ trunk/monodevelop/Extras/NUnit/Services/UnitTest.cs 2005-11-15 16:59:26 UTC 
(rev 53076)
@@ -355,8 +355,9 @@
                
                public virtual void SaveResults ()
                {
-                       if (resultsStore != null)
-                               resultsStore.Save ();
+                       IResultsStore store = GetResultsStore ();
+                       if (store != null)
+                               store.Save ();
                }
                
                internal virtual void FindRegressions (UnitTestCollection list, 
DateTime fromDate, DateTime toDate)

Modified: trunk/monodevelop/Extras/NUnit/Services/XmlResultsStore.cs
===================================================================
--- trunk/monodevelop/Extras/NUnit/Services/XmlResultsStore.cs  2005-11-15 
16:58:34 UTC (rev 53075)
+++ trunk/monodevelop/Extras/NUnit/Services/XmlResultsStore.cs  2005-11-15 
16:59:26 UTC (rev 53076)
@@ -199,6 +199,7 @@
                                } finally {
                                        writer.Close ();
                                }
+                               record.Modified = false;
                        }
                        cachedRootList.Clear ();
                }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to