Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid secondary app init if test class has been ignored #168

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/TestApp/shared/FilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class FilterTests
[DataRow("!abcd | def", "abc.def.g.h.i", true)]
public void When_ParseAndMatch(string filter, string method, bool expectedResult)
{
UnitTestFilter sut = filter;
UnitTestFilter sut = filter;
var result = sut.IsMatch(method);

Assert.AreEqual(expectedResult, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ private DevServer(global::System.Diagnostics.Process process, int port)
dir,
log);

return GetConfigurationValue(data, "RemoteControlHostPath") is { Length: > 0 } path
? path
return GetConfigurationValue(data, "RemoteControlHostPath") is { Length: > 0 } path
? path
: throw new global::System.InvalidOperationException("Failed to get remote control host path");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
Text = $"{testClass.Name} ({testClass.Assembly.GetName().Name})",
Foreground = new SolidColorBrush(Colors.White),
FontSize = 16d,
IsTextSelectionEnabled = true

Check warning on line 326 in src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs

View workflow job for this annotation

GitHub Actions / build

Microsoft.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled is not implemented in Uno (https://aka.platform.uno/notimplemented?m=Microsoft.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled) (https://aka.platform.uno/notimplemented)

Check warning on line 326 in src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs

View workflow job for this annotation

GitHub Actions / build

Microsoft.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled is not implemented in Uno (https://aka.platform.uno/notimplemented?m=Microsoft.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled) (https://aka.platform.uno/notimplemented)

Check warning on line 326 in src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs

View workflow job for this annotation

GitHub Actions / build

Windows.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled is not implemented in Uno (https://aka.platform.uno/notimplemented?m=Windows.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled) (https://aka.platform.uno/notimplemented)
};

testResults.Children.Add(testResultBlock);
Expand Down Expand Up @@ -378,7 +378,7 @@
FontFamily = new FontFamily("Courier New"),
Margin = new Thickness(8, 0, 0, 0),
Foreground = new SolidColorBrush(Colors.LightGray),
IsTextSelectionEnabled = true

Check warning on line 381 in src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs

View workflow job for this annotation

GitHub Actions / build

Microsoft.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled is not implemented in Uno (https://aka.platform.uno/notimplemented?m=Microsoft.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled) (https://aka.platform.uno/notimplemented)

Check warning on line 381 in src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs

View workflow job for this annotation

GitHub Actions / build

Microsoft.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled is not implemented in Uno (https://aka.platform.uno/notimplemented?m=Microsoft.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled) (https://aka.platform.uno/notimplemented)

Check warning on line 381 in src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs

View workflow job for this annotation

GitHub Actions / build

Windows.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled is not implemented in Uno (https://aka.platform.uno/notimplemented?m=Windows.UI.Xaml.Controls.TextBlock.IsTextSelectionEnabled) (https://aka.platform.uno/notimplemented)
};

var retriesText = _currentRun.CurrentRepeatCount != 0 ? $" (Retried {_currentRun.CurrentRepeatCount} time(s))" : "";
Expand Down Expand Up @@ -618,6 +618,7 @@

public async Task RunTestsForInstance(object testClassInstance)
{
#pragma warning disable CA1849
Interlocked.Exchange(ref _cts, new CancellationTokenSource())?.Cancel(); // cancel any previous CTS

testResults.Children.Clear();
Expand Down Expand Up @@ -718,11 +719,9 @@
? ConsoleOutputRecorder.Start()
: default;

var tests = (config.Filter is null
? testClassInfo.Tests
: testClassInfo.Tests.Where(test => config.Filter.IsMatch(test)))
.Select(method => new UnitTestMethodInfo(instance, method))
.ToArray();
var tests = config.Filter is null
? testClassInfo.Tests
: testClassInfo.Tests.Where(test => config.Filter.IsMatch(test.Method)).ToArray();

if (tests.Length <= 0 || testClassInfo.Type == null)
{
Expand All @@ -732,7 +731,9 @@
ReportTestClass(testClassInfo.Type.GetTypeInfo());
_ = ReportMessage($"Running {tests.Length} test methods");

if (testClassInfo.RunsInSecondaryApp is { } secondaryApp && !IsSecondaryApp)
if (testClassInfo.RunsInSecondaryApp is { } secondaryApp
&& !IsSecondaryApp
&& (config.IsRunningIgnored || testClassInfo.Tests.Any(test => !test.IsIgnored(out _))))
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public partial class UnitTestDispatcherCompat

#if WINDOWS_WINUI || HAS_UNO_WINUI

private readonly Windows.UI.Core.CoreDispatcher? _dispatcher;
public UnitTestDispatcherCompat(_Impl impl, Windows.UI.Core.CoreDispatcher? dispatcher = null)
private readonly Windows.UI.Core.CoreDispatcher? _dispatcher;
public UnitTestDispatcherCompat(_Impl impl, Windows.UI.Core.CoreDispatcher? dispatcher = null)
{
this._impl = impl;
this._dispatcher = dispatcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public UnitTestClassInfo(
{
Type = type;
TestClassName = Type?.Name ?? "(null)";
Tests = tests ?? Array.Empty<MethodInfo>();
Tests = tests?.Select(test => new UnitTestMethodInfo(test)).ToArray() ?? Array.Empty<UnitTestMethodInfo>();
Initialize = initialize;
Cleanup = cleanup;

Expand All @@ -33,7 +33,7 @@ public UnitTestClassInfo(

public Type? Type { get; }

public MethodInfo[] Tests { get; }
public UnitTestMethodInfo[] Tests { get; }

public MethodInfo? Initialize { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

namespace Uno.UI.RuntimeTests;

internal record UnitTestMethodInfo
public record UnitTestMethodInfo
{
private readonly List<ITestDataSource> _casesParameters;
private readonly IList<PointerDeviceType> _injectedPointerTypes;

public UnitTestMethodInfo(object testClassInstance, MethodInfo method)
public UnitTestMethodInfo(MethodInfo method)
{
Method = method;
RunsOnUIThread =
Expand All @@ -36,7 +36,7 @@ public UnitTestMethodInfo(object testClassInstance, MethodInfo method)
.SingleOrDefault()
?.ExceptionType;

_casesParameters = method
_casesParameters = method
.GetCustomAttributes()
.Where(x => x is ITestDataSource)
.Cast<ITestDataSource>()
Expand Down Expand Up @@ -80,7 +80,7 @@ public bool IsIgnored(out string ignoreMessage)
return false;
}

public IEnumerable<TestCase> GetCases(CancellationToken ct)
internal IEnumerable<TestCase> GetCases(CancellationToken ct)
{
List<TestCase> cases = new();

Expand All @@ -98,7 +98,7 @@ public IEnumerable<TestCase> GetCases(CancellationToken ct)
.GetData(Method)
.Select(caseData => new TestCase
{
Parameters = caseData,
Parameters = caseData,
DisplayName = testCaseSource.GetDisplayName(Method, caseData)
});

Expand Down
Loading