Skip to content

Commit

Permalink
(cake-buildGH-2063) Adds netstandard2 integration tests.
Browse files Browse the repository at this point in the history
- Adds integration test for loading netstandard2 addin.
  • Loading branch information
bjorkstromm authored and gep13 committed Mar 1, 2018
1 parent 0d5623e commit d82d177
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/integration/Cake.Core/Scripting/AddinDirective.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Task("Cake.Core.Scripting.AddinDirective.LoadNetStandardAddin")
.Does(() =>
{
DotNetCorePack($"{Paths.Resources}/Cake.Core/Scripting/netstandard2.addin/netstandard2.addin.csproj",
new DotNetCorePackSettings {
Configuration = "Release"
});

var script = $@"#addin nuget:{Paths.Resources}/Cake.Core/Scripting/netstandard2.addin/bin/Release?package=netstandard2.addin&version=1.0.0
Information(""Magic number: {0}"", GetMagicNumber(false));
Information(""The answer to life: {0}"", TheAnswerToLife);
";

CakeExecuteExpression(script);
});

//////////////////////////////////////////////////////////////////////////////

Task("Cake.Core.Scripting.AddinDirective")
.IsDependentOn("Cake.Core.Scripting.AddinDirective.LoadNetStandardAddin");
2 changes: 2 additions & 0 deletions tests/integration/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#load "./Cake.Common/Tools/Cake/CakeAliases.cake"
#load "./Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cake"
#load "./Cake.Common/Tools/NuGet/NuGetAliases.cake"
#load "./Cake.Core/Scripting/AddinDirective.cake"
#load "./Cake.Core/Scripting/DefineDirective.cake"
#load "./Cake.Core/Scripting/LoadDirective.cake"
#load "./Cake.Core/Scripting/SystemCollections.cake"
Expand Down Expand Up @@ -47,6 +48,7 @@ Setup(ctx =>
//////////////////////////////////////////////////

Task("Cake.Core")
.IsDependentOn("Cake.Core.Scripting.AddinDirective")
.IsDependentOn("Cake.Core.Scripting.DefineDirective")
.IsDependentOn("Cake.Core.Scripting.LoadDirective")
.IsDependentOn("Cake.Core.Scripting.SystemCollections")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using Cake.Core;
using Cake.Core.Annotations;

public static class MyCakeExtension
{
[CakeMethodAlias]
public static int GetMagicNumber(this ICakeContext context, bool value)
{
return value ? int.MinValue : int.MaxValue;
}

[CakeMethodAlias]
public static int GetMagicNumberOrDefault(this ICakeContext context, bool value, Func<int> defaultValueProvider = null)
{
if (value)
{
return int.MinValue;
}

return defaultValueProvider == null ? int.MaxValue : defaultValueProvider();
}

[CakePropertyAlias]
public static int TheAnswerToLife(this ICakeContext context)
{
return 42;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.26.0" />
</ItemGroup>

</Project>

0 comments on commit d82d177

Please sign in to comment.