Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/guiunit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <llsan@microsoft.com>2021-05-19 12:09:57 +0300
committerGitHub <noreply@github.com>2021-05-19 12:09:57 +0300
commitdc47c13c4ed47c76dc2e1f7cb2cb896d9bce00f5 (patch)
tree5a0fa89493117296da0cf1a5f448b6e7f9f742c8
parentc2cd748ef51748c77d560ca393ce79e5f5f3b1c3 (diff)
parentc3864e447faf2c3f6488358af4077eaf4cc0184d (diff)
Merge pull request #24 from mono/dev/lluis/exit-with-code
Report exit code when shutting down toolkit
-rw-r--r--src/framework/GuiUnit/GtkMainLoopIntegration.cs2
-rw-r--r--src/framework/GuiUnit/IMainLoopIntegration.cs2
-rw-r--r--src/framework/GuiUnit/MonoMacMainLoopIntegration.cs2
-rw-r--r--src/framework/GuiUnit/TestRunner.cs49
-rw-r--r--src/framework/GuiUnit/XwtMainLoopIntegration.cs8
5 files changed, 40 insertions, 23 deletions
diff --git a/src/framework/GuiUnit/GtkMainLoopIntegration.cs b/src/framework/GuiUnit/GtkMainLoopIntegration.cs
index 80ab3f5..bf59d30 100644
--- a/src/framework/GuiUnit/GtkMainLoopIntegration.cs
+++ b/src/framework/GuiUnit/GtkMainLoopIntegration.cs
@@ -60,7 +60,7 @@ namespace GuiUnit
Application.GetMethod ("Run").Invoke (null, null);
}
- public void Shutdown ()
+ public void Shutdown (int exitCode)
{
Application.GetMethod ("Quit").Invoke (null, null);
}
diff --git a/src/framework/GuiUnit/IMainLoopIntegration.cs b/src/framework/GuiUnit/IMainLoopIntegration.cs
index 4121c50..a51f4c8 100644
--- a/src/framework/GuiUnit/IMainLoopIntegration.cs
+++ b/src/framework/GuiUnit/IMainLoopIntegration.cs
@@ -7,7 +7,7 @@ namespace GuiUnit
void InitializeToolkit ();
void InvokeOnMainLoop (InvokerHelper helper);
void RunMainLoop ();
- void Shutdown ();
+ void Shutdown (int exitCode);
}
}
diff --git a/src/framework/GuiUnit/MonoMacMainLoopIntegration.cs b/src/framework/GuiUnit/MonoMacMainLoopIntegration.cs
index 6ff8100..4314dba 100644
--- a/src/framework/GuiUnit/MonoMacMainLoopIntegration.cs
+++ b/src/framework/GuiUnit/MonoMacMainLoopIntegration.cs
@@ -56,7 +56,7 @@ namespace GuiUnit
Application.GetMethod ("Run").Invoke (SharedApplication, null);
}
- public void Shutdown ()
+ public void Shutdown (int exitCode)
{
Application.GetMethod ("Terminate").Invoke (SharedApplication, new [] { SharedApplication });
}
diff --git a/src/framework/GuiUnit/TestRunner.cs b/src/framework/GuiUnit/TestRunner.cs
index fb8d3a2..996bc42 100644
--- a/src/framework/GuiUnit/TestRunner.cs
+++ b/src/framework/GuiUnit/TestRunner.cs
@@ -82,6 +82,8 @@ namespace GuiUnit
private ITestAssemblyRunner runner;
+ private bool finished;
+
#region Constructors
/// <summary>
@@ -228,7 +230,8 @@ namespace GuiUnit
} catch (Exception ex) {
Console.WriteLine ("Unexpected error while running the tests: {0}", ex);
} finally {
- Shutdown ();
+ FinishTestExecution();
+ Shutdown();
}
});
MainLoop.RunMainLoop ();
@@ -246,24 +249,34 @@ namespace GuiUnit
ExitCode = 1;
}
finally
- {
- if (commandLineOptions.OutFile == null)
- {
- if (commandLineOptions.Wait)
- {
- Console.WriteLine("Press Enter key to continue . . .");
- Console.ReadLine();
- }
- }
- else
- {
- writer.Close();
- }
- }
- }
+ {
+ FinishTestExecution();
+ }
+ }
}
- static void Shutdown ()
+ private void FinishTestExecution()
+ {
+ if (finished)
+ return;
+
+ finished = true;
+
+ if (commandLineOptions.OutFile == null)
+ {
+ if (commandLineOptions.Wait)
+ {
+ Console.WriteLine("Press Enter key to continue . . .");
+ Console.ReadLine();
+ }
+ }
+ else
+ {
+ writer.Close();
+ }
+ }
+
+ static void Shutdown ()
{
// Run the shutdown method on the main thread
var helper = new InvokerHelper {
@@ -275,7 +288,7 @@ namespace GuiUnit
Console.WriteLine ("Unexpected error during `BeforeShutdown`: {0}", ex);
ExitCode = 1;
} finally {
- MainLoop.Shutdown ();
+ MainLoop.Shutdown (ExitCode);
}
return null;
}
diff --git a/src/framework/GuiUnit/XwtMainLoopIntegration.cs b/src/framework/GuiUnit/XwtMainLoopIntegration.cs
index d657fcd..ff6d598 100644
--- a/src/framework/GuiUnit/XwtMainLoopIntegration.cs
+++ b/src/framework/GuiUnit/XwtMainLoopIntegration.cs
@@ -67,9 +67,13 @@ namespace GuiUnit
Application.GetMethod ("Run").Invoke (null, null);
}
- public void Shutdown ()
+ public void Shutdown (int exitCode)
{
- Application.GetMethod ("Exit").Invoke (null, null);
+ var method = Application.GetMethod("Exit", new Type[] { typeof(int) });
+ if (method != null)
+ method.Invoke(null, new object[] { exitCode });
+ else
+ Application.GetMethod("Exit").Invoke(null, null);
}
}
}