Skip to content

Commit

Permalink
Merge pull request #4430 from devlead/feature/4427
Browse files Browse the repository at this point in the history
GH4427: Update xunit to V3
  • Loading branch information
devlead authored Jan 5, 2025
2 parents d51bb67 + 2fdc78b commit 7217373
Show file tree
Hide file tree
Showing 31 changed files with 117 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/Cake.Common.Tests/Cake.Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<ProjectReference Include="..\Cake.Core\Cake.Core.csproj" />
<ProjectReference Include="..\Cake.Common\Cake.Common.csproj" />
<ProjectReference Include="..\Cake.Testing\Cake.Testing.csproj" />
<ProjectReference Include="..\Cake.Testing.Xunit\Cake.Testing.Xunit.csproj" />
<ProjectReference Include="..\Cake.Testing.Xunit.v3\Cake.Testing.Xunit.v3.csproj" />
</ItemGroup>
<!-- Global packages -->
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
6 changes: 3 additions & 3 deletions src/Cake.Core.Tests/Cake.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<ItemGroup>
<ProjectReference Include="..\Cake.Core\Cake.Core.csproj" />
<ProjectReference Include="..\Cake.Testing\Cake.Testing.csproj" />
<ProjectReference Include="..\Cake.Testing.Xunit\Cake.Testing.Xunit.csproj" />
<ProjectReference Include="..\Cake.Testing.Xunit.v3\Cake.Testing.Xunit.v3.csproj" />
</ItemGroup>
<!-- Global packages -->
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Spectre.Verify.Extensions" />
<PackageReference Include="Verify.Xunit" />
<PackageReference Include="xunit" />
<PackageReference Include="Verify.XunitV3" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
1 change: 0 additions & 1 deletion src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Threading.Tasks;
using Cake.Testing.Xunit;
using Xunit;
using Xunit.Abstractions;

namespace Cake.Core.Tests.Unit
{
Expand Down
8 changes: 4 additions & 4 deletions src/Cake.Core.Tests/Unit/CakeTaskBuilderExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public void Should_Add_Action_To_Task()
var builder = new CakeTaskBuilder(task);

// When
builder.Does<string>(async (data, context) => { await Task.Delay(0); });
builder.Does<string>(async (data, context) => { await Task.Delay(0, TestContext.Current.CancellationToken); });

// Then
Assert.Single(task.Actions);
Expand Down Expand Up @@ -289,7 +289,7 @@ public void Should_Add_Action_To_Task()
var builder = new CakeTaskBuilder(task);

// When
builder.Does<string>(async data => { await Task.Delay(0); });
builder.Does<string>(async data => { await Task.Delay(0, TestContext.Current.CancellationToken); });

// Then
Assert.Single(task.Actions);
Expand Down Expand Up @@ -323,7 +323,7 @@ public void Should_Add_Action_To_Task()
var builder = new CakeTaskBuilder(task);

// When
builder.Does(async c => { await Task.Delay(0); });
builder.Does(async c => { await Task.Delay(0, TestContext.Current.CancellationToken); });

// Then
Assert.Single(task.Actions);
Expand Down Expand Up @@ -354,7 +354,7 @@ public void Should_Add_Action_To_Task()
var builder = new CakeTaskBuilder(task);

// When
builder.Does(async () => { await Task.Delay(0); });
builder.Does(async () => { await Task.Delay(0, TestContext.Current.CancellationToken); });

// Then
Assert.Single(task.Actions);
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.Core.Tests/Unit/CakeTaskBuilderOfTExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void Should_Add_Action_To_Task()
var builder = new CakeTaskBuilder<string>(task);

// When
builder.Does(async (data, ctx) => { await Task.Delay(0); });
builder.Does(async (data, ctx) => { await Task.Delay(0, TestContext.Current.CancellationToken); });

// Then
Assert.Single(task.Actions);
Expand Down Expand Up @@ -257,7 +257,7 @@ public void Should_Add_Action_To_Task()
var builder = new CakeTaskBuilder<string>(task);

// When
builder.Does(async (ctx, data) => { await Task.Delay(0); });
builder.Does(async (ctx, data) => { await Task.Delay(0, TestContext.Current.CancellationToken); });

// Then
Assert.Single(task.Actions);
Expand Down
3 changes: 2 additions & 1 deletion src/Cake.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
[assembly: InternalsVisibleTo("Cake.Tool")]
[assembly: InternalsVisibleTo("Cake.Common")]
[assembly: InternalsVisibleTo("Cake.Core.Tests")]
[assembly: InternalsVisibleTo("Cake.Testing.Xunit")]
[assembly: InternalsVisibleTo("Cake.Testing.Xunit")]
[assembly: InternalsVisibleTo("Cake.Testing.Xunit.v3")]
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<ProjectReference Include="..\Cake.Core\Cake.Core.csproj" />
<ProjectReference Include="..\Cake.DotNetTool.Module\Cake.DotNetTool.Module.csproj" />
<ProjectReference Include="..\Cake.Testing\Cake.Testing.csproj" />
<ProjectReference Include="..\Cake.Testing.Xunit\Cake.Testing.Xunit.csproj" />
<ProjectReference Include="..\Cake.Testing.Xunit.v3\Cake.Testing.Xunit.v3.csproj" />
</ItemGroup>
<!-- Global packages -->
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
12 changes: 12 additions & 0 deletions src/Cake.Frosting.Tests.Tasks/Cake.Frosting.Tests.Tasks.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(MSBuildThisFileDirectory)..\Shared.msbuild" />

<PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>


<ItemGroup>
<ProjectReference Include="..\Cake.Frosting\Cake.Frosting.csproj" />
</ItemGroup>
</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
<ItemGroup>
<ProjectReference Include="..\Cake.Frosting\Cake.Frosting.csproj" />
<ProjectReference Include="..\Cake.Testing\Cake.Testing.csproj" />
<ProjectReference Include="..\Cake.Frosting.Tests.Tasks\Cake.Frosting.Tests.Tasks.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 0 additions & 1 deletion src/Cake.Frosting.Tests/CakeHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Xunit;
using Xunit.Sdk;

namespace Cake.Frosting.Tests
{
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<ProjectReference Include="..\Cake.Core\Cake.Core.csproj" />
<ProjectReference Include="..\Cake.NuGet\Cake.NuGet.csproj" />
<ProjectReference Include="..\Cake.Testing\Cake.Testing.csproj" />
<ProjectReference Include="..\Cake.Testing.Xunit\Cake.Testing.Xunit.csproj" />
<ProjectReference Include="..\Cake.Testing.Xunit.v3\Cake.Testing.Xunit.v3.csproj" />
</ItemGroup>
<!-- Global packages -->
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
28 changes: 28 additions & 0 deletions src/Cake.Testing.Xunit.v3/Cake.Testing.Xunit.v3.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Cake.Testing.Xunit.v3</AssemblyName>
<OutputType>Library</OutputType>
<PlatformTarget>AnyCpu</PlatformTarget>
<IsPackable>true</IsPackable>
<DefineConstants>$(DefineConstants);XUNIT3</DefineConstants>
</PropertyGroup>
<!-- Package specific metadata -->
<PropertyGroup>
<Description>Contains Xunit.v3 testing utilities for Cake.</Description>
</PropertyGroup>
<!-- Global packages -->
<ItemGroup>
<PackageReference Include="xunit.v3" />
</ItemGroup>
<!-- Import shared functionality -->
<Import Project="..\Shared.msbuild" />
<!-- Project references -->
<ItemGroup>
<ProjectReference Include="..\Cake.Core\Cake.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="../Cake.Testing.Xunit/**/*.cs" Exclude="../Cake.Testing.Xunit/obj/**;../Cake.Testing.Xunit/bin/**;../Cake.Testing.Xunit/Properties/**">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile>
</ItemGroup>
</Project>
18 changes: 18 additions & 0 deletions src/Cake.Testing.Xunit.v3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Cake.Testing.Xunit.v3")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
[assembly: CLSCompliant(false)]
12 changes: 11 additions & 1 deletion src/Cake.Testing.Xunit/PlatformRestrictedFactAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace Cake.Testing.Xunit
public abstract class PlatformRestrictedFactAttribute : FactAttribute
{
private static readonly PlatformFamily _family;
#if !XUNIT3
private string _skip;
#endif

static PlatformRestrictedFactAttribute()
{
Expand All @@ -38,15 +40,23 @@ protected PlatformRestrictedFactAttribute(
}

Reason = reason;
#if XUNIT3
if (!string.IsNullOrEmpty(reason) && string.IsNullOrWhiteSpace(Skip))
{
Skip = reason;
}
#endif
}
}

private string Reason { get; }
protected string Reason { get; }

#if !XUNIT3
public override string Skip
{
get => _skip ?? Reason;
set => _skip = value;
}
#endif
}
}
12 changes: 11 additions & 1 deletion src/Cake.Testing.Xunit/PlatformRestrictedTheoryAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace Cake.Testing.Xunit
public abstract class PlatformRestrictedTheoryAttribute : TheoryAttribute
{
private static readonly PlatformFamily _family;
#if !XUNIT3
private string _skip;
#endif

static PlatformRestrictedTheoryAttribute()
{
Expand All @@ -38,15 +40,23 @@ protected PlatformRestrictedTheoryAttribute(
}

Reason = reason;
#if XUNIT3
if (!string.IsNullOrEmpty(reason) && string.IsNullOrEmpty(Skip))
{
Skip = reason;
}
#endif
}
}

private string Reason { get; }
protected string Reason { get; }

#if !XUNIT3
public override string Skip
{
get => _skip ?? Reason;
set => _skip = value;
}
#endif
}
}
4 changes: 2 additions & 2 deletions src/Cake.Tests/Cake.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand All @@ -23,7 +23,7 @@
<ItemGroup>
<ProjectReference Include="..\Cake\Cake.csproj" />
<ProjectReference Include="..\Cake.Core\Cake.Core.csproj" />
<ProjectReference Include="..\Cake.Testing.Xunit\Cake.Testing.Xunit.csproj" />
<ProjectReference Include="..\Cake.Testing.Xunit.v3\Cake.Testing.Xunit.v3.csproj" />
<ProjectReference Include="..\Cake.Testing\Cake.Testing.csproj" />
</ItemGroup>

Expand Down
14 changes: 14 additions & 0 deletions src/Cake.sln
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.DotNetTool.Module", "C
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.DotNetTool.Module.Tests", "Cake.DotNetTool.Module.Tests\Cake.DotNetTool.Module.Tests.csproj", "{CE4433AD-A5F2-44DA-A0DA-E51D141FFFDC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Testing.Xunit.v3", "Cake.Testing.Xunit.v3\Cake.Testing.Xunit.v3.csproj", "{EAF830C8-6D2E-43FB-83E2-A1E192A6B8B1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Frosting.Tests.Tasks", "Cake.Frosting.Tests.Tasks\Cake.Frosting.Tests.Tasks.csproj", "{CCEB314C-5724-4E07-B2D9-C7A78DE50CE2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -146,6 +150,14 @@ Global
{CE4433AD-A5F2-44DA-A0DA-E51D141FFFDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE4433AD-A5F2-44DA-A0DA-E51D141FFFDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE4433AD-A5F2-44DA-A0DA-E51D141FFFDC}.Release|Any CPU.Build.0 = Release|Any CPU
{EAF830C8-6D2E-43FB-83E2-A1E192A6B8B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAF830C8-6D2E-43FB-83E2-A1E192A6B8B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAF830C8-6D2E-43FB-83E2-A1E192A6B8B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAF830C8-6D2E-43FB-83E2-A1E192A6B8B1}.Release|Any CPU.Build.0 = Release|Any CPU
{CCEB314C-5724-4E07-B2D9-C7A78DE50CE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCEB314C-5724-4E07-B2D9-C7A78DE50CE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCEB314C-5724-4E07-B2D9-C7A78DE50CE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCEB314C-5724-4E07-B2D9-C7A78DE50CE2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -161,6 +173,8 @@ Global
{26F4E738-122C-428D-A014-62A357F39023} = {8615F41E-65C7-4BE5-AFD4-C9C78912AF80}
{83848400-2E27-4B57-B733-FAF357ED1AE6} = {A01118B7-C6FC-4B0B-8B5C-F580F31FE57D}
{CE4433AD-A5F2-44DA-A0DA-E51D141FFFDC} = {8615F41E-65C7-4BE5-AFD4-C9C78912AF80}
{EAF830C8-6D2E-43FB-83E2-A1E192A6B8B1} = {DD6045D3-D869-48FE-9BB1-9F61EF73F192}
{CCEB314C-5724-4E07-B2D9-C7A78DE50CE2} = {DD6045D3-D869-48FE-9BB1-9F61EF73F192}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {35585E1D-D23E-40C8-A01E-2E5FF5B41083}
Expand Down
3 changes: 2 additions & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
<PackageVersion Include="Spectre.Verify.Extensions" Version="22.3.1" />
<PackageVersion Include="System.Collections.Immutable" Version="9.0.0" />
<PackageVersion Include="System.Reflection.Metadata" Version="9.0.0" />
<PackageVersion Include="Verify.Xunit" Version="28.7.0" />
<PackageVersion Include="Verify.XunitV3" Version="28.6.0" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.v3" Version="1.0.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />

<!-- Pin nuget transitive packages vulnerability issues NuGet.Packaging -->
Expand Down

0 comments on commit 7217373

Please sign in to comment.