From 1e25b6f5bcc780e05dd096f1406b0fe586077c2e Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Mon, 21 May 2018 21:22:32 +0200 Subject: [PATCH 1/3] Added extra images to the exclude list and also skip them locally. --- .../Formats/Jpg/JpegDecoderTests.Baseline.cs | 2 +- .../Formats/Jpg/JpegDecoderTests.Progressive.cs | 2 +- tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs index 778459775..f178c29c0 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg public void DecodeBaselineJpeg_PdfJs(TestImageProvider provider) where TPixel : struct, IPixel { - if (TestEnvironment.RunsOnCI && !TestEnvironment.Is64BitProcess) + if (SkipTest(provider)) { // skipping to avoid OutOfMemoryException on CI return; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs index 83983691e..c988f8f05 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg public void DecodeProgressiveJpeg_Orig(TestImageProvider provider) where TPixel : struct, IPixel { - if (TestEnvironment.RunsOnCI && !TestEnvironment.Is64BitProcess) + if (SkipTest(provider)) { // skipping to avoid OutOfMemoryException on CI return; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index cfd5989f5..3667790a2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -48,11 +48,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg string[] largeImagesToSkipOn32Bit = { TestImages.Jpeg.Baseline.Jpeg420Exif, - TestImages.Jpeg.Issues.BadZigZagProgressive385 + TestImages.Jpeg.Issues.MissingFF00ProgressiveBedroom159, + TestImages.Jpeg.Issues.BadZigZagProgressive385, + TestImages.Jpeg.Issues.NoEoiProgressive517, + TestImages.Jpeg.Issues.BadRstProgressive518, }; - return TestEnvironment.RunsOnCI && !TestEnvironment.Is64BitProcess - && largeImagesToSkipOn32Bit.Contains(provider.SourceFileOrDescription); + return !TestEnvironment.Is64BitProcess && largeImagesToSkipOn32Bit.Contains(provider.SourceFileOrDescription); } public JpegDecoderTests(ITestOutputHelper output) From abd1ba437d1432f6f60deb10830823ce0d284116 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Tue, 22 May 2018 23:41:20 +0200 Subject: [PATCH 2/3] Added missing null check when disposing the objects. --- .../FrameQuantizers/WuFrameQuantizer{TPixel}.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs index fbc40dc8a..bc7a2df71 100644 --- a/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs @@ -157,13 +157,13 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers } finally { - this.vwt.Dispose(); - this.vmr.Dispose(); - this.vmg.Dispose(); - this.vmb.Dispose(); - this.vma.Dispose(); - this.m2.Dispose(); - this.tag.Dispose(); + this.vwt?.Dispose(); + this.vmr?.Dispose(); + this.vmg?.Dispose(); + this.vmb?.Dispose(); + this.vma?.Dispose(); + this.m2?.Dispose(); + this.tag?.Dispose(); } } From 4a0e0e159d553d7afd34348584aafedef0097b8c Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Tue, 22 May 2018 23:42:07 +0200 Subject: [PATCH 3/3] Disable caching in the FileProvider for the 32bit build. --- .../ImageProviders/FileProvider.cs | 25 +++++++++++-------- .../Tests/TestImageProviderTests.cs | 12 +++++++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs index 2dbddcc8f..6475547a0 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs @@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests public bool Equals(Key other) { - if (ReferenceEquals(null, other)) return false; + if (other is null) return false; if (ReferenceEquals(this, other)) return true; if (!this.commonValues.Equals(other.commonValues)) return false; @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) return false; + if (obj is null) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; return this.Equals((Key)obj); @@ -133,15 +133,14 @@ namespace SixLabors.ImageSharp.Tests { Guard.NotNull(decoder, nameof(decoder)); - Key key = new Key(this.PixelType, this.FilePath, decoder); + if (!TestEnvironment.Is64BitProcess) + { + return LoadImage(decoder); + } - Image cachedImage = cache.GetOrAdd( - key, - fn => - { - var testFile = TestFile.Create(this.FilePath); - return Image.Load(this.Configuration, testFile.Bytes, decoder); - }); + var key = new Key(this.PixelType, this.FilePath, decoder); + + Image cachedImage = cache.GetOrAdd(key, fn => { return LoadImage(decoder); }); return cachedImage.Clone(); } @@ -158,6 +157,12 @@ namespace SixLabors.ImageSharp.Tests base.Serialize(info); info.AddValue("path", this.FilePath); } + + private Image LoadImage(IImageDecoder decoder) + { + var testFile = TestFile.Create(this.FilePath); + return Image.Load(this.Configuration, testFile.Bytes, decoder); + } } public static string GetFilePathOrNull(ITestImageProvider provider) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 494c56dea..c5d9a7248 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -121,6 +121,12 @@ namespace SixLabors.ImageSharp.Tests public void GetImage_WithCustomParameterlessDecoder_ShouldUtilizeCache(TestImageProvider provider) where TPixel : struct, IPixel { + if (!TestEnvironment.Is64BitProcess) + { + // We don't cache with the 32 bit build. + return; + } + Assert.NotNull(provider.Utility.SourceFileOrDescription); TestDecoder.DoTestThreadSafe(() => @@ -179,6 +185,12 @@ namespace SixLabors.ImageSharp.Tests public void GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParametersAreEqual(TestImageProvider provider) where TPixel : struct, IPixel { + if (!TestEnvironment.Is64BitProcess) + { + // We don't cache with the 32 bit build. + return; + } + Assert.NotNull(provider.Utility.SourceFileOrDescription); TestDecoderWithParameters.DoTestThreadSafe(() =>