Skip to content

Commit

Permalink
Merge pull request #912 from bUnit-dev/release/v1.12
Browse files Browse the repository at this point in the history
Release of new minor version v1.12
  • Loading branch information
egil authored Nov 8, 2022
2 parents ac4061c + f2d5955 commit 6026243
Show file tree
Hide file tree
Showing 29 changed files with 468 additions and 107 deletions.
6 changes: 0 additions & 6 deletions .github/backmerge-failed.md

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ jobs:
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj"]'

- name: ⚙️ Setup dotnet versions
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
include-prerelease: true

- name: 🎨 Setup color
run: |
echo "DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION=1" >> $GITHUB_ENV
Expand All @@ -84,7 +84,7 @@ jobs:
- name: 🛠️ Building docs
uses: nikeee/docfx-action@v1.0.0
with:
args: docs/site/docfx.json
args: docs/site/docfx.json

- name: 🛠️ Deploy to GitHub Pages
if: success()
Expand All @@ -103,7 +103,7 @@ jobs:

- name: ⏩ Merge stable with main, push origin
id: mergeMainline
continue-on-error: true
continue-on-error: true
run: |
git checkout main
git merge -S stable
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/release-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: release-preview
concurrency: 'release-preview'

on:
workflow_run:
workflow_run:
workflows: [ 'verification' ]
types: [completed]
branches: [main, v2]

workflow_dispatch:
inputs:
nugetRelease:
description: 'Release to NuGet? Set to "true" to release to NuGet.org as well as GPR.'
description: 'Release to NuGet? Set to "true" to release to NuGet.org as well as GPR.'
required: true
default: 'false'

Expand All @@ -19,30 +19,30 @@ jobs:
if: github.event_name == 'workflow_dispatch' || (github.ref == 'refs/heads/main' && ${{ github.event.workflow_run.conclusion == 'success' }}) || (github.ref == 'refs/heads/v2' && ${{ github.event.workflow_run.conclusion == 'success' }})
runs-on: ubuntu-latest
steps:

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

- name: ⚙️ Setup GIT versioning
uses: dotnet/nbgv@v0.4.0

- name: ⚙️ Setup dotnet versions
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
include-prerelease: true

- name: 🎨 Setup color
run: |
echo "DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION=1" >> $GITHUB_ENV
echo "TERM=xterm" >> $GITHUB_ENV
- name: 🛠️ Update tokens in project files
uses: cschleiden/replace-tokens@v1
with:
Expand All @@ -53,7 +53,7 @@ jobs:
dotnet pack -c Release -o ${GITHUB_WORKSPACE}/packages -p:ContinuousIntegrationBuild=true -p:publicrelease=true
dotnet pack src/bunit/ -c Release -o ${GITHUB_WORKSPACE}/packages -p:ContinuousIntegrationBuild=true -p:publicrelease=true
dotnet pack src/bunit.template/ -c Release -o ${GITHUB_WORKSPACE}/packages -p:ContinuousIntegrationBuild=true -p:publicrelease=true
- name: 🛠️ Upload library to GitHub Package Repository
run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/bunit-dev/index.json --skip-duplicate --no-symbols

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:

- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.BUNIT_BOT_TOKEN }}
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
setAllVars: true

- name: ⚙️ Setup dotnet versions
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:

- name: ⏩ Merge stable with main, push to origin
id: mergeMainline
continue-on-error: true
continue-on-error: true
run: |
git checkout main
git merge -S stable
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ on:
- reopened

workflow_dispatch:

concurrency:
group: verification-${{ github.ref }}-1
cancel-in-progress: true
cancel-in-progress: true

jobs:
verify-bunit:
Expand All @@ -37,7 +37,7 @@ jobs:
fetch-depth: 0

- name: ⚙️ Setup dotnet versions
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
Expand All @@ -62,9 +62,12 @@ jobs:
with:
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj"]'

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

## [Unreleased]

