Skip to content

Commit

Permalink
cpu limit in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
majocha committed Oct 6, 2024
1 parent 6936121 commit c632695
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 14 deletions.
11 changes: 8 additions & 3 deletions eng/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,18 @@ function TestUsingMSBuild([string] $testProject, [string] $targetFramework, [str
}
}

function TestSolutionUsingMSBuild([string] $testSolution, [string] $targetFramework, [string] $testadapterpath) {
function TestSolutionUsingMSBuild([string] $testSolution, [string] $targetFramework, [string] $testadapterpath, [int] $maxCpuCount = 1) {
$dotnetPath = InitializeDotNetCli
$dotnetExe = Join-Path $dotnetPath "dotnet.exe"
$solutionName = [System.IO.Path]::GetFileNameWithoutExtension($testSolution)
$testLogPath = "$ArtifactsDir\TestResults\$configuration\{assembly}.{framework}.xml"
$testBinLogPath = "$LogDir\${solutionName}_$targetFramework.binlog"
$args = "test -m:1 $testSolution -c $configuration -f $targetFramework --test-adapter-path $testadapterpath -v n --logger ""xunit;LogFilePath=$testLogPath"" /bl:$testBinLogPath"
$cpuLimit = ""
if ($ci) {
$cpuLimit = "-m:$maxCpuCount"
}

$args = "test $cpuLimit $testSolution -c $configuration -f $targetFramework --test-adapter-path $testadapterpath -v n --logger ""xunit;LogFilePath=$testLogPath"" /bl:$testBinLogPath"
$args += " --blame --blame-hang-timeout 5minutes --results-directory $ArtifactsDir\TestResults\$configuration"

if (-not $noVisualStudio -or $norestore) {
Expand Down Expand Up @@ -614,7 +619,7 @@ try {
}

if ($testDesktop) {
TestSolutionUsingMSBuild -testSolution "$RepoRoot\FSharp.sln" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\"
TestSolutionUsingMSBuild -testSolution "$RepoRoot\FSharp.sln" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -maxCpuCount 3
}

if ($testFSharpQA) {
Expand Down
2 changes: 1 addition & 1 deletion eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function Test() {
projectname=$(basename -- "$testproject")
projectname="${projectname%.*}"
testlogpath="$artifacts_dir/TestResults/$configuration/${projectname}_$targetframework.xml"
args="test \"$testproject\" --no-restore --no-build -c $configuration -f $targetframework --test-adapter-path . --logger \"xunit;LogFilePath=$testlogpath\" --blame --blame-hang-timeout 5minutes --results-directory $artifacts_dir/TestResults/$configuration -p:vstestusemsbuildoutput=false"
args="test \"$testproject\" --no-restore --no-build -c $configuration -f $targetframework --test-adapter-path . --logger \"xunit;LogFilePath=$testlogpath\" --blame --blame-hang-timeout 5minutes --results-directory $artifacts_dir/TestResults/$configuration -p:vstestusemsbuildoutput=false -- xUnit.MaxparallelThreads=2"
"$DOTNET_INSTALL_DIR/dotnet" $args || exit $?
}

Expand Down
6 changes: 6 additions & 0 deletions tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
<Compile Include="MapSourceRootsTests.fs" />
</ItemGroup>

<ItemGroup>
<Content Include="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(FSharpSourcesRoot)\FSharp.Build\FSharp.Build.fsproj" />
<ProjectReference Include="$(FSharpSourcesRoot)\FSharp.Core\FSharp.Core.fsproj" />
Expand Down
5 changes: 5 additions & 0 deletions tests/FSharp.Build.UnitTests/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"appDomain": "denied",
"parallelizeAssembly": true
}
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.ComponentTests/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"shadowCopy": false,
"appDomain": "denied",
"parallelizeAssembly": true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"shadowCopy": false,
"appDomain": "denied",
"parallelizeAssembly": true
}
5 changes: 2 additions & 3 deletions tests/FSharp.Compiler.Service.Tests/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"shadowCopy": false,
"parallelizeAssembly": true,
"maxParallelThreads": "4.0x"
"appDomain": "denied",
"parallelizeAssembly": true
}
2 changes: 1 addition & 1 deletion tests/FSharp.Core.UnitTests/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"shadowCopy": false,
"appDomain": "denied",
"parallelizeAssembly": true
}
2 changes: 1 addition & 1 deletion tests/FSharp.Test.Utilities/CompilerAssert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ module CompilerAssertHelpers =
deps
|> List.tryFind (fun (x: string) -> Path.GetFileNameWithoutExtension x = name.Name)
|> Option.map ctxt.LoadFromAssemblyPath
|> Option.defaultValue null)
|> Option.toObj)

executeAssemblyEntryPoint (ctxt.LoadFromAssemblyPath assemblyPath) isFsx
finally
Expand Down
2 changes: 0 additions & 2 deletions tests/FSharp.Test.Utilities/XunitHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ type TestRun(sink) =
// Try to release files locked by AssemblyLoadContext, AppDomains etc.
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()

testRunFinishedEvent.Trigger()
base.Dispose()
2 changes: 1 addition & 1 deletion tests/fsharp/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"shadowCopy": false,
"appDomain": "denied",
"parallelizeAssembly": true
}

0 comments on commit c632695

Please sign in to comment.