Skip to content

Commit

Permalink
Merge pull request #942 from bUnit-dev/release/v1.13
Browse files Browse the repository at this point in the history
Release of new minor version v1.13
  • Loading branch information
egil authored Dec 16, 2022
2 parents 1c916ba + e3f5261 commit bcd2e6d
Show file tree
Hide file tree
Showing 47 changed files with 196 additions and 162 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
11 changes: 5 additions & 6 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ jobs:
steps:

- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.BUNIT_BOT_TOKEN }}

- name: ⚙️ Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg-private-key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
gpg_private_key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BUNIT_BOT_GPG_KEY_PASSPHRASE }}

- name: ⚙️ Setup CI GIT
Expand Down Expand Up @@ -68,7 +68,6 @@ jobs:
5.0.x
6.0.x
7.0.x
include-prerelease: true
- name: 🎨 Setup color
run: |
Expand All @@ -88,7 +87,7 @@ jobs:

- name: 🛠️ Deploy to GitHub Pages
if: success()
uses: crazy-max/ghaction-github-pages@v2
uses: crazy-max/ghaction-github-pages@v3
with:
build_dir: docs/site/_site
fqdn: bunit.dev
Expand All @@ -111,7 +110,7 @@ jobs:
- name: ⏭ Create pull request from stable to main when direct merge fails
if: steps.mergeMainline.outcome == 'failure'
uses: thomaseizinger/create-pull-request@1.0.0
uses: thomaseizinger/create-pull-request@1.3.0
env:
GITHUB_TOKEN: ${{ secrets.BUNIT_BOT_TOKEN }}
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
if: github.ref == 'refs/heads/main' && contains(fromJson('["major","minor"]'), github.event.inputs.versionIncrement)
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.BUNIT_BOT_TOKEN }}
Expand All @@ -35,9 +35,9 @@ jobs:
exit 1
- name: ⚙️ Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg-private-key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
gpg_private_key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BUNIT_BOT_GPG_KEY_PASSPHRASE }}

- name: ⚙️ Setup CI GIT
Expand All @@ -56,9 +56,9 @@ jobs:
id: versions
run: |
nbgv prepare-release --versionIncrement ${{ github.event.inputs.versionIncrement }}
echo "::set-output name=MAIN_VERSION_COMMIT_MESSAGE::$(git log --format=%B -n 1 --skip 1)"
echo "MAIN_VERSION_COMMIT_MESSAGE=$(git log --format=%B -n 1 --skip 1)" >> $GITHUB_OUTPUT
git checkout release/v$NBGV_MajorMinorVersion
echo "::set-output name=RELEASE_VERSION_COMMIT_MESSAGE::$(git log --format=%B -n 1)"
echo "RELEASE_VERSION_COMMIT_MESSAGE=$(git log --format=%B -n 1)" >> $GITHUB_OUTPUT
# Workaround since nbgv prepare-release does not sign commits.
# This undo's the commits, keeps the version changes, and commits again with signing
Expand All @@ -83,7 +83,7 @@ jobs:
run: git push origin release/v$NBGV_MajorMinorVersion

- name: ⏭ Create pull request for release branch
uses: thomaseizinger/create-pull-request@1.0.0
uses: thomaseizinger/create-pull-request@1.3.0
env:
GITHUB_TOKEN: ${{ secrets.BUNIT_BOT_TOKEN }}
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:

- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -36,7 +36,6 @@ jobs:
5.0.x
6.0.x
7.0.x
include-prerelease: true
- name: 🎨 Setup color
run: |
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:
- name: ⚙️ Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg-private-key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
gpg_private_key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BUNIT_BOT_GPG_KEY_PASSPHRASE }}

- name: ⚙️ Setup CI GIT
Expand All @@ -67,10 +67,9 @@ jobs:
5.0.x
6.0.x
7.0.x
include-prerelease: true
- name: 🛠️ Update changelog
uses: thomaseizinger/keep-a-changelog-new-release@1.2.1
uses: thomaseizinger/keep-a-changelog-new-release@1.3.0
with:
version: ${{ env.NBGV_SemVer2 }}

Expand Down Expand Up @@ -126,7 +125,7 @@ jobs:
- name: ⏭ Create pull request from stable to main when direct merge fails
if: steps.mergeMainline.outcome == 'failure'
uses: thomaseizinger/create-pull-request@1.0.0
uses: thomaseizinger/create-pull-request@1.3.0
env:
GITHUB_TOKEN: ${{ secrets.BUNIT_BOT_TOKEN }}
with:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -44,7 +44,6 @@ jobs:
5.0.x
6.0.x
7.0.x
include-prerelease: true
- name: 🎨 Setup color
if: matrix.os != 'windows-latest'
Expand All @@ -64,10 +63,10 @@ jobs:

- name: 🧪 Run unit tests (async)
run: |
dotnet test --filter Category!=sync -c release --blame-hang-timeout 15s --blame-hang-dump-type full --blame-crash-dump-type full
dotnet test --filter Category!=sync -c release
- name: 🧪 Run unit tests (sync)
run: |
dotnet test --filter Category!=async -c release --blame-hang-timeout 15s --blame-hang-dump-type full --blame-crash-dump-type full
dotnet test --filter Category!=async -c release
- name: 📛 Upload hang- and crash-dumps on test failure
if: failure()
uses: actions/upload-artifact@v3
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to **bUnit** will be documented in this file. The project ad

## [Unreleased]

This release contains a bunch of small tweaks and fixes.

## [1.12.6] - 2022-11-08

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<!-- Shared code analyzers used for all projects in the solution -->
<ItemGroup Label="Code Analyzers">
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.47.0.55603" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.50.0.58025" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Label="Implicit usings"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,9 @@ public static void WaitForState(this IRenderedFragmentBase renderedFragment, Fun
{
waiter.WaitTask.GetAwaiter().GetResult();
}
catch (Exception e)
catch (AggregateException e) when (e.InnerExceptions.Count == 1)
{
if (e is AggregateException aggregateException && aggregateException.InnerExceptions.Count == 1)
{
ExceptionDispatchInfo.Capture(aggregateException.InnerExceptions[0]).Throw();
}

throw;
ExceptionDispatchInfo.Capture(e.InnerExceptions[0]).Throw();
}
}

Expand Down Expand Up @@ -76,14 +71,9 @@ public static void WaitForAssertion(this IRenderedFragmentBase renderedFragment,
{
waiter.WaitTask.GetAwaiter().GetResult();
}
catch (Exception e)
catch (AggregateException e) when (e.InnerExceptions.Count == 1)
{
if (e is AggregateException aggregateException && aggregateException.InnerExceptions.Count == 1)
{
ExceptionDispatchInfo.Capture(aggregateException.InnerExceptions[0]).Throw();
}

throw;
ExceptionDispatchInfo.Capture(e.InnerExceptions[0]).Throw();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.ComponentModel;

namespace Bunit.Extensions.WaitForHelpers;

/// <summary>
Expand All @@ -14,6 +16,11 @@ public WaitForFailedException(string? errorMessage, Exception? innerException =
{
}

internal WaitForFailedException(string errorMessage, int checkCount, int componentRenderCount, int totalRenderCount, Exception? innerException = null)
: base(errorMessage + $" Check count: {checkCount}. Component render count: {componentRenderCount}. Total render count: {totalRenderCount}.", innerException)
{
}

private WaitForFailedException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
34 changes: 24 additions & 10 deletions src/bunit.core/Extensions/WaitForHelpers/WaitForHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public abstract class WaitForHelper<T> : IDisposable
private readonly Func<(bool CheckPassed, T Content)> completeChecker;
private readonly IRenderedFragmentBase renderedFragment;
private readonly ILogger<WaitForHelper<T>> logger;
private readonly TestRenderer renderer;
private bool isDisposed;
private int checkCount;
private Exception? capturedException;

/// <summary>
Expand Down Expand Up @@ -49,15 +51,24 @@ protected WaitForHelper(
{
this.renderedFragment = renderedFragment ?? throw new ArgumentNullException(nameof(renderedFragment));
this.completeChecker = completeChecker ?? throw new ArgumentNullException(nameof(completeChecker));

logger = renderedFragment.Services.CreateLogger<WaitForHelper<T>>();
renderer = (TestRenderer)renderedFragment
.Services
.GetRequiredService<ITestRenderer>();
checkPassedCompletionSource = new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously);
timer = new Timer(_ =>
{
logger.LogWaiterTimedOut(renderedFragment.ComponentId);
checkPassedCompletionSource.TrySetException(new WaitForFailedException(TimeoutErrorMessage, capturedException));
checkPassedCompletionSource.TrySetException(
new WaitForFailedException(
TimeoutErrorMessage ?? string.Empty,
checkCount,
renderedFragment.RenderCount,
renderer.RenderCount,
capturedException));
});
WaitTask = CreateWaitTask(renderedFragment);
WaitTask = CreateWaitTask();
timer.Change(GetRuntimeTimeout(timeout), Timeout.InfiniteTimeSpan);

InitializeWaiting();
Expand Down Expand Up @@ -113,12 +124,8 @@ private void InitializeWaiting()
}
}

private Task<T> CreateWaitTask(IRenderedFragmentBase renderedFragment)
{
var renderer = renderedFragment
.Services
.GetRequiredService<ITestRenderer>();

private Task<T> CreateWaitTask()
{
// Two to failure conditions, that the renderer captures an unhandled
// exception from a component or itself, or that the timeout is reached,
// are executed on the renderers scheduler, to ensure that OnAfterRender
Expand All @@ -144,6 +151,7 @@ private void OnAfterRender(object? sender, EventArgs args)
logger.LogCheckingWaitCondition(renderedFragment.ComponentId);

var checkResult = completeChecker();
checkCount++;
if (checkResult.CheckPassed)
{
checkPassedCompletionSource.TrySetResult(checkResult.Content);
Expand All @@ -157,13 +165,19 @@ private void OnAfterRender(object? sender, EventArgs args)
}
catch (Exception ex)
{
checkCount++;
capturedException = ex;
logger.LogCheckThrow(renderedFragment.ComponentId, ex);

if (StopWaitingOnCheckException)
{
checkPassedCompletionSource.TrySetException(
new WaitForFailedException(CheckThrowErrorMessage, capturedException));
new WaitForFailedException(
CheckThrowErrorMessage ?? string.Empty,
checkCount,
renderedFragment.RenderCount,
renderer.RenderCount,
capturedException));
Dispose();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/bunit.core/Rendering/RootRenderTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Bunit.Rendering;
/// Components added to the render tree must have either a <c>ChildContent</c> or
/// <c>Body</c> parameter.
/// </summary>
[SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "A tree is a collection by default.")]
public sealed class RootRenderTree : IReadOnlyCollection<RootRenderTreeRegistration>
{
private readonly List<RootRenderTreeRegistration> registrations = new();
Expand Down
8 changes: 8 additions & 0 deletions src/bunit.core/Rendering/TestRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class TestRenderer : Renderer, ITestRenderer
/// <inheritdoc/>
public override Dispatcher Dispatcher { get; } = Dispatcher.CreateDefault();

/// <summary>
/// Gets the number of render cycles that has been performed.
/// </summary>
internal int RenderCount { get; private set; }

/// <summary>
/// Initializes a new instance of the <see cref="TestRenderer"/> class.
/// </summary>
Expand Down Expand Up @@ -151,6 +156,8 @@ protected override Task UpdateDisplayAsync(in RenderBatch renderBatch)
{
logger.LogNewRenderBatchReceived();

RenderCount++;

var renderEvent = new RenderEvent(renderBatch, new RenderTreeFrameDictionary());

// removes disposed components
Expand Down Expand Up @@ -201,6 +208,7 @@ protected override void Dispose(bool disposing)
}

renderedComponents.Clear();
unhandledExceptionTsc.TrySetCanceled();
}

base.Dispose(disposing);
Expand Down
3 changes: 2 additions & 1 deletion src/bunit.core/StringSyntaxAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
namespace System.Diagnostics.CodeAnalysis;

/// <summary>Fake version of the StringSyntaxAttribute, which was introduced in .NET 7</summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
[SuppressMessage("Design", "CA1019:Define accessors for attribute arguments", Justification = "The sole purpose is to have the same public surface as the class in .NET7 and above.")]
public sealed class StringSyntaxAttribute : Attribute
{
/// <summary>
Expand Down
Loading

0 comments on commit bcd2e6d

Please sign in to comment.