### Fixed
- The created HTML contained encoded strings. Reported by [@tobiasbrandstaedter](https://github.com/tobiasbrandstaedter). Fixed by [@linkdotnet](https://github.com/linkdotnet).

## [1.11.7] - 2022-10-13

### Added
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<DotNet3Version>3.1.22</DotNet3Version>
<DotNet5Version>5.0.0</DotNet5Version>
<DotNet6Version>6.0.0</DotNet6Version>
<DotNet7Version>7.0.0-*</DotNet7Version>
<DotNet7Version>7.0.0</DotNet7Version>
</PropertyGroup>

<!-- Solution wide properties -->
Expand Down 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.46.0.54807" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.47.0.55603" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Label="Implicit usings"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ A huge thank you to the [sponsors of my work with bUnit](https://github.com/spon
<table border="0">
<tr>
<td align="center" width="120">
<a href="https://github.com/Progress-Telerik">
<img src="https://avatars.githubusercontent.com/u/57092419?s=460" alt="@Progress-Telerik" class="avatar" width="72" height="72" />
<a href="https://github.com/telerik">
<img src="https://avatars.githubusercontent.com/u/568561?s=200&v=4" alt="@Telerik" class="avatar" width="72" height="72" />
<br />
Progress Telerik
Telerik
</a>
</td>
<td align="center" width="120">
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.113" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" PrivateAssets="All" />

</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,29 @@ public static void WaitForState(this IRenderedFragmentBase renderedFragment, Fun
{
ExceptionDispatchInfo.Capture(aggregateException.InnerExceptions[0]).Throw();
}
else
{
ExceptionDispatchInfo.Capture(e).Throw();
}

throw;
}
}

/// <summary>
/// Wait until the provided <paramref name="statePredicate"/> action returns true,
/// or the <paramref name="timeout"/> is reached (default is one second).
///
/// The <paramref name="statePredicate"/> is evaluated initially, and then each time
/// the <paramref name="renderedFragment"/> renders.
/// </summary>
/// <param name="renderedFragment">The render fragment or component to attempt to verify state against.</param>
/// <param name="statePredicate">The predicate to invoke after each render, which must returns <c>true</c> when the desired state has been reached.</param>
/// <param name="timeout">The maximum time to wait for the desired state.</param>
/// <exception cref="WaitForFailedException">Thrown if the <paramref name="statePredicate"/> throw an exception during invocation, or if the timeout has been reached. See the inner exception for details.</exception>
internal static async Task WaitForStateAsync(this IRenderedFragmentBase renderedFragment, Func<bool> statePredicate, TimeSpan? timeout = null)
{
using var waiter = new WaitForStateHelper(renderedFragment, statePredicate, timeout);

await waiter.WaitTask;
}

/// <summary>
/// Wait until the provided <paramref name="assertion"/> passes (i.e. does not throw an
/// exception), or the <paramref name="timeout"/> is reached (default is one second).
Expand All @@ -66,10 +82,26 @@ public static void WaitForAssertion(this IRenderedFragmentBase renderedFragment,
{
ExceptionDispatchInfo.Capture(aggregateException.InnerExceptions[0]).Throw();
}
else
{
ExceptionDispatchInfo.Capture(e).Throw();
}

throw;
}
}

/// <summary>
/// Wait until the provided <paramref name="assertion"/> passes (i.e. does not throw an
/// exception), or the <paramref name="timeout"/> is reached (default is one second).
///
/// The <paramref name="assertion"/> is attempted initially, and then each time the <paramref name="renderedFragment"/> renders.
/// </summary>
/// <param name="renderedFragment">The rendered fragment to wait for renders from and assert against.</param>
/// <param name="assertion">The verification or assertion to perform.</param>
/// <param name="timeout">The maximum time to attempt the verification.</param>
/// <exception cref="WaitForFailedException">Thrown if the timeout has been reached. See the inner exception to see the captured assertion exception.</exception>
[AssertionMethod]
internal static async Task WaitForAssertionAsync(this IRenderedFragmentBase renderedFragment, Action assertion, TimeSpan? timeout = null)
{
using var waiter = new WaitForAssertionHelper(renderedFragment, assertion, timeout);

await waiter.WaitTask;
}
}
15 changes: 5 additions & 10 deletions src/bunit.core/Extensions/WaitForHelpers/WaitForHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected WaitForHelper(
this.completeChecker = completeChecker ?? throw new ArgumentNullException(nameof(completeChecker));

logger = renderedFragment.Services.CreateLogger<WaitForHelper<T>>();
checkPassedCompletionSource = new TaskCompletionSource<T>();
checkPassedCompletionSource = new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously);
timer = new Timer(_ =>
{
logger.LogWaiterTimedOut(renderedFragment.ComponentId);
Expand Down Expand Up @@ -121,17 +121,12 @@ private Task<T> CreateWaitTask(IRenderedFragmentBase renderedFragment)

// 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 renderes scheduler, to ensure that OnAfterRender
// are executed on the renderers scheduler, to ensure that OnAfterRender
// and the continuations does not happen at the same time.
var failureTask = renderer.Dispatcher.InvokeAsync(() =>
var failureTask = renderer.Dispatcher.InvokeAsync(async () =>
{
return renderer
.UnhandledException
.ContinueWith(
x => Task.FromException<T>(x.Result),
CancellationToken.None,
TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.ExecuteSynchronously,
TaskScheduler.FromCurrentSynchronizationContext());
var exception = await renderer.UnhandledException;
return Task.FromException<T>(exception);
}).Unwrap();

return Task
Expand Down
1 change: 1 addition & 0 deletions src/bunit.core/InternalsVisibleTo.cs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Bunit.Core.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010001be6b1a2ca57b09b7040e2ab0993e515296ae22aef4031a4fe388a1336fe21f69c7e8610e9935de6ed18d94b5c98429f99ef62ce3d0af28a7088f856239368ea808ad4c448aa2a8075ed581f989f36ed0d0b8b1cfcaf1ff6a4506c8a99b7024b6eb56996d08e3c9c1cf5db59bff96fcc63ccad155ef7fc63aab6a69862437b6")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Bunit.Web.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010001be6b1a2ca57b09b7040e2ab0993e515296ae22aef4031a4fe388a1336fe21f69c7e8610e9935de6ed18d94b5c98429f99ef62ce3d0af28a7088f856239368ea808ad4c448aa2a8075ed581f989f36ed0d0b8b1cfcaf1ff6a4506c8a99b7024b6eb56996d08e3c9c1cf5db59bff96fcc63ccad155ef7fc63aab6a69862437b6")]
6 changes: 3 additions & 3 deletions src/bunit.core/Rendering/TestRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class TestRenderer : Renderer, ITestRenderer
private readonly List<RootComponent> rootComponents = new();
private readonly ILogger<TestRenderer> logger;
private readonly IRenderedComponentActivator activator;
private TaskCompletionSource<Exception> unhandledExceptionTsc = new();
private TaskCompletionSource<Exception> unhandledExceptionTsc = new(TaskCreationOptions.RunContinuationsAsynchronously);
private Exception? capturedUnhandledException;

/// <inheritdoc/>
Expand Down Expand Up @@ -352,7 +352,7 @@ protected override void HandleException(Exception exception)

if (!unhandledExceptionTsc.TrySetResult(capturedUnhandledException))
{
unhandledExceptionTsc = new TaskCompletionSource<Exception>();
unhandledExceptionTsc = new TaskCompletionSource<Exception>(TaskCreationOptions.RunContinuationsAsynchronously);
unhandledExceptionTsc.SetResult(capturedUnhandledException);
}
}
Expand All @@ -362,7 +362,7 @@ private void ResetUnhandledException()
capturedUnhandledException = null;

if (unhandledExceptionTsc.Task.IsCompleted)
unhandledExceptionTsc = new TaskCompletionSource<Exception>();
unhandledExceptionTsc = new TaskCompletionSource<Exception>(TaskCreationOptions.RunContinuationsAsynchronously);
}

private void AssertNoUnhandledExceptions()
Expand Down
Loading

0 comments on commit 6026243

Please sign in to comment.