OSDN Git Service

CI環境ではConvertFromWebp_SuccessTestの実行をスキップする
authorKimura Youichi <kim.upsilon@bucyou.net>
Sun, 2 Jun 2024 09:25:13 +0000 (18:25 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sun, 2 Jun 2024 10:10:16 +0000 (19:10 +0900)
.github/workflows/test.yml
Directory.Build.props [new file with mode: 0644]
OpenTween.Tests/WebpDecoderTest.cs
appveyor.yml

index a7d1d15..a6aa217 100644 (file)
@@ -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 (file)
index 0000000..7524fb0
--- /dev/null
@@ -0,0 +1,5 @@
+<Project>
+  <PropertyGroup>
+    <DefineConstants Condition="'$(ContinuousIntegrationBuild)' == 'true'">$(DefineConstants);CI_BUILD</DefineConstants>
+  </PropertyGroup>
+</Project>
index 79f2887..d6fb823 100644 (file)
@@ -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<InvalidImageException>(
+                () => WebpDecoder.ConvertFromWebp(buffer)
+            );
+        }
     }
 }
index 1cb9a89..8805c3a 100644 (file)
@@ -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: