-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds an integration test for Cake Frosting (WIP)
- Loading branch information
1 parent
8c83e3a
commit 046458f
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Cake.Frosting" Version="4.0.0" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using Cake.Common; | ||
using Cake.Core; | ||
using Cake.Core.Diagnostics; | ||
using Cake.Frosting; | ||
|
||
public static class Program | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
return new CakeHost() | ||
.UseContext<BuildContext>() | ||
.Run(args); | ||
} | ||
} | ||
|
||
public class BuildContext : FrostingContext | ||
{ | ||
public BuildContext(ICakeContext context) | ||
: base(context) | ||
{ | ||
} | ||
} | ||
|
||
[TaskName("Successful-Task")] | ||
public sealed class SuccessfulTask : FrostingTask<BuildContext> | ||
{ | ||
public override void Run(BuildContext context) | ||
{ | ||
context.Log.Information("✓ Passed"); | ||
} | ||
} | ||
|
||
[TaskName("Test-Verbosity")] | ||
public sealed class TestVerbosity : FrostingTask<BuildContext> | ||
{ | ||
public override void Run(BuildContext context) | ||
{ | ||
var hasExpectedVerbosity = Enum.TryParse( | ||
context.EnvironmentVariable("EXPECTED_VERBOSITY"), | ||
ignoreCase: true, | ||
out Verbosity expectedVerbosity); | ||
|
||
if (!hasExpectedVerbosity) | ||
{ | ||
throw new Exception( | ||
"✕ The EXPECTED_VERBOSITY environment variable is not set or it doesn't contain a verbosity level"); | ||
} | ||
|
||
var actualVerbosity = context.Log.Verbosity; | ||
|
||
if (expectedVerbosity != actualVerbosity) | ||
{ | ||
throw new Exception($"✕ Expected verbosity {expectedVerbosity} but got {actualVerbosity}"); | ||
} | ||
|
||
context.Log.Information("✓ Passed"); | ||
} | ||
} | ||
|
||
[TaskName("Default")] | ||
[IsDependentOn(typeof(SuccessfulTask))] | ||
public class DefaultTask : FrostingTask; |