Skip to content

Commit

Permalink
Adds more integration tests for Cake Frosting (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecampidoglio committed Apr 16, 2024
1 parent 6f43add commit 07804c2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,33 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
env:
csproj-directory: integrationtests/frosting
steps:
- name: Get the sources
uses: actions/checkout@v1
- name: Install Node 16
- name: Install Node 20
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '20'
- name: Install the .NET 8 SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.0.x'
- name: Run a specific Cake Frosting project
uses: ./
with:
csproj-path: integrationtests/frosting/Build.csproj
csproj-path: ${{ env.csproj-directory}}/Build.csproj
- name: Run a specific Cake Frosting task
uses: ./
with:
csproj-path: integrationtests/frosting/Build.csproj
csproj-path: ${{ env.csproj-directory}}/Build.csproj
target: Successful-Task
- name: Run with a specific verbosity level
uses: ./
env:
EXPECTED_VERBOSITY: Diagnostic
with:
verbosity: Diagnostic
csproj-path: ${{ env.csproj-directory}}/Build.csproj
target: Test-Verbosity
30 changes: 29 additions & 1 deletion integrationtests/frosting/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using Cake.Common;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Frosting;
Expand Down Expand Up @@ -30,6 +31,33 @@ public override void Run(BuildContext context)
}
}

[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;

0 comments on commit 07804c2

Please sign in to comment.