Skip to content

Commit

Permalink
Merge pull request #166 from unoplatform/dev/dr/unoSupport
Browse files Browse the repository at this point in the history
feat: Add ability to control visibility of teh secondary app (only th…
  • Loading branch information
dr1rrb authored Jan 16, 2024
2 parents 03a18ca + 2a09dcc commit 148af33
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestResultKind>(Environment.GetEnvironmentVariable("UNO_RUNTIME_TESTS_OUTPUT_KIND"), ignoreCase: true, out var kind)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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()
Expand All @@ -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))
Expand All @@ -573,6 +577,7 @@ private UnitTestEngineConfig BuildConfig()
Filter = filter,
IsConsoleOutputEnabled = isConsoleOutput,
IsRunningIgnored = isRunningIgnored,
IsSecondaryAppVisible = isSecondaryAppVisible,
Attempts = attempts,
};
}
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
IsChecked="True"
not_skia:Content="➰ Auto retry"
skia:Content="Auto retry" />
<ToggleButton
x:Name="showSecondaryApp"
IsThreeState="True"
not_skia:Content="🪟 Show 2nd app"
skia:Content="Show 2nd app" />
</StackPanel>
</Flyout>
</Button.Flyout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public record UnitTestEngineConfig
public bool IsConsoleOutputEnabled { get; init; }

public bool IsRunningIgnored { get; init; }

public bool? IsSecondaryAppVisible { get; init; }
}

#endif

0 comments on commit 148af33

Please sign in to comment.