Skip to content

Commit

Permalink
Modify build.fsx dotnet test to target the assembly dll directly inst…
Browse files Browse the repository at this point in the history
…ead of targetting the .csproj file (#5924)
  • Loading branch information
Arkatufus authored May 6, 2022
1 parent f8053b9 commit 2662a64
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,26 @@ Target "RunTests" (fun _ ->
-- "./src/examples/**"
rawProjects |> Seq.choose filterProjects

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

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

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

ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result

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

Target "RunTestsNetCore" (fun _ ->
Expand All @@ -277,21 +282,26 @@ Target "RunTestsNetCore" (fun _ ->
-- "./src/examples/**"
rawProjects |> Seq.choose filterProjects

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

let runSingleProject projectDll =
let arguments =
match (hasTeamCity) with
| true -> (sprintf "test -c Release --blame --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none -teamcity" testNetCoreVersion outputTests)
| false -> (sprintf "test -c Release --blame --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetCoreVersion outputTests)
| 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)

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

ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result

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

Target "RunTestsNet" (fun _ ->
Expand All @@ -307,21 +317,26 @@ Target "RunTestsNet" (fun _ ->
-- "./src/examples/**"
rawProjects |> Seq.choose filterProjects

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

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

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

ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result

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

Target "MultiNodeTestsNetCore" (fun _ ->
Expand Down

0 comments on commit 2662a64

Please sign in to comment.