From c45c0dee949b97fed0d807e9a2b7e3809de8a2a4 Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Sun, 2 Jun 2024 18:25:13 +0900 Subject: [PATCH] =?utf8?q?CI=E7=92=B0=E5=A2=83=E3=81=A7=E3=81=AFConvertFro?= =?utf8?q?mWebp=5FSuccessTest=E3=81=AE=E5=AE=9F=E8=A1=8C=E3=82=92=E3=82=B9?= =?utf8?q?=E3=82=AD=E3=83=83=E3=83=97=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 2 ++ Directory.Build.props | 5 +++++ OpenTween.Tests/WebpDecoderTest.cs | 27 ++++++++++++++++++++++++++- appveyor.yml | 2 +- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 Directory.Build.props diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7d1d159..a6aa217f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,8 @@ env: jobs: build: uses: ./.github/workflows/build.yml + with: + msbuild_args: /p:ContinuousIntegrationBuild=true test: runs-on: windows-2022 diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 00000000..7524fb09 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,5 @@ + + + $(DefineConstants);CI_BUILD + + diff --git a/OpenTween.Tests/WebpDecoderTest.cs b/OpenTween.Tests/WebpDecoderTest.cs index 79f28878..d6fb823c 100644 --- a/OpenTween.Tests/WebpDecoderTest.cs +++ b/OpenTween.Tests/WebpDecoderTest.cs @@ -50,8 +50,14 @@ namespace OpenTween Assert.True(WebpDecoder.IsWebpImage(buffer)); } +#if CI_BUILD +#pragma warning disable xUnit1004 + [Fact(Skip = "WebP画像拡張機能がインストールされている環境でしか動作しない")] +#pragma warning restore xUnit1004 +#else [Fact] - public async Task ConvertFromWebp_Test() +#endif + public async Task ConvertFromWebp_SuccessTest() { using var imgStream = File.OpenRead("Resources/re1.webp"); using var memstream = new MemoryStream(); @@ -62,5 +68,24 @@ namespace OpenTween using var memoryImage = new MemoryImage(converted); Assert.Equal(ImageFormat.Png, memoryImage.ImageFormat); } + +#if CI_BUILD + [Fact] +#else +#pragma warning disable xUnit1004 + [Fact(Skip = "WebP画像拡張機能がインストールされていない環境に対するテスト")] +#pragma warning restore xUnit1004 +#endif + public async Task ConvertFromWebp_FailTest() + { + using var imgStream = File.OpenRead("Resources/re1.webp"); + using var memstream = new MemoryStream(); + await imgStream.CopyToAsync(memstream); + memstream.TryGetBuffer(out var buffer); + + await Assert.ThrowsAsync( + () => WebpDecoder.ConvertFromWebp(buffer) + ); + } } } diff --git a/appveyor.yml b/appveyor.yml index 1cb9a89b..8805c3a3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -57,7 +57,7 @@ init: before_build: - nuget restore - - ps: Set-Content .\msbuild.rsp "/warnaserror /p:DebugType=None" + - ps: Set-Content .\msbuild.rsp "/warnaserror /p:DebugType=None /p:ContinuousIntegrationBuild=true" test: assemblies: -- 2.11.0