diff --git a/src/TestApp/shared/FilterTests.cs b/src/TestApp/shared/FilterTests.cs index caee6b2..a9b7968 100644 --- a/src/TestApp/shared/FilterTests.cs +++ b/src/TestApp/shared/FilterTests.cs @@ -53,6 +53,20 @@ public class FilterTests [DataRow("abc ; g.h.i", "g.h", false)] [DataRow("abc ; g.h.i", "g.h.i", true)] [DataRow("abc ; g.h.i", "abc.def.g.h.i", true)] + + [DataRow("!abc", "abc.def.g.h.i", false)] + [DataRow("abc & !def", "abc.def.g.h.i", false)] + [DataRow("!abc & def", "abc.def.g.h.i", false)] + [DataRow("abc & !defg", "abc.def.g.h.i", true)] + [DataRow("!abc & defg", "abc.def.g.h.i", false)] + [DataRow("abcd & !def", "abc.def.g.h.i", false)] + [DataRow("!abcd & def", "abc.def.g.h.i", true)] + [DataRow("abc | !def", "abc.def.g.h.i", true)] + [DataRow("!abc | def", "abc.def.g.h.i", true)] + [DataRow("abc | !defg", "abc.def.g.h.i", true)] + [DataRow("!abc | defg", "abc.def.g.h.i", false)] + [DataRow("abcd | !def", "abc.def.g.h.i", false)] + [DataRow("!abcd | def", "abc.def.g.h.i", true)] public void When_ParseAndMatch(string filter, string method, bool expectedResult) { UnitTestFilter sut = filter; 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 7f03b34..c0b9dc0 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/RuntimeTestEmbeddedRunner.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/RuntimeTestEmbeddedRunner.cs @@ -80,7 +80,7 @@ private static async Task RunTestsAndExit(string testsConfigRaw, string outputPa #pragma warning restore CA1416 // Validate platform compatibility // Wait for the app to init it-self - await Task.Delay(500, ct.Token).ConfigureAwait(false); + await Task.Delay(2000, ct.Token).ConfigureAwait(false); for (var i = 0; Window.Current is null && i < 100; i++) { await Task.Delay(50, ct.Token).ConfigureAwait(false); diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestCase.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestCase.cs index 9bbec27..54c88ea 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestCase.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestCase.cs @@ -1,5 +1,9 @@ #nullable enable +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; using System.Linq; using Windows.Devices.Input; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestCaseResult.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestCaseResult.cs index 8952cf1..3a2045d 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestCaseResult.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestCaseResult.cs @@ -1,5 +1,9 @@ #nullable enable +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; using System.Linq; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestResult.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestResult.cs index d0d8529..39acc24 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestResult.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestResult.cs @@ -1,4 +1,8 @@ -using System; +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +# endif + +using System; using System.Linq; namespace Uno.UI.RuntimeTests; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.CustomConsoleOutput.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.CustomConsoleOutput.cs index 69a0514..171db78 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.CustomConsoleOutput.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.CustomConsoleOutput.cs @@ -1,5 +1,9 @@ #if !UNO_RUNTIMETESTS_DISABLE_UI +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; using System.Collections.Generic; using System.IO; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.TestRun.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.TestRun.cs index 13f0c8b..b62c3ab 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.TestRun.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.TestRun.cs @@ -2,6 +2,10 @@ #if !UNO_RUNTIMETESTS_DISABLE_UI +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + public sealed partial class UnitTestsControl { private class TestRun 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 a34456d..a8d7e53 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs @@ -1,6 +1,10 @@ #if !UNO_RUNTIMETESTS_DISABLE_UI #nullable enable + +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously using System; @@ -129,8 +133,10 @@ private static void OverrideDebugProviderAsserts() #endif } +#pragma warning disable CA2201 // Do not raise reserved exception types static void FailCore(string stackTrace, string message, string detailMessage, string errorSource) => throw new Exception($"{message} ({detailMessage}) {stackTrace}"); +#pragma warning restore CA2201 public bool IsRunningOnCI { diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsUIContentHelper.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsUIContentHelper.cs index 5b5a4d1..1790eb0 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsUIContentHelper.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsUIContentHelper.cs @@ -1,5 +1,9 @@ #nullable enable +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; using System.ComponentModel; using System.Diagnostics; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/_Private/UnitTestDispatcherCompat.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/_Private/UnitTestDispatcherCompat.cs index a4cbd62..76434a0 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/_Private/UnitTestDispatcherCompat.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/_Private/UnitTestDispatcherCompat.cs @@ -1,5 +1,9 @@ #if !UNO_RUNTIMETESTS_DISABLE_UI +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; using System.Collections.Generic; using System.Text; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestClassInfo.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestClassInfo.cs index 388e692..ce2dc60 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestClassInfo.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestClassInfo.cs @@ -1,5 +1,9 @@ #nullable enable +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; using System.Linq; using System.Reflection; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestEngineConfig.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestEngineConfig.cs index 86d2ab0..9f54485 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestEngineConfig.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestEngineConfig.cs @@ -1,5 +1,9 @@ #nullable enable +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; using System.Linq; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestFilter.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestFilter.cs index 2043d31..f86f2c5 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestFilter.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestFilter.cs @@ -1,4 +1,9 @@ #if !UNO_RUNTIMETESTS_DISABLE_UI || !UNO_RUNTIMETESTS_DISABLE_EMBEDDEDRUNNER + +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; using System.Linq; using System.Reflection; @@ -8,7 +13,7 @@ namespace Uno.UI.RuntimeTests; public record UnitTestFilter { private readonly IUnitTestEngineFilter _filter; - private static readonly char[] _separators = { '(', ')', '&', '|', ';' }; + private static readonly char[] _separators = { '(', ')', '&', '|', ';', '!' }; private UnitTestFilter(IUnitTestEngineFilter filter) { @@ -44,36 +49,42 @@ private static IUnitTestEngineFilter Parse(string? syntax) else { var index = 0; - return Parse(ref index, syntax.AsSpan()); + var pending = default(IUnitTestEngineFilter?); + var stx = syntax.AsSpan(); + do + { + pending = ReadToken(pending, ref index, stx); + } while (index < syntax.Length); + + return pending; } } - private static IUnitTestEngineFilter Parse(ref int index, ReadOnlySpan syntax) + private static IUnitTestEngineFilter ReadToken(IUnitTestEngineFilter? pending, ref int index, ReadOnlySpan syntax) { // Simple syntax parser ... that does not have any operator priority! - var pending = default(IUnitTestEngineFilter?); for (; index < syntax.Length; index++) { switch (syntax[index]) { case '(': index++; - pending = Parse(ref index, syntax); + pending = ReadToken(null, ref index, syntax); break; - //case ' ': - // break; + case ' ': + break; case '&' when pending is not null: index++; - pending = new AndFilter(pending, Parse(ref index, syntax)); + pending = new AndFilter(pending, ReadToken(null, ref index, syntax)); break; case ';' when pending is not null: // Legacy support case '|' when pending is not null: index++; - pending = new OrFilter(pending, Parse(ref index, syntax)); + pending = new OrFilter(pending, ReadToken(null, ref index, syntax)); break; case ')' when pending is not null: @@ -82,13 +93,25 @@ private static IUnitTestEngineFilter Parse(ref int index, ReadOnlySpan syn case ')': return new NullFilter(); + case '!': + index++; + pending = new NotFilter(ReadToken(null, ref index, syntax)); + break; + default: { var j = index; - for (; j < syntax.Length && !_separators.Contains(syntax[j]); j++) { } - pending = new TextFilter(syntax.Slice(index, j - index).ToString().Trim()); - index = j - 1; - break; + for (; j < syntax.Length; j++) + { + if (_separators.Contains(syntax[j])) + { + j--; + break; + } + } + var text = syntax.Slice(index, j - index).ToString().TrimEnd(); + index = j; + return text is { Length: > 0 } ? new TextFilter(text) : default(NullFilter); } } } @@ -113,6 +136,12 @@ private readonly record struct OrFilter(IUnitTestEngineFilter Left, IUnitTestEng public override string ToString() => $"({Left} | {Right})"; } + private readonly record struct NotFilter(IUnitTestEngineFilter Filter) : IUnitTestEngineFilter + { + public bool IsMatch(string methodFullname) => !Filter.IsMatch(methodFullname); + public override string ToString() => $"!({Filter})"; + } + private readonly record struct TextFilter(string Text) : IUnitTestEngineFilter { public bool IsMatch(string methodFullname) => methodFullname.Contains(Text, StringComparison.InvariantCultureIgnoreCase); diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestMethodInfo.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestMethodInfo.cs index 2bf1735..1ddfd29 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestMethodInfo.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UnitTestMethodInfo.cs @@ -1,6 +1,9 @@ #if !UNO_RUNTIMETESTS_DISABLE_UI #nullable enable +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif using System; using System.Collections.Generic; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Library/InjectedPointerAttribute.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Library/InjectedPointerAttribute.cs index 9bfa77a..a14db80 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Library/InjectedPointerAttribute.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Library/InjectedPointerAttribute.cs @@ -1,5 +1,9 @@ #nullable enable +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; namespace Uno.UI.RuntimeTests; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Library/RequiresFullWindowAttribute.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Library/RequiresFullWindowAttribute.cs index e6d4c59..d674bda 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Library/RequiresFullWindowAttribute.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Library/RequiresFullWindowAttribute.cs @@ -1,5 +1,9 @@ #nullable enable +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; namespace Uno.UI.RuntimeTests; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Library/RunsInSecondaryAppAttribute.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Library/RunsInSecondaryAppAttribute.cs index 01b96e5..362841f 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Library/RunsInSecondaryAppAttribute.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Library/RunsInSecondaryAppAttribute.cs @@ -1,5 +1,9 @@ #nullable enable +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; namespace Uno.UI.RuntimeTests; diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Library/RunsOnUIThreadAttribute.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Library/RunsOnUIThreadAttribute.cs index 3b3f57c..8a2028b 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Library/RunsOnUIThreadAttribute.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Library/RunsOnUIThreadAttribute.cs @@ -1,5 +1,9 @@ #nullable enable +#if !IS_UNO_RUNTIMETEST_PROJECT +#pragma warning disable +#endif + using System; namespace Uno.UI.RuntimeTests; diff --git a/src/Uno.UI.RuntimeTests.Engine.Package/Uno.UI.RuntimeTests.Engine.Package.csproj b/src/Uno.UI.RuntimeTests.Engine.Package/Uno.UI.RuntimeTests.Engine.Package.csproj index bd42141..89346e2 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Package/Uno.UI.RuntimeTests.Engine.Package.csproj +++ b/src/Uno.UI.RuntimeTests.Engine.Package/Uno.UI.RuntimeTests.Engine.Package.csproj @@ -26,6 +26,10 @@ true build + + true + buildTransitive + true false diff --git a/src/Uno.UI.RuntimeTests.Engine.Package/build/Uno.UI.RuntimeTests.Engine.targets b/src/Uno.UI.RuntimeTests.Engine.Package/build/Uno.UI.RuntimeTests.Engine.targets index ce8dd1c..1655520 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Package/build/Uno.UI.RuntimeTests.Engine.targets +++ b/src/Uno.UI.RuntimeTests.Engine.Package/build/Uno.UI.RuntimeTests.Engine.targets @@ -6,10 +6,4 @@ - - - $(DefineConstants);HAS_UNO_DEVSERVER - true - true - \ No newline at end of file diff --git a/src/Uno.UI.RuntimeTests.Engine.Package/buildTransitive/Uno.UI.RuntimeTests.Engine.targets b/src/Uno.UI.RuntimeTests.Engine.Package/buildTransitive/Uno.UI.RuntimeTests.Engine.targets new file mode 100644 index 0000000..31c5f1e --- /dev/null +++ b/src/Uno.UI.RuntimeTests.Engine.Package/buildTransitive/Uno.UI.RuntimeTests.Engine.targets @@ -0,0 +1,8 @@ + + + $(DefineConstants);HAS_UNO_DEVSERVER + true + true + true + + \ No newline at end of file