Skip to content

Commit

Permalink
Add async fluent builder feature to TestPublisher (#5934)
Browse files Browse the repository at this point in the history
* Add async fluent builder feature to TestPublisher

* Revert build.fsx changes
  • Loading branch information
Arkatufus authored May 11, 2022
1 parent 9f04b7d commit 8e79294
Show file tree
Hide file tree
Showing 10 changed files with 860 additions and 224 deletions.
67 changes: 23 additions & 44 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,34 +241,27 @@ Target "RunTests" (fun _ ->
| true -> !! "./src/**/*.Tests.*sproj"
++ "./src/**/Akka.Streams.Tests.TCK.csproj"
-- "./src/**/*.Tests.MultiNode.csproj"
-- "./src/**/*.Tests.Performance.csproj"
-- "./src/examples/**"
| _ -> !! "./src/**/*.Tests.*sproj" // if you need to filter specs for Linux vs. Windows, do it here
-- "./src/**/*.Tests.MultiNode.csproj"
-- "./src/**/*.Tests.Performance.csproj"
-- "./src/examples/**"
rawProjects |> Seq.choose filterProjects

let projectDlls = projects |> Seq.map ( fun project ->
let assemblyName = fileNameWithoutExt project
(directory project) @@ "bin" @@ "Release" @@ testNetFrameworkVersion @@ assemblyName + ".dll"
)

let runSingleProject projectDll =
let runSingleProject project =
let arguments =
match (hasTeamCity) with
| true -> (sprintf "test \"%s\" --blame-crash --blame-hang-timeout 25m -l:trx -l:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -teamcity" projectDll testNetFrameworkVersion outputTests)
| false -> (sprintf "test \"%s\" --blame-crash --blame-hang-timeout 25m -l:trx -l:\"console;verbosity=normal\" --framework %s --results-directory \"%s\"" projectDll testNetFrameworkVersion outputTests)
| true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none -teamcity" testNetFrameworkVersion outputTests)
| false -> (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 <- outputTests
info.WorkingDirectory <- (Directory.GetParent project).FullName
info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0)

ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result

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

Target "RunTestsNetCore" (fun _ ->
Expand All @@ -278,34 +271,27 @@ Target "RunTestsNetCore" (fun _ ->
| true -> !! "./src/**/*.Tests.*sproj"
++ "./src/**/Akka.Streams.Tests.TCK.csproj"
-- "./src/**/*.Tests.MultiNode.csproj"
-- "./src/**/*.Tests.Performance.csproj"
-- "./src/examples/**"
| _ -> !! "./src/**/*.Tests.*sproj" // if you need to filter specs for Linux vs. Windows, do it here
-- "./src/**/*.Tests.MultiNode.csproj"
-- "./src/**/*.Tests.Performance.csproj"
-- "./src/examples/**"
rawProjects |> Seq.choose filterProjects

let projectDlls = projects |> Seq.map ( fun project ->
let assemblyName = fileNameWithoutExt project
(directory project) @@ "bin" @@ "Release" @@ testNetCoreVersion @@ assemblyName + ".dll"
)

let runSingleProject projectDll =
let runSingleProject project =
let arguments =
match (hasTeamCity) with
| true -> (sprintf "test \"%s\" --blame-crash --blame-hang-timeout 25m -l:trx -l:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -teamcity" projectDll testNetCoreVersion outputTests)
| false -> (sprintf "test \"%s\" --blame-crash --blame-hang-timeout 25m -l:trx -l:\"console;verbosity=normal\" --framework %s --results-directory \"%s\"" projectDll testNetCoreVersion outputTests)
| true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none -teamcity" testNetCoreVersion outputTests)
| false -> (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 <- outputTests
info.WorkingDirectory <- (Directory.GetParent project).FullName
info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0)

ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result

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

Target "RunTestsNet" (fun _ ->
Expand All @@ -315,34 +301,27 @@ Target "RunTestsNet" (fun _ ->
| true -> !! "./src/**/*.Tests.*sproj"
++ "./src/**/Akka.Streams.Tests.TCK.csproj"
-- "./src/**/*.Tests.MultiNode.csproj"
-- "./src/**/*.Tests.Performance.csproj"
-- "./src/examples/**"
| _ -> !! "./src/**/*.Tests.*sproj" // if you need to filter specs for Linux vs. Windows, do it here
-- "./src/**/*.Tests.MultiNode.csproj"
-- "./src/**/*.Tests.Performance.csproj"
-- "./src/examples/**"
rawProjects |> Seq.choose filterProjects

let projectDlls = projects |> Seq.map ( fun project ->
let assemblyName = fileNameWithoutExt project
(directory project) @@ "bin" @@ "Release" @@ testNetVersion @@ assemblyName + ".dll"
)

let runSingleProject projectDll =
let runSingleProject project =
let arguments =
match (hasTeamCity) with
| true -> (sprintf "test \"%s\" --blame-crash --blame-hang-timeout 25m -l:trx -l:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -teamcity" projectDll testNetVersion outputTests)
| false -> (sprintf "test \"%s\" --blame-crash --blame-hang-timeout 25m -l:trx -l:\"console;verbosity=normal\" --framework %s --results-directory \"%s\"" projectDll testNetVersion outputTests)
| true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none -teamcity" testNetVersion outputTests)
| false -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetVersion outputTests)

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

ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result

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

Target "MultiNodeTestsNetCore" (fun _ ->
Expand All @@ -363,13 +342,13 @@ Target "MultiNodeTestsNetCore" (fun _ ->
let runSingleProject projectDll =
let arguments =
match (hasTeamCity) with
| true -> (sprintf "test \"%s\" -l:trx -l:\"console;verbosity=detailed\" --framework %s --results-directory \"%s\" -- -teamcity" projectDll testNetCoreVersion outputMultiNode)
| false -> (sprintf "test \"%s\" -l:trx -l:\"console;verbosity=detailed\" --framework %s --results-directory \"%s\"" projectDll testNetCoreVersion outputMultiNode)
| true -> (sprintf "test \"%s\" -l:\"console;verbosity=detailed\" --framework %s --results-directory \"%s\" -- -teamcity" projectDll testNetCoreVersion outputMultiNode)
| false -> (sprintf "test \"%s\" -l:\"console;verbosity=detailed\" --framework %s --results-directory \"%s\"" projectDll testNetCoreVersion outputMultiNode)

let resultPath = (directory projectDll)
File.WriteAllText(
(resultPath @@ "xunit.multinode.runner.json"),
(sprintf "{\"outputDirectory\":\"%s\"}" outputMultiNode).Replace("\\", "\\\\"))
(sprintf "{\"outputDirectory\":\"%s\", \"useBuiltInTrxReporter\":true}" outputMultiNode).Replace("\\", "\\\\"))

let result = ExecProcess(fun info ->
info.FileName <- "dotnet"
Expand Down Expand Up @@ -402,13 +381,13 @@ Target "MultiNodeTestsNet" (fun _ ->
let runSingleProject projectDll =
let arguments =
match (hasTeamCity) with
| true -> (sprintf "test \"%s\" -l:trx -l:\"console;verbosity=detailed\" --framework %s --results-directory \"%s\" -- -teamcity" projectDll testNetVersion outputMultiNode)
| false -> (sprintf "test \"%s\" -l:trx -l:\"console;verbosity=detailed\" --framework %s --results-directory \"%s\"" projectDll testNetVersion outputMultiNode)
| true -> (sprintf "test \"%s\" -l:\"console;verbosity=detailed\" --framework %s --results-directory \"%s\" -- -teamcity" projectDll testNetVersion outputMultiNode)
| false -> (sprintf "test \"%s\" -l:\"console;verbosity=detailed\" --framework %s --results-directory \"%s\"" projectDll testNetVersion outputMultiNode)

let resultPath = (directory projectDll)
File.WriteAllText(
(resultPath @@ "xunit.multinode.runner.json"),
(sprintf "{\"outputDirectory\":\"%s\"}" outputMultiNode).Replace("\\", "\\\\"))
(sprintf "{\"outputDirectory\":\"%s\", \"useBuiltInTrxReporter\":true}" outputMultiNode).Replace("\\", "\\\\"))

let result = ExecProcess(fun info ->
info.FileName <- "dotnet"
Expand Down
Loading

0 comments on commit 8e79294

Please sign in to comment.