From 3b6b30a2f5ebf57ccd9988f082de93fd25b2c54a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 20 Aug 2022 12:59:44 +1000 Subject: [PATCH] Change percentages for mac --- .../Formats/Gif/GifDecoderTests.cs | 2 +- .../Formats/Tga/TgaDecoderTests.cs | 2 +- .../Formats/WebP/WebpDecoderTests.cs | 2 +- ...ImageDifferenceIsOverThresholdException.cs | 28 +++++++++++++++++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index cbca125a5..3a8ae6f11 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); image.CompareToReferenceOutput( - ImageComparer.Exact, + ImageComparer.TolerantPercentage(0.0001F), provider, testOutputDetails: details, appendPixelTypeToFileName: false); diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs index 8a5412ab7..5007aa371 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs @@ -764,7 +764,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); image.CompareToReferenceOutput( - ImageComparer.Exact, + ImageComparer.TolerantPercentage(0.0001F), provider, testOutputDetails: details, appendPixelTypeToFileName: false); diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index aae27cae2..417d3ce2d 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs @@ -372,7 +372,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); image.CompareToReferenceOutput( - ImageComparer.Exact, + ImageComparer.TolerantPercentage(0.0006F), provider, testOutputDetails: details, appendPixelTypeToFileName: false); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDifferenceIsOverThresholdException.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDifferenceIsOverThresholdException.cs index e77dce861..7560308db 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDifferenceIsOverThresholdException.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDifferenceIsOverThresholdException.cs @@ -24,8 +24,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison sb.Append(Environment.NewLine); - // TODO: We should add macOS. - sb.AppendFormat("Test Environment OS : {0}", TestEnvironment.IsWindows ? "Windows" : "Linux"); + sb.AppendFormat("Test Environment OS : {0}", GetEnvironmentName()); sb.Append(Environment.NewLine); sb.AppendFormat("Test Environment is CI : {0}", TestEnvironment.RunsOnCI); @@ -33,11 +32,14 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison sb.AppendFormat("Test Environment is .NET Core : {0}", !TestEnvironment.IsFramework); sb.Append(Environment.NewLine); + + sb.AppendFormat("Test Environment is Mono : {0}", TestEnvironment.IsMono); + sb.Append(Environment.NewLine); int i = 0; foreach (ImageSimilarityReport r in reports) { - sb.Append($"Report ImageFrame {i}: "); + sb.Append("Report ImageFrame {i}: "); sb.Append(r); sb.Append(Environment.NewLine); i++; @@ -45,5 +47,25 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison return sb.ToString(); } + + private static string GetEnvironmentName() + { + if (TestEnvironment.IsMacOS) + { + return "Mac OS"; + } + + if (TestEnvironment.IsMacOS) + { + return "Linux"; + } + + if (TestEnvironment.IsWindows) + { + return "Windows"; + } + + return "Unknown"; + } } }