diff --git a/build.cake b/build.cake index 5bbcffbe..165f9b75 100644 --- a/build.cake +++ b/build.cake @@ -161,8 +161,11 @@ Task ("libs") Task ("tests") .IsDependentOn ("libs") + .IsDependentOn ("nuget") .Does (() => { + ClearSkiaSharpNuGetCache (); + RunNuGetRestore ("./tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln"); // Windows (x86 and x64) @@ -185,6 +188,11 @@ Task ("tests") }); RunTests("./tests/SkiaSharp.Desktop.Tests/bin/AnyCPU/Release/SkiaSharp.Desktop.Tests.dll", false); } + // .NET Core + RunDotNetCoreRestore ("./tests/SkiaSharp.NetCore.Tests"); + DotNetCoreTest ("./tests/SkiaSharp.NetCore.Tests", new DotNetCoreTestSettings { + Configuration = "Release" + }); }); //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/cake/UtilsManaged.cake b/cake/UtilsManaged.cake index 7d67328a..c6cb1674 100644 --- a/cake/UtilsManaged.cake +++ b/cake/UtilsManaged.cake @@ -9,6 +9,14 @@ var RunNuGetRestore = new Action ((solution) => }); }); +var RunDotNetCoreRestore = new Action ((solution) => +{ + DotNetCoreRestore (solution, new DotNetCoreRestoreSettings { + Sources = NuGetSources, + Verbosity = DotNetCoreRestoreVerbosity.Verbose + }); +}); + var PackageNuGet = new Action ((nuspecPath, outputPath) => { if (!DirectoryExists (outputPath)) { diff --git a/tests/SkiaSharp.NetCore.Tests/project.json b/tests/SkiaSharp.NetCore.Tests/project.json new file mode 100644 index 00000000..8198d28a --- /dev/null +++ b/tests/SkiaSharp.NetCore.Tests/project.json @@ -0,0 +1,47 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "debugType": "portable", + "define": [ + "NET_STANDARD" + ], + "allowUnsafe": true, + "compile": { + "include": "../Tests/*.cs", + "excludeFiles":[ + "../Tests/SKSurfaceTest.cs" + ] + }, + "copyToOutput": { + "mappings": { + "fonts/": { "include": "../Content/fonts/" }, + "images/": { "include": "../Content/images/" } + } + } + }, + "dependencies": { + "xunit": "2.2.0-beta5-build3474", + "dotnet-test-xunit": "2.2.0-preview2-build1029", + + "SkiaSharp": "1.56.0", + "SkiaSharp.Svg": "1.56.0-beta1" + }, + "testRunner": "xunit", + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0" + } + }, + "imports": [ + "portable-net451+win8" + ] + } + }, + "runtimes": { + "win7-x64": { }, + "win7-x86": { }, + "osx.10.10-x64": { } + } +} diff --git a/tests/Tests/SKStringTest.cs b/tests/Tests/SKStringTest.cs index 3a31457b..c207cf2e 100644 --- a/tests/Tests/SKStringTest.cs +++ b/tests/Tests/SKStringTest.cs @@ -9,7 +9,7 @@ namespace SkiaSharp.Tests [Fact] public void StringIsMarshaledCorrectly () { - using (var typeface = SKTypeface.FromFile (Path.Combine ("fonts", "SpiderSymbol.ttf"))) + using (var typeface = SKTypeface.FromFile (Path.Combine (PathToFonts, "SpiderSymbol.ttf"))) { Assert.Equal ("SpiderSymbol", typeface.FamilyName); } diff --git a/tests/Tests/SKTest.cs b/tests/Tests/SKTest.cs index f661278d..7755f86f 100644 --- a/tests/Tests/SKTest.cs +++ b/tests/Tests/SKTest.cs @@ -1,4 +1,6 @@ using System; +using System.IO; +using System.Reflection; using System.Runtime.InteropServices; using Xunit; @@ -6,13 +8,17 @@ namespace SkiaSharp.Tests { public abstract class SKTest { - protected const string PathToFonts = "fonts"; - protected const string PathToImages = "images"; - #if NET_STANDARD + protected static readonly string PathToAssembly = Path.GetDirectoryName(typeof(SKTest).GetTypeInfo().Assembly.Location); + protected static readonly string PathToFonts = Path.Combine(PathToAssembly, "fonts"); + protected static readonly string PathToImages = Path.Combine(PathToAssembly, "images"); + protected static bool IsUnix => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux); protected static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); #else + protected const string PathToFonts = "fonts"; + protected const string PathToImages = "images"; + protected static bool IsUnix => Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix; protected static bool IsWindows => !IsUnix; #endif diff --git a/tools/packages.config b/tools/packages.config index 3b99f969..0d05ae1d 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,6 +1,6 @@ - +