Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Xunit #52

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a38abc3
Add xunit and Xunit.SkippableFact, replace [Test] with [SkippableFact]
Arkatufus Aug 21, 2020
14ecb1d
Replace IgnoreException with SkipException
Arkatufus Aug 21, 2020
e2c1ae3
Replace `Assert.Ignore` with `TckAssert.Skip` and `Assert.Fail` with …
Arkatufus Aug 21, 2020
6e56e66
replace Assert functions to the equivalent version in Xunit
Arkatufus Aug 21, 2020
56e9f3e
Add `Assert.Fail` and `Assert.Ignore` support
Arkatufus Aug 21, 2020
08db990
Remove TextFixtureAttribute
Arkatufus Aug 21, 2020
ce6f42e
Add ITestOutputHelper support
Arkatufus Aug 21, 2020
72e080b
Fix OptionalActivePublisherTest, it was eating all exceptions
Arkatufus Aug 21, 2020
d484a57
Turn on netcoreapp3.1 testing
Arkatufus Aug 21, 2020
1c4a538
Update build script to dotnet 3.1.105 LTS, add RunTestsDotNet build args
Arkatufus Aug 21, 2020
feb6247
Merge branch 'master' into Update_to_Xunit
Arkatufus May 17, 2021
d9b05e3
Update framework targets and package versions
Arkatufus May 17, 2021
3e2e02f
Add xunit and Xunit.SkippableFact, replace [Test] with [SkippableFact]
Arkatufus Aug 21, 2020
2c21b07
Replace IgnoreException with SkipException
Arkatufus Aug 21, 2020
4c56cd0
Replace `Assert.Ignore` with `TckAssert.Skip` and `Assert.Fail` with …
Arkatufus Aug 21, 2020
9fa653e
replace Assert functions to the equivalent version in Xunit
Arkatufus Aug 21, 2020
a6cb650
Add `Assert.Fail` and `Assert.Ignore` support
Arkatufus Aug 21, 2020
5b50b7b
Remove TextFixtureAttribute
Arkatufus Aug 21, 2020
ab53717
Add ITestOutputHelper support
Arkatufus Aug 21, 2020
49fd87e
Fix OptionalActivePublisherTest, it was eating all exceptions
Arkatufus Aug 21, 2020
044a695
Turn on netcoreapp3.1 testing
Arkatufus Aug 21, 2020
3a7436a
Update build script to dotnet 3.1.105 LTS, add RunTestsDotNet build args
Arkatufus Aug 21, 2020
3a85e83
Added me to relicensing file
marcpiechura Aug 19, 2020
de965e7
Signed relicensing doc
cconstantin Aug 20, 2020
a5466f9
Update Relicensing.txt
alexvaluyskiy Sep 9, 2020
1093ff0
Port NUnit to XUnit, update target frameworks to netstandard2.0 and n…
viktorklang Oct 29, 2020
635332b
Update framework targets and package versions
Arkatufus May 17, 2021
b566ecf
Merge branch 'Update_to_Xunit' of github.com:Arkatufus/reactive-strea…
Arkatufus May 17, 2021
94e485b
Added copyright
alexvaluyskiy Mar 14, 2017
abd4803
Fix missing Cancel() in tests that don't consume the entire source (#32)
akarnokd Mar 27, 2017
c0225ec
Update CopyrightWaivers.txt
akarnokd Mar 18, 2017
83730c7
Skip §2.13 for value types (#34)
Apr 1, 2017
d45bfa5
fail if timeout is reached
marcpiechura Apr 1, 2017
2b34b05
1.0.0 stable release (#28)
Apr 5, 2017
36ebf21
bump version
Apr 7, 2017
5d687fc
Add the 'I' prefix to component names
akarnokd Apr 5, 2017
d8964c0
Update AsyncSubscriber.cs
Megasware128 Jun 29, 2017
dac6326
Added xml documentation (#42)
alexvaluyskiy Aug 8, 2017
a819a0e
Preparing for relicensing to MIT-0
viktorklang Aug 12, 2020
785397d
Update Relicensing.txt
akarnokd Aug 12, 2020
b68530b
Add xunit and Xunit.SkippableFact, replace [Test] with [SkippableFact]
Arkatufus Aug 21, 2020
fbf7f35
Replace IgnoreException with SkipException
Arkatufus Aug 21, 2020
39d5b7b
Replace `Assert.Ignore` with `TckAssert.Skip` and `Assert.Fail` with …
Arkatufus Aug 21, 2020
463a68c
replace Assert functions to the equivalent version in Xunit
Arkatufus Aug 21, 2020
380a841
Add `Assert.Fail` and `Assert.Ignore` support
Arkatufus Aug 21, 2020
f43349c
Remove TextFixtureAttribute
Arkatufus Aug 21, 2020
7fd7136
Add ITestOutputHelper support
Arkatufus Aug 21, 2020
5ff3cba
Fix OptionalActivePublisherTest, it was eating all exceptions
Arkatufus Aug 21, 2020
bc73d6b
Turn on netcoreapp3.1 testing
Arkatufus Aug 21, 2020
79008d1
Update build script to dotnet 3.1.105 LTS, add RunTestsDotNet build args
Arkatufus Aug 21, 2020
07b7f26
Added me to relicensing file
marcpiechura Aug 19, 2020
b9fb096
Signed relicensing doc
cconstantin Aug 20, 2020
5ec79c5
Update Relicensing.txt
alexvaluyskiy Sep 9, 2020
2ff6255
Port NUnit to XUnit, update target frameworks to netstandard2.0 and n…
viktorklang Oct 29, 2020
68ef99a
Update framework targets and package versions
Arkatufus May 17, 2021
b45555b
Add xunit and Xunit.SkippableFact, replace [Test] with [SkippableFact]
Arkatufus Aug 21, 2020
9c99de1
Merge branch 'Update_to_Xunit' of github.com:Arkatufus/reactive-strea…
Arkatufus May 17, 2021
16412fd
Update target frameworks
Arkatufus May 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,5 @@ UpgradeLog*.htm
.dotnet/

# Tools
tools/
tools/
src/.vs/
126 changes: 94 additions & 32 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ let output = __SOURCE_DIRECTORY__ @@ "build"
let outputTests = output @@ "TestResults"
let outputBinaries = output @@ "binaries"
let outputNuGet = output @@ "nuget"
let outputBinariesNet45 = outputBinaries @@ "net45"
let outputBinariesNetStandard = outputBinaries @@ "netstandard1.0"
let outputBinariesNet45 = outputBinaries @@ "net452"
let outputBinariesNetStandard = outputBinaries @@ "netstandard2.0"

// Configuration values for tests
let testNetFrameworkVersion = "net461"
let testNetCoreVersion = "netcoreapp3.1"

Target "Clean" (fun _ ->
CleanDir output
Expand Down Expand Up @@ -61,17 +65,63 @@ Target "Build" (fun _ ->
Configuration = configuration })
)

Target "RunTests" (fun _ ->
let projects = !! "./src/**/Reactive.Streams.Example.Unicast.Tests.csproj"
++ "./src/**/Reactive.Streams.TCK.Tests.csproj"
module internal ResultHandling =
let (|OK|Failure|) = function
| 0 -> OK
| x -> Failure x

let buildErrorMessage = function
| OK -> None
| Failure errorCode ->
Some (sprintf "xUnit2 reported an error (Error Code %d)" errorCode)

let failBuildWithMessage = function
| DontFailBuild -> traceError
| _ -> (fun m -> raise(FailedTestsException m))

let failBuildIfXUnitReportedError errorLevel =
buildErrorMessage
>> Option.iter (failBuildWithMessage errorLevel)

Target "RunTests" (fun _ ->
let projects =
match (isWindows) with
| true -> !! "./src/**/*.Tests.*sproj"
| _ -> !! "./src/**/*.Tests.*sproj" // if you need to filter specs for Linux vs. Windows, do it here

let runSingleProject project =
let arguments =
(sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetFrameworkVersion outputTests)

let result = ExecProcess(fun info ->
info.FileName <- "dotnet"
info.WorkingDirectory <- (Directory.GetParent project).FullName
info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0)

ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result

CreateDir outputTests
projects |> Seq.iter (runSingleProject)
)

Target "RunTestsNetCore" (fun _ ->
let projects =
match (isWindows) with
| true -> !! "./src/**/*.Tests.*sproj"
| _ -> !! "./src/**/*.Tests.*sproj" // if you need to filter specs for Linux vs. Windows, do it here

let runSingleProject project =
DotNetCli.Test
(fun p ->
{ p with
Project = project
Configuration = configuration })
let arguments =
(sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetCoreVersion outputTests)

let result = ExecProcess(fun info ->
info.FileName <- "dotnet"
info.WorkingDirectory <- (Directory.GetParent project).FullName
info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0)

ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result

CreateDir outputTests
projects |> Seq.iter (runSingleProject)
)

Expand Down Expand Up @@ -102,19 +152,28 @@ Target "CreateNuget" (fun _ ->
)

Target "PublishNuget" (fun _ ->
let projects = !! "./build/nuget/*.nupkg" -- "./build/nuget/*.symbols.nupkg"
let apiKey = getBuildParamOrDefault "nugetkey" ""
let source = getBuildParamOrDefault "nugetpublishurl" ""
let symbolSource = getBuildParamOrDefault "symbolspublishurl" ""

let runSingleProject project =
DotNetCli.RunCommand
(fun p ->
{ p with
TimeOut = TimeSpan.FromMinutes 10. })
(sprintf "nuget push %s --api-key %s --source %s --symbol-source %s" project apiKey source symbolSource)

projects |> Seq.iter (runSingleProject)
let rec publishPackage url apiKey trialsLeft packageFile =
tracefn "Pushing %s Attempts left: %d" (FullName packageFile) trialsLeft
try
DotNetCli.RunCommand
(fun p ->
{ p with
TimeOut = TimeSpan.FromMinutes 10. })
(sprintf "nuget push %s --api-key %s --source %s" packageFile apiKey url)
with exn ->
if (trialsLeft > 0) then (publishPackage url apiKey (trialsLeft-1) packageFile)
else raise exn

let shouldPushNugetPackages = hasBuildParam "nugetkey"

if (shouldPushNugetPackages) then
printfn "Pushing nuget packages"
let projects = !! "./build/nuget/*.nupkg" -- "./build/nuget/*.symbols.nupkg"
for package in projects do
try
publishPackage (getBuildParamOrDefault "nugetpublishurl" "https://api.nuget.org/v3/index.json") (getBuildParam "nugetkey") 3 package
with exn ->
printfn "%s" exn.Message
)

//--------------------------------------------------------------------------------
Expand All @@ -127,10 +186,11 @@ Target "Help" <| fun _ ->
"/build [target]"
""
" Targets for building:"
" * Build Builds"
" * Nuget Create and optionally publish nugets packages"
" * RunTests Runs tests"
" * All Builds, run tests, creates and optionally publish nuget packages"
" * Build Builds"
" * Nuget Create and optionally publish nugets packages"
" * RunTests Runs .NET Framework tests"
" * RunTestsNetCore Runs .NET Core tests"
" * All Builds, run tests, creates and optionally publish nuget packages"
""
" Other Targets"
" * Help Display this help"
Expand Down Expand Up @@ -175,18 +235,20 @@ Target "All" DoNothing
Target "Nuget" DoNothing

// build dependencies
"Clean" ==> "RestorePackages" ==> "Build" ==> "BuildRelease"
"Clean" ==> "RestorePackages" ==> "Build"
"Build" ==> "BuildRelease"

// tests dependencies
"Clean" ==> "RestorePackages" ==> "Build" ==> "RunTests"
"Build" ==> "RunTests"
"Build" ==> "RunTestsNetCore"

// nuget dependencies
"Clean" ==> "RestorePackages" ==> "Build" ==> "CreateNuget"
"CreateNuget" ==> "PublishNuget"
"PublishNuget" ==> "Nuget"
"BuildRelease" ==> "CreateNuget" ==> "PublishNuget" ==> "Nuget"

// all
"BuildRelease" ==> "All"
"RunTests" ==> "All"
"RunTestsNetCore" ==> "All"
"CreateNuget" ==> "All"

RunTargetOrDefault "Help"
25 changes: 5 additions & 20 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ Param(
[string[]]$ScriptArgs
)

$FakeVersion = "4.57.4"
$NUnitVersion = "3.6.0"
$DotNetChannel = "preview";
$DotNetVersion = "1.0.0";
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1";
$NugetVersion = "4.1.0";
$FakeVersion = "4.63.0"
$DotNetChannel = "LTS";
$DotNetVersion = "3.1.105";
$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1";
$NugetVersion = "4.3.0";
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/v$NugetVersion/nuget.exe"

# Make sure tools folder exists
Expand Down Expand Up @@ -111,20 +110,6 @@ if (!(Test-Path $FakeExePath)) {
}
}

###########################################################################
# INSTALL NUnit3 Test Runner
###########################################################################

# Make sure NUnit3 Test Runner has been installed.
$NUnitDllPath = Join-Path $ToolPath "NUnit.ConsoleRunner/tools/nunit3-console.exe"
if (!(Test-Path $NUnitDllPath)) {
Write-Host "Installing NUnit3 Runner..."
Invoke-Expression "&`"$NugetPath`" install NUnit.ConsoleRunner -ExcludeVersion -Version $NUnitVersion -OutputDirectory `"$ToolPath`"" | Out-Null;
if ($LASTEXITCODE -ne 0) {
Throw "An error occured while restoring NUnit3 Test from NuGet."
}
}

###########################################################################
# RUN BUILD SCRIPT
###########################################################################
Expand Down
18 changes: 11 additions & 7 deletions src/Reactive.Streams.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.30204.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams", "api\Reactive.Streams\Reactive.Streams.csproj", "{68FBB4DF-6D83-4CF1-8105-A1D41912852F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reactive.Streams", "api\Reactive.Streams\Reactive.Streams.csproj", "{68FBB4DF-6D83-4CF1-8105-A1D41912852F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{97BE0CEB-2816-47E9-ABC3-78905582A882}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -17,16 +17,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{D389959C
ProjectSection(SolutionItems) = preProject
..\build.cmd = ..\build.cmd
..\build.fsx = ..\build.fsx
..\build.ps1 = ..\build.ps1
..\build.sh = ..\build.sh
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams.TCK", "tck\Reactive.Streams.TCK\Reactive.Streams.TCK.csproj", "{7DBE1261-04EB-4DA7-9953-C8E8CCC49010}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reactive.Streams.TCK", "tck\Reactive.Streams.TCK\Reactive.Streams.TCK.csproj", "{7DBE1261-04EB-4DA7-9953-C8E8CCC49010}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams.TCK.Tests", "tck\Reactive.Streams.TCK.Tests\Reactive.Streams.TCK.Tests.csproj", "{0F1C51EB-3554-487F-8CE4-75CAAD2887F8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reactive.Streams.TCK.Tests", "tck\Reactive.Streams.TCK.Tests\Reactive.Streams.TCK.Tests.csproj", "{0F1C51EB-3554-487F-8CE4-75CAAD2887F8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams.Example.Unicast", "examples\Reactive.Streams.Example.Unicast\Reactive.Streams.Example.Unicast.csproj", "{01737D0D-ED40-499B-A706-12BE9847491B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reactive.Streams.Example.Unicast", "examples\Reactive.Streams.Example.Unicast\Reactive.Streams.Example.Unicast.csproj", "{01737D0D-ED40-499B-A706-12BE9847491B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams.Example.Unicast.Tests", "examples\Reactive.Streams.Example.Unicast.Tests\Reactive.Streams.Example.Unicast.Tests.csproj", "{A69C5115-5E39-47ED-B8EF-83A342968999}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reactive.Streams.Example.Unicast.Tests", "examples\Reactive.Streams.Example.Unicast.Tests\Reactive.Streams.Example.Unicast.Tests.csproj", "{A69C5115-5E39-47ED-B8EF-83A342968999}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{47E4C672-A6E8-43FE-A03E-761BC4601F84}"
EndProject
Expand Down Expand Up @@ -71,4 +72,7 @@ Global
{01737D0D-ED40-499B-A706-12BE9847491B} = {6CCDDC32-BD9D-4767-BF9A-64275D330558}
{A69C5115-5E39-47ED-B8EF-83A342968999} = {6CCDDC32-BD9D-4767-BF9A-64275D330558}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {33BB0CD0-DB06-47D3-8BDE-FB0ECFA5ACC2}
EndGlobalSection
EndGlobal
3 changes: 1 addition & 2 deletions src/api/Reactive.Streams/Reactive.Streams.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
<Copyright>MIT-0</Copyright>
<VersionPrefix>1.0.3</VersionPrefix>
<Authors>Reactive Streams</Authors>
<TargetFrameworks>netstandard1.0;net45</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PackageTags>reactive;stream</PackageTags>
<PackageProjectUrl>https://github.com/reactive-streams/reactive-streams-dotnet</PackageProjectUrl>
<PackageLicenseUrl>http://creativecommons.org/publicdomain/zero/1.0/</PackageLicenseUrl>
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
***************************************************/
using System;
using System.Threading;
using NUnit.Framework;
using Xunit;
using Xunit.Abstractions;
using Reactive.Streams.TCK;
using Reactive.Streams.TCK.Support;

namespace Reactive.Streams.Example.Unicast.Tests
{
[TestFixture]
public class AsyncSubscriberTest : SubscriberBlackboxVerification<int?>
{
public AsyncSubscriberTest() : base(new TestEnvironment())
public AsyncSubscriberTest(ITestOutputHelper output) : base(new TestEnvironment(output))
{
}

Expand All @@ -25,15 +25,15 @@ private sealed class Suscriber : AsyncSubscriber<int?>
protected override bool WhenNext(int? element) => true;
}

[Test]
[SkippableFact]
public void TestAccumulation()
{
var i = new AtomicCounterLong(0);
var latch = new CountdownEvent(1);
var subscriber = new AccSubscriber(i, latch);
new NumberIterablePublisher(0,10).Subscribe(subscriber);
latch.Wait(TimeSpan.FromMilliseconds(Environment.DefaultTimeoutMilliseconds*10));
Assert.AreEqual(45, i.Current);
Assert.Equal(45, i.Current);
}

private sealed class AccSubscriber : AsyncSubscriber<int?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using Xunit;
using Xunit.Abstractions;
using Reactive.Streams.TCK;

namespace Reactive.Streams.Example.Unicast.Tests
{
[TestFixture]
public class IterablePublisherTest : PublisherVerification<int?>
{
public IterablePublisherTest() : base(new TestEnvironment())
public IterablePublisherTest(ITestOutputHelper output) : base(new TestEnvironment(output))
{
}

public override IPublisher<int?> CreatePublisher(long elements)
{
Assert.LessOrEqual(elements, MaxElementsFromPublisher);
Assert.True(elements <= MaxElementsFromPublisher);
//Assert.LessOrEqual(elements, MaxElementsFromPublisher);
return new NumberIterablePublisher(0, (int)elements);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Reactive.Streams.Example.Unicast.Tests</AssemblyName>
<TargetFrameworks>net45</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>

Expand All @@ -12,9 +12,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="NUnit" Version="3.7.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.utility" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
Loading