From ca42f82295de89a666bd96d714f1dda146b8043e Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 18 Dec 2016 22:53:38 +0100 Subject: [PATCH] Fixes for CodeCoverage. --- src/ImageSharp/project.json | 1 - tests/CodeCoverage/CodeCoverage.cmd | 3 ++- tests/ImageSharp.Tests/TestImages.cs | 23 +++++++++++++++++++---- tests/ImageSharp.Tests/project.json | 4 ++-- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/ImageSharp/project.json b/src/ImageSharp/project.json index 12cfaee39..a9958a87a 100644 --- a/src/ImageSharp/project.json +++ b/src/ImageSharp/project.json @@ -23,7 +23,6 @@ }, "buildOptions": { "allowUnsafe": true, - "debugType": "portable", "xmlDoc": true, "additionalArguments": [ "/additionalfile:stylecop.json" ] }, diff --git a/tests/CodeCoverage/CodeCoverage.cmd b/tests/CodeCoverage/CodeCoverage.cmd index 2b6b4e6e1..e90740839 100644 --- a/tests/CodeCoverage/CodeCoverage.cmd +++ b/tests/CodeCoverage/CodeCoverage.cmd @@ -8,7 +8,8 @@ cd ..\ImageSharp.Tests dotnet restore -..\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test -c Release" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -oldStyle -output:.\ImageSharp.Coverage.xml +rem The -threshold options prevents this taking ages... +..\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test -c Release -f net451" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -output:.\ImageSharp.Coverage.xml SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH% pip install codecov diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 6898cbce2..bd745f7e1 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -5,14 +5,29 @@ namespace ImageSharp.Tests { + using System.IO; + /// /// Class that contains all the test images. /// public static class TestImages { + private static readonly string FormatsDirectory = GetFormatsDirectory(); + + private static string GetFormatsDirectory() + { + // Here for code coverage tests. + string directory = "TestImages/Formats/"; + if (Directory.Exists(directory)) + { + return directory; + } + return "../../../../TestImages/Formats/"; + } + public static class Png { - private static readonly string folder = "TestImages/Formats/Png/"; + private static readonly string folder = FormatsDirectory + "Png/"; public static TestFile P1 => new TestFile(folder + "pl.png"); public static TestFile Pd => new TestFile(folder + "pd.png"); @@ -37,7 +52,7 @@ namespace ImageSharp.Tests public static class Jpeg { - private static readonly string folder = "TestImages/Formats/Jpg/"; + private static readonly string folder = FormatsDirectory + "Jpg/"; public static TestFile Cmyk => new TestFile(folder + "cmyk.jpg"); public static TestFile Exif => new TestFile(folder + "exif.jpg"); @@ -67,7 +82,7 @@ namespace ImageSharp.Tests public static class Bmp { - private static readonly string folder = "TestImages/Formats/Bmp/"; + private static readonly string folder = FormatsDirectory + "Bmp/"; public static TestFile Car => new TestFile(folder + "Car.bmp"); @@ -82,7 +97,7 @@ namespace ImageSharp.Tests public static class Gif { - private static readonly string folder = "TestImages/Formats/Gif/"; + private static readonly string folder = FormatsDirectory + "Gif/"; public static TestFile Rings => new TestFile(folder + "rings.gif"); public static TestFile Giphy => new TestFile(folder + "giphy.gif"); diff --git a/tests/ImageSharp.Tests/project.json b/tests/ImageSharp.Tests/project.json index 458bad1c0..798a48be1 100644 --- a/tests/ImageSharp.Tests/project.json +++ b/tests/ImageSharp.Tests/project.json @@ -10,7 +10,6 @@ ] }, "buildOptions": { - "debugType": "portable", "allowUnsafe": true }, "dependencies": { @@ -26,7 +25,8 @@ "version": "1.0.0-*" } } - } + }, + "net451": {} }, "testRunner": "xunit" } \ No newline at end of file