From 2a09dcc1fd86b530dc9b7b7065dc64d8251571b4 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 16 Jan 2024 16:07:52 -0500 Subject: [PATCH] feat: Add ability to control visibility of teh secondary app (only the root executable, i.e. works only in WinEXE, has no impact debug / EXE mode where window is created manually by uno apps) --- .../ExternalRunner/RuntimeTestEmbeddedRunner.cs | 13 +++++++++++++ .../Engine/ExternalRunner/_Private/SecondaryApp.cs | 2 +- .../Engine/UI/UnitTestsControl.cs | 7 ++++++- .../Engine/UI/UnitTestsControl.xaml | 5 +++++ .../Engine/UnitTestEngineConfig.cs | 2 ++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/RuntimeTestEmbeddedRunner.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/RuntimeTestEmbeddedRunner.cs index e963259..3172730 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/RuntimeTestEmbeddedRunner.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/RuntimeTestEmbeddedRunner.cs @@ -55,6 +55,19 @@ public static void AutoStartTests() if (Environment.GetEnvironmentVariable("UNO_RUNTIME_TESTS_RUN_TESTS") is { } testsConfig && Environment.GetEnvironmentVariable("UNO_RUNTIME_TESTS_OUTPUT_PATH") is { } outputPath) { + if (bool.TryParse(testsConfig, out var runTests)) + { + if (runTests) + { + testsConfig = string.Empty; // Do not treat "true" as a filter. + } + else + { + Trace("Application has been configured to **NOT** start runtime-test, aborting runtime-test embedded runner."); + return; + } + } + Trace($"Application configured to start runtime-tests (Output={outputPath} | Config={testsConfig})."); var outputKind = Enum.TryParse(Environment.GetEnvironmentVariable("UNO_RUNTIME_TESTS_OUTPUT_KIND"), ignoreCase: true, out var kind) diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/SecondaryApp.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/SecondaryApp.cs index 4216c7b..2009fae 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/SecondaryApp.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/SecondaryApp.cs @@ -98,7 +98,7 @@ internal static partial class SecondaryApp childStartInfo.EnvironmentVariables["UNO_RUNTIME_TESTS_RUN_TESTS"] = configJson; childStartInfo.EnvironmentVariables["UNO_RUNTIME_TESTS_OUTPUT_PATH"] = testOutput; childStartInfo.EnvironmentVariables["UNO_RUNTIME_TESTS_OUTPUT_KIND"] = "UnoRuntimeTests"; // "NUnit" - childStartInfo.EnvironmentVariables["UNO_RUNTIME_TESTS_IS_SECONDARY_APP"] = "true"; // "NUnit" + childStartInfo.EnvironmentVariables["UNO_RUNTIME_TESTS_IS_SECONDARY_APP"] = "true"; var childProcess = new global::System.Diagnostics.Process { StartInfo = childStartInfo }; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs index 6adbd31..6c53545 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs @@ -527,6 +527,7 @@ private void EnableConfigPersistence() { consoleOutput.IsChecked = config.IsConsoleOutputEnabled; runIgnored.IsChecked = config.IsRunningIgnored; + showSecondaryApp.IsChecked = config.IsSecondaryAppVisible; retry.IsChecked = config.Attempts > 1; testFilter.Text = config.Filter; } @@ -548,6 +549,8 @@ private void ListenConfigChanged() runIgnored.Unchecked += (snd, e) => StoreConfig(); retry.Checked += (snd, e) => StoreConfig(); retry.Unchecked += (snd, e) => StoreConfig(); + showSecondaryApp.Checked += (snd, e) => StoreConfig(); + showSecondaryApp.Unchecked += (snd, e) => StoreConfig(); testFilter.TextChanged += (snd, e) => StoreConfig(); void StoreConfig() @@ -561,6 +564,7 @@ private UnitTestEngineConfig BuildConfig() { var isConsoleOutput = consoleOutput.IsChecked ?? false; var isRunningIgnored = runIgnored.IsChecked ?? false; + var isSecondaryAppVisible = showSecondaryApp.IsChecked; var attempts = (retry.IsChecked ?? true) ? UnitTestEngineConfig.DefaultRepeatCount : 1; var filter = testFilter.Text.Trim(); if (string.IsNullOrEmpty(filter)) @@ -573,6 +577,7 @@ private UnitTestEngineConfig BuildConfig() Filter = filter, IsConsoleOutputEnabled = isConsoleOutput, IsRunningIgnored = isRunningIgnored, + IsSecondaryAppVisible = isSecondaryAppVisible, Attempts = attempts, }; } @@ -749,7 +754,7 @@ private async Task ExecuteTestsForInstance( config = config with { Filter = $"{testClassInfo.Type.FullName} & ({config.Filter})" }; - var results = await SecondaryApp.RunTest(config, ct, isAppVisible: Debugger.IsAttached); + var results = await SecondaryApp.RunTest(config, ct, isAppVisible: config.IsSecondaryAppVisible ?? Debugger.IsAttached); foreach (var result in results) { ReportTestResult(result); diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.xaml b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.xaml index 0ed0de4..013a4c7 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.xaml +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.xaml @@ -71,6 +71,11 @@ IsChecked="True" not_skia:Content="➰ Auto retry" skia:Content="Auto retry" /> + diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestEngineConfig.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestEngineConfig.cs index 9f54485..af9f3b4 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestEngineConfig.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestEngineConfig.cs @@ -25,6 +25,8 @@ public record UnitTestEngineConfig public bool IsConsoleOutputEnabled { get; init; } public bool IsRunningIgnored { get; init; } + + public bool? IsSecondaryAppVisible { get; init; } } #endif \ No newline at end of file