Browse Source

Reuse PlatformFact on some onplatform tests

pull/7812/head
Max Katz 4 years ago
parent
commit
6bd6e9fd29
  1. 25
      tests/Avalonia.IntegrationTests.Appium/PlatformFactAttribute.cs
  2. 5
      tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj
  3. 5
      tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/OptionsMarkupExtensionTests.cs

25
tests/Avalonia.IntegrationTests.Appium/PlatformFactAttribute.cs

@ -1,27 +1,34 @@
#nullable enable
using System; using System;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Xunit; using Xunit;
namespace Avalonia.IntegrationTests.Appium namespace Avalonia
{ {
[Flags] [Flags]
internal enum TestPlatforms internal enum TestPlatforms
{ {
Windows = 0x01, Windows = 0x01,
MacOS = 0x02, MacOS = 0x02,
All = Windows | MacOS, Linux = 0x04,
All = Windows | MacOS | Linux,
} }
internal class PlatformFactAttribute : FactAttribute internal class PlatformFactAttribute : FactAttribute
{ {
public PlatformFactAttribute(TestPlatforms platforms = TestPlatforms.All) => Platforms = platforms; private readonly string? _reason;
public PlatformFactAttribute(TestPlatforms platforms, string? reason = null)
{
_reason = reason;
Platforms = platforms;
}
public TestPlatforms Platforms { get; } public TestPlatforms Platforms { get; }
public override string? Skip public override string? Skip
{ {
get => IsSupported() ? null : $"Ignored on {RuntimeInformation.OSDescription}"; get => IsSupported() ? null : $"Ignored on {RuntimeInformation.OSDescription}" + (_reason is not null ? $" reason: \"{_reason}\"" : "");
set => throw new NotSupportedException(); set => throw new NotSupportedException();
} }
@ -31,6 +38,8 @@ namespace Avalonia.IntegrationTests.Appium
return Platforms.HasAnyFlag(TestPlatforms.Windows); return Platforms.HasAnyFlag(TestPlatforms.Windows);
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return Platforms.HasAnyFlag(TestPlatforms.MacOS); return Platforms.HasAnyFlag(TestPlatforms.MacOS);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
return Platforms.HasAnyFlag(TestPlatforms.Linux);
return false; return false;
} }
} }

5
tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj

@ -31,5 +31,10 @@
<AvaloniaResource Include="Xaml\XamlIlClassWithPrecompiledXaml.xaml" /> <AvaloniaResource Include="Xaml\XamlIlClassWithPrecompiledXaml.xaml" />
<AvaloniaResource Include="Xaml\XamlIlClassWithCustomProperty.xaml" /> <AvaloniaResource Include="Xaml\XamlIlClassWithCustomProperty.xaml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Include="..\Avalonia.IntegrationTests.Appium\PlatformFactAttribute.cs">
<Link>PlatformFactAttribute.cs</Link>
</Compile>
</ItemGroup>
<Import Project="..\..\build\BuildTargets.targets" /> <Import Project="..\..\build\BuildTargets.targets" />
</Project> </Project>

5
tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/OptionsMarkupExtensionTests.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Runtime.InteropServices;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml.MarkupExtensions; using Avalonia.Markup.Xaml.MarkupExtensions;
using Avalonia.Media; using Avalonia.Media;
@ -185,7 +186,7 @@ public class OptionsMarkupExtensionTests : XamlTestBase
Assert.Equal(new Thickness(10, 8, 10, 8), border.Padding); Assert.Equal(new Thickness(10, 8, 10, 8), border.Padding);
} }
[Fact] [PlatformFact(TestPlatforms.Windows | TestPlatforms.Linux, "TypeArguments test is failing on macOS from SRE emit")]
public void Respect_Custom_TypeArgument() public void Respect_Custom_TypeArgument()
{ {
using var _ = SetupTestGlobals("option 1"); using var _ = SetupTestGlobals("option 1");
@ -261,7 +262,7 @@ public class OptionsMarkupExtensionTests : XamlTestBase
Assert.Equal(Color.Parse("#ff506070"), ((ISolidColorBrush)border.Background!).Color); Assert.Equal(Color.Parse("#ff506070"), ((ISolidColorBrush)border.Background!).Color);
} }
[Fact] [PlatformFact(TestPlatforms.Windows | TestPlatforms.Linux, "TypeArguments test is failing on macOS from SRE emit")]
public void Support_Xml_Syntax_With_Custom_TypeArguments() public void Support_Xml_Syntax_With_Custom_TypeArguments()
{ {
using var _ = SetupTestGlobals("option 1"); using var _ = SetupTestGlobals("option 1");

Loading…
Cancel
Save