зеркало из https://github.com/mono/SkiaSharp.git
[Tests] Added the test run to the Cake script
This commit is contained in:
Родитель
81b487bd00
Коммит
c3deb8415f
36
build.cake
36
build.cake
|
@ -115,6 +115,27 @@ CakeSpec.Samples = new ISolutionBuilder [] {
|
|||
},
|
||||
};
|
||||
|
||||
CakeSpec.Tests = new SolutionTestRunner [] {
|
||||
new SolutionTestRunner {
|
||||
SolutionBuilder = new DefaultSolutionBuilder {
|
||||
IsWindowsCompatible = true,
|
||||
IsMacCompatible = false,
|
||||
SolutionPath = "./tests/SkiaSharp.WindowsDesktop.Tests/SkiaSharp.WindowsDesktop.Tests.sln",
|
||||
Platform = "x86",
|
||||
},
|
||||
TestAssembly = "./tests/SkiaSharp.WindowsDesktop.Tests/bin/x86/Release/SkiaSharp.WindowsDesktop.Tests.dll",
|
||||
},
|
||||
new SolutionTestRunner {
|
||||
SolutionBuilder = new DefaultSolutionBuilder {
|
||||
IsWindowsCompatible = true,
|
||||
IsMacCompatible = false,
|
||||
SolutionPath = "./tests/SkiaSharp.WindowsDesktop.Tests/SkiaSharp.WindowsDesktop.Tests.sln",
|
||||
Platform = "x64",
|
||||
},
|
||||
TestAssembly = "./tests/SkiaSharp.WindowsDesktop.Tests/bin/x64/Release/SkiaSharp.WindowsDesktop.Tests.dll",
|
||||
},
|
||||
};
|
||||
|
||||
CakeSpec.NuSpecs = new [] {
|
||||
"./nuget/Xamarin.SkiaSharp.nuspec"
|
||||
};
|
||||
|
@ -136,17 +157,10 @@ Task ("externals")
|
|||
|
||||
FilePath input = "binding/SkiaSharp.Generic/bin/Release/SkiaSharp.dll";
|
||||
var libPath = "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/,.";
|
||||
if (IsRunningOnUnix ()) {
|
||||
StartProcess ("mono", new ProcessSettings {
|
||||
Arguments = string.Format("\"{0}\" -libPath:{3} -out \"{1}\" \"{2}\"", CakeStealer.GenApiToolPath, input.GetFilename () + ".cs", input.GetFilename (), libPath),
|
||||
WorkingDirectory = input.GetDirectory ().FullPath,
|
||||
});
|
||||
} else {
|
||||
StartProcess (CakeStealer.GenApiToolPath, new ProcessSettings {
|
||||
Arguments = string.Format("-libPath:{2} -out \"{0}\" \"{1}\"", input.GetFilename () + ".cs", input.GetFilename (), libPath),
|
||||
WorkingDirectory = input.GetDirectory ().FullPath,
|
||||
});
|
||||
}
|
||||
StartProcess (CakeStealer.GenApiToolPath, new ProcessSettings {
|
||||
Arguments = string.Format("-libPath:{2} -out \"{0}\" \"{1}\"", input.GetFilename () + ".cs", input.GetFilename (), libPath),
|
||||
WorkingDirectory = input.GetDirectory ().FullPath,
|
||||
});
|
||||
CopyFile ("binding/SkiaSharp.Generic/bin/Release/SkiaSharp.dll.cs", "binding/SkiaSharp.Portable/SkiaPortable.cs");
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Cake" version="0.6.0" />
|
||||
<package id="NUnit.Console" version="3.0.1" />
|
||||
</packages>
|
||||
|
|
64
common.cake
64
common.cake
|
@ -21,6 +21,18 @@ FilePath GetCakeToolPath ()
|
|||
return new FilePath (p.Modules[0].FileName);
|
||||
}
|
||||
|
||||
FilePath GetNUnitConsoleToolPath ()
|
||||
{
|
||||
var appRoot = Context.Environment.GetApplicationRoot ();
|
||||
|
||||
var consolePath = appRoot.Combine ("../").CombineWithFilePath ("NUnit.Console/tools/nunit3-console.exe");
|
||||
|
||||
if (FileExists (consolePath))
|
||||
return consolePath;
|
||||
|
||||
return GetFiles ("../../../**/nunit3-console.exe").FirstOrDefault ();
|
||||
}
|
||||
|
||||
FilePath GetNugetToolPath ()
|
||||
{
|
||||
if (IsRunningOnUnix ())
|
||||
|
@ -97,9 +109,11 @@ CakeStealer.NuGetSources = NUGET_RESTORE_SOURCES;
|
|||
CakeStealer.NugetToolPath = GetNugetToolPath ();
|
||||
CakeStealer.XamarinComponentToolPath = GetXamarinComponentToolPath ();
|
||||
CakeStealer.CakeToolPath = GetCakeToolPath ();
|
||||
CakeStealer.NUnitConsoleToolPath = GetNUnitConsoleToolPath ();
|
||||
CakeStealer.GenApiToolPath = GetGenApiToolPath ();
|
||||
|
||||
Information ("Cake.exe ToolPath: {0}", CakeStealer.CakeToolPath);
|
||||
Information ("Cake.exe NUnitConsoleToolPath: {0}", CakeStealer.NUnitConsoleToolPath);
|
||||
Information ("NuGet.exe ToolPath: {0}", CakeStealer.NugetToolPath);
|
||||
Information ("Xamarin-Component.exe ToolPath: {0}", CakeStealer.XamarinComponentToolPath);
|
||||
Information ("genapi.exe ToolPath: {0}", CakeStealer.GenApiToolPath);
|
||||
|
@ -120,6 +134,7 @@ public class CakeStealer
|
|||
static public FilePath NugetToolPath { get;set; }
|
||||
static public FilePath XamarinComponentToolPath { get; set; }
|
||||
static public FilePath CakeToolPath { get;set; }
|
||||
static public FilePath NUnitConsoleToolPath { get;set; }
|
||||
static public FilePath GenApiToolPath { get;set; }
|
||||
}
|
||||
|
||||
|
@ -168,7 +183,7 @@ public class DefaultSolutionBuilder : CakeStealer, ISolutionBuilder
|
|||
public Action PreBuildAction { get;set; }
|
||||
public Action PostBuildAction { get;set; }
|
||||
|
||||
protected virtual bool CanBuildOnPlatform {
|
||||
public virtual bool CanBuildOnPlatform {
|
||||
get {
|
||||
if (CakeContext.IsRunningOnWindows () && !IsWindowsCompatible)
|
||||
return false;
|
||||
|
@ -332,16 +347,50 @@ public class WpSolutionBuilder : DefaultSolutionBuilder
|
|||
}
|
||||
}
|
||||
|
||||
public class SolutionTestRunner : CakeStealer
|
||||
{
|
||||
public DefaultSolutionBuilder SolutionBuilder { get; set; }
|
||||
|
||||
public FilePath TestAssembly { get; set; }
|
||||
|
||||
public DirectoryPath TestDiectory { get; set; }
|
||||
|
||||
public void BuildSolution ()
|
||||
{
|
||||
SolutionBuilder.BuildSolution ();
|
||||
SolutionBuilder.CopyOutput ();
|
||||
}
|
||||
|
||||
public void RunTests ()
|
||||
{
|
||||
if (!SolutionBuilder.CanBuildOnPlatform) {
|
||||
CakeContext.Information ("Solution is not configured to run test on this platform: {0}", SolutionBuilder.SolutionPath);
|
||||
return;
|
||||
}
|
||||
|
||||
var dir = TestDiectory == null ? TestAssembly.GetDirectory() : TestDiectory;
|
||||
var result = CakeContext.StartProcess(NUnitConsoleToolPath, new ProcessSettings {
|
||||
Arguments = string.Format ("\"{0}\" --work=\"{1}\"", TestAssembly, dir),
|
||||
});
|
||||
|
||||
if (result != 0) {
|
||||
throw new Exception ("NUnit test failed with error: " + result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CakeSpec
|
||||
{
|
||||
static CakeSpec ()
|
||||
{
|
||||
Libs = new ISolutionBuilder [] {};
|
||||
Tests = new SolutionTestRunner [] {};
|
||||
Samples = new ISolutionBuilder [] {};
|
||||
NuSpecs = new string [] {};
|
||||
}
|
||||
|
||||
static public ISolutionBuilder [] Libs { get; set; }
|
||||
static public SolutionTestRunner [] Tests { get; set; }
|
||||
static public ISolutionBuilder [] Samples { get; set; }
|
||||
static public string [] NuSpecs { get; set; }
|
||||
}
|
||||
|
@ -482,6 +531,19 @@ void DefineDefaultTasks ()
|
|||
Task ("libs").IsDependentOn ("externals").IsDependentOn ("libs-base");
|
||||
}
|
||||
|
||||
Task ("tests-base").Does (() =>
|
||||
{
|
||||
foreach (var t in CakeSpec.Tests) {
|
||||
t.BuildSolution ();
|
||||
t.RunTests ();
|
||||
}
|
||||
});
|
||||
|
||||
if (!Tasks.Where (tsk => tsk.Name == "tests").Any ())
|
||||
{
|
||||
Task ("tests").IsDependentOn ("libs").IsDependentOn ("tests-base");
|
||||
}
|
||||
|
||||
Task ("samples-base").Does (() =>
|
||||
{
|
||||
foreach (var s in CakeSpec.Samples) {
|
||||
|
|
|
@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Skia.WindowsDesktop.Demo",
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.WindowsDesktop", "..\..\binding\SkiaSharp.WindowsDesktop\SkiaSharp.WindowsDesktop.csproj", "{EB1BBDCC-FB07-40D5-8B9E-0079E2C2F2DF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.WindowsDesktop.Tests", "..\..\tests\SkiaSharp.WindowsDesktop.Tests\SkiaSharp.WindowsDesktop.Tests.csproj", "{F0179CDB-9435-4FB4-8E52-DBF191079491}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
..\..\binding\Binding\Binding.projitems*{9c502b9a-25d4-473f-89bd-5a13dde16354}*SharedItemsImports = 13
|
||||
|
@ -49,18 +47,6 @@ Global
|
|||
{EB1BBDCC-FB07-40D5-8B9E-0079E2C2F2DF}.Release|x64.Build.0 = Release|x64
|
||||
{EB1BBDCC-FB07-40D5-8B9E-0079E2C2F2DF}.Release|x86.ActiveCfg = Release|x86
|
||||
{EB1BBDCC-FB07-40D5-8B9E-0079E2C2F2DF}.Release|x86.Build.0 = Release|x86
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Debug|x64.Build.0 = Debug|x64
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Debug|x86.Build.0 = Debug|x86
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Release|x64.ActiveCfg = Release|x64
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Release|x64.Build.0 = Release|x64
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Release|x86.ActiveCfg = Release|x86
|
||||
{F0179CDB-9435-4FB4-8E52-DBF191079491}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
|
|
Загрузка…
Ссылка в новой задаче