Make it works on net6.0
authorEunki Hong <eunkiki.hong@samsung.com>
Thu, 26 Oct 2023 16:48:39 +0000 (01:48 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Tue, 31 Oct 2023 14:07:28 +0000 (23:07 +0900)
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
14 files changed:
test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/.vscode/launch.json
test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/Program.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/public/TSPropertyValue.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Api/NUnitTestAssemblyRunner.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/CompositeWorkItem.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/ParallelWorkItemDispatcher.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/SimpleWorkItem.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/SimpleWorkItemDispatcher.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/TestWorker.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/WorkItem.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/WorkShift.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/TUnit/TAsyncThreadMgr.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunitlite/TUnit/TRunner.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunitlite/TextRunner.cs

index 368e16f..dc9b2c9 100755 (executable)
@@ -9,7 +9,7 @@
             "type": "coreclr",
             "request": "launch",
             "preLaunchTask": "build",
-            "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Tizen.NUI.Devel.Tests.dll",
+            "program": "${workspaceFolder}/bin/Debug/net6.0/Tizen.NUI.Devel.Tests.dll",
             "args": [],
             "env": {
                 "DESKTOP_PREFIX":"${env:HOME}/dali-env/opt",
index 60af9ff..f954349 100755 (executable)
@@ -52,6 +52,8 @@ namespace Tizen.NUI.Devel.Tests
         private ManualResetEvent methodExecutionResetEvent;
         private TAsyncThreadMgr asyncThreadMgr;
 
+        private bool testFinished = false;
+
         protected override void OnCreate()
         {
             base.OnCreate();
@@ -114,15 +116,18 @@ namespace Tizen.NUI.Devel.Tests
         {
             methodExecutionResetEvent.WaitOne();
 
-            if (asyncThreadMgr.RunTestMethod() == false)
+            if (eventThreadCallback == null || asyncThreadMgr.RunTestMethod() == false)
             {
                 mainTitle.Text = title + "Finished!\nWill be terminated after 5 seconds";
+                testFinished = true;
+
                 timer = new Timer(300);
                 timer.Tick += OnTick;
                 timer.Start();
                 return;
             }
-            eventThreadCallback.Trigger();
+
+            eventThreadCallback?.Trigger();
         }
 
         private bool OnTick(object obj, EventArgs e)
@@ -163,9 +168,9 @@ namespace Tizen.NUI.Devel.Tests
 
         protected override void OnResume()
         {
-            base.OnResume();
-
             tlog.Debug(tag, $"OnResume()");
+
+            base.OnResume();
         }
 
         protected override void OnPause()
@@ -175,9 +180,21 @@ namespace Tizen.NUI.Devel.Tests
 
         protected override void OnTerminate()
         {
-            timer.Dispose();
-            mainTitle.Unparent();
-            root.Unparent();
+            tlog.Debug(tag, "OnTerminate()");
+
+            // Clear program
+            timer?.Dispose();
+            mainTitle?.Unparent();
+            root?.Dispose();
+            eventThreadCallback?.Dispose();
+
+            // Stop test forcely.
+            if (!testFinished)
+            {
+                // TODO : Currently, it is not works well...
+                // trunner._textRunner.StopTest(true);
+            }
+
             base.OnTerminate();
             Exit();
         }
index aa18e3d..5a73629 100644 (file)
@@ -12,7 +12,6 @@ namespace Tizen.NUI.Devel.Tests
     public class PropertyValueTest
     {
         private const string tag = "NUITEST";
-        private string path;
 
         [SetUp]
         public void Init()
index 10220ce..94ffb3f 100755 (executable)
@@ -261,7 +261,7 @@ namespace NUnit.Framework.Api
         /// </remarks>
         public void RunAsync(ITestListener listener, ITestFilter filter)
         {
-            log.Info("Running tests");
+            TLogger.Write("RunAsync Start!\n");
             if (LoadedTest == null)
                 throw new InvalidOperationException("The Run method was called but no test has been loaded");
 
@@ -288,6 +288,7 @@ namespace NUnit.Framework.Api
 
             StartRun(listener);
             WaitForCompletion(Timeout.Infinite);
+            TLogger.Write("RunAsync Finished!\n");
         }
 
         /// <summary>
@@ -297,6 +298,7 @@ namespace NUnit.Framework.Api
         /// <returns>True if the run completed, otherwise false</returns>
         public bool WaitForCompletion(int timeout)
         {
+            TLogger.Write("WaitForCompletion...\n");
 #if !SILVERLIGHT && !PORTABLE
             return _runComplete.WaitOne(timeout, false);
 #else
@@ -408,6 +410,7 @@ namespace NUnit.Framework.Api
         /// </summary>
         private void OnRunCompleted(object sender, EventArgs e)
         {
+            TLogger.Write("OnRunCompleted\n");
 #if PARALLEL
             if (_pump != null)
                 _pump.Dispose();
index b06a287..e044c25 100755 (executable)
@@ -518,6 +518,7 @@ namespace NUnit.Framework.Internal.Execution
         {
             lock (cancelLock)
             {
+                NUnit.Framework.TUnit.TLogger.Write($"CompositeWorkItem Cancel {force}\n");
                 if (_children == null)
                     return;
 
@@ -531,6 +532,7 @@ namespace NUnit.Framework.Internal.Execution
                         child.Cancel(force);
                 }
             }
+            base.Cancel(force);
         }
 
         private string GetCaseID(string TCID)
index 37344e6..8d3a338 100755 (executable)
@@ -205,6 +205,7 @@ namespace NUnit.Framework.Internal.Execution
         /// </summary>
         public void CancelRun(bool force)
         {
+            NUnit.Framework.TUnit.TLogger.Write($"CancelRun {force}\n");
             foreach (var shift in Shifts)
                 shift.Cancel(force);
         }
index 79fad1c..fe18b79 100755 (executable)
@@ -75,5 +75,10 @@ namespace NUnit.Framework.Internal.Execution
             }
         }
 
+        public override void Cancel(bool force)
+        {
+            TLogger.Write($"Cancel SimpleWorkItem force:{force}\n");
+            base.Cancel(force);
+        }
     }
 }
index 3bab6f4..b0d7c85 100755 (executable)
@@ -99,6 +99,7 @@ namespace NUnit.Framework.Internal.Execution
         /// <param name="force">true if the run should be aborted, false if it should allow its currently running test to complete</param>
         public void CancelRun(bool force)
         {
+            NUnit.Framework.TUnit.TLogger.Write($"CancelRun {force}\n");
 #if !PORTABLE
             lock (cancelLock)
             {
index dc80a92..951c3e2 100755 (executable)
@@ -30,6 +30,7 @@
 #if PARALLEL
 using System;
 using System.Threading;
+using NUnit.Framework.TUnit;
 
 namespace NUnit.Framework.Internal.Execution
 {
@@ -112,6 +113,7 @@ namespace NUnit.Framework.Internal.Execution
         private void TestWorkerThreadProc()
         {
             log.Info("{0} starting ", _workerThread.Name);
+            TLogger.Write($"{_workerThread.Name} Started\n");
 
             _running = true;
 
@@ -125,15 +127,20 @@ namespace NUnit.Framework.Internal.Execution
 
                     log.Info("{0} executing {1}", _workerThread.Name, _currentWorkItem.Test.Name);
 
+                    TLogger.Write($"{_workerThread.Name} busy\n");
+
                     if (Busy != null)
                         Busy(this, EventArgs.Empty);
-
+                        
+                    TLogger.Write($"{_workerThread.Name} executing {_currentWorkItem.Test.Name}\n");
                     _currentWorkItem.WorkerId = Name;
                     _currentWorkItem.Execute();
+                    TLogger.Write($"{_workerThread.Name} executing {_currentWorkItem.Test.Name} done\n");
 
                     if (Idle != null)
                         Idle(this, EventArgs.Empty);
 
+                    TLogger.Write($"{_workerThread.Name} idle\n");
                     ++_workItemCount;
                 }
             }
@@ -141,6 +148,7 @@ namespace NUnit.Framework.Internal.Execution
             {
                 log.Info("{0} stopping - {1} WorkItems processed.", _workerThread.Name, _workItemCount);
             }
+            TLogger.Write($"{_workerThread.Name} Finished\n");
         }
 
         /// <summary>
@@ -159,6 +167,7 @@ namespace NUnit.Framework.Internal.Execution
         /// <param name="force">true if the thread should be aborted, false if it should allow the currently running test to complete</param>
         public void Cancel(bool force)
         {
+            TLogger.Write($"Cancel TestWorker force:{force}\n");
             if (force)
                 _running = false;
 
@@ -167,7 +176,9 @@ namespace NUnit.Framework.Internal.Execution
                 {
                     _currentWorkItem.Cancel(force);
                     if (force)
+                    {
                         _currentWorkItem = null;
+                    }
                 }
         }
     }
index 2242dad..1c12841 100755 (executable)
@@ -383,6 +383,7 @@ namespace NUnit.Framework.Internal.Execution
         /// <param name="force">true if the WorkItem should be aborted, false if it should run to completion</param>
         public virtual void Cancel(bool force)
         {
+            NUnit.Framework.TUnit.TLogger.Write($"Cancel WorkItem force:{force}\n");
             if (Context != null)
                 Context.ExecutionStatus = force ? TestExecutionStatus.AbortRequested : TestExecutionStatus.StopRequested;
 
index 79a7b4a..4b0dc59 100755 (executable)
@@ -201,6 +201,7 @@ namespace NUnit.Framework.Internal.Execution
         /// <param name="force">true if the WorkShift should be aborted, false if it should allow its currently running tests to complete</param>
         public void Cancel(bool force)
         {
+            NUnit.Framework.TUnit.TLogger.Write($"Cancel shift {force}\n");
             if (force)
                 this.IsActive = false;
 
index 58eb76c..7191378 100755 (executable)
@@ -44,6 +44,7 @@ namespace NUnit.Framework.TUnit
 
         public void SetData(TestCommand testCommand, TestMethod testMethod, object[] arguments, TestExecutionContext context, bool IsAsyncOperation)
         {
+            TLogger.Write($"TAsyn.SetData()\n");
             this.testCommand = testCommand;
             this.testMethod = testMethod;
             this.arguments = arguments;
@@ -126,6 +127,7 @@ namespace NUnit.Framework.TUnit
                     runTearDown();
                     Thread.Sleep(50);
                     #endregion
+                    
                     testCommand._testMethodRunComplete.Set();
                     _methodExecutionResetEvent.Reset();
                     _methodExecutionResetEvent.WaitOne();
@@ -163,6 +165,7 @@ namespace NUnit.Framework.TUnit
             #region nguyen.vtan add TearDown
             runTearDown();
             #endregion
+
             testCommand._testMethodRunComplete.Set();
             _methodExecutionResetEvent.Reset();
             _methodExecutionResetEvent.WaitOne();
index ae763ea..440c257 100755 (executable)
@@ -127,14 +127,15 @@ namespace NUnitLite.TUnit
 
             //TLogger.Write("Executing the application: " + pkgName + "...");
             Tizen.Log.Fatal("NUITEST", $"Executing the application: {pkgName}");
+            Tizen.Log.Fatal("NUITEST", $"dllPath: {dllPath}");
             string exeFilePathName = "";
-            if (dllPath.Contains("netcoreapp"))
+            if (dllPath.Contains("net6.0"))
             {
                 exeFilePathName = string.Format(dllPath + "Tizen.{0}Tests.dll", pkgName);
             }
             else
             {
-                exeFilePathName = string.Format(dllPath + "Debug/netcoreapp3.1/Tizen.{0}dll", pkgName);
+                exeFilePathName = string.Format(dllPath + "Debug/net6.0/Tizen.{0}dll", pkgName);
             }
             //TLogger.Write("exeFilePathName : " + exeFilePathName);
             Tizen.Log.Fatal("NUITEST", $"exeFilePathName : {exeFilePathName}");
index 18fe8d3..4cb77f2 100755 (executable)
@@ -420,6 +420,12 @@ namespace NUnitLite
                return Summary.FailureCount + Summary.ErrorCount + Summary.InvalidCount;
        }
 
+       public void StopTest(bool force)
+       {
+               TLogger.Write($"StopTest force:{force}\n");
+               _runner.StopRun(force);
+       }
+
        public void ReportResults(ITestResult result)
        {
                Summary = new ResultSummary(result);