From 43bcb29ca5dd0958db7636133d92b60eb61cd9a6 Mon Sep 17 00:00:00 2001 From: Petr <psfinaki@users.noreply.github.com> Date: Fri, 28 Jun 2024 01:30:47 +0200 Subject: [PATCH 1/3] Simplify test-related scripts (#17333) * simplify * remove dead param * simplify * adapter * Simplify sh also * up * Okay logger should stay * Update AssemblyContentProviderTests.fs --- eng/Build.ps1 | 72 ++++++++----------- eng/build.sh | 26 +++---- .../AssemblyContentProviderTests.fs | 10 +-- 3 files changed, 43 insertions(+), 65 deletions(-) diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 104353203df..4f6d3b767b5 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -354,7 +354,7 @@ function VerifyAssemblyVersionsAndSymbols() { } } -function TestUsingMSBuild([string] $testProject, [string] $targetFramework, [string]$testadapterpath, [boolean] $noTestFilter = $false, [boolean] $asBackgroundJob = $false) { +function TestUsingMSBuild([string] $testProject, [string] $targetFramework, [string]$testadapterpath, [boolean] $asBackgroundJob = $false) { $dotnetPath = InitializeDotNetCli $dotnetExe = Join-Path $dotnetPath "dotnet.exe" $projectName = [System.IO.Path]::GetFileNameWithoutExtension($testProject) @@ -371,10 +371,6 @@ function TestUsingMSBuild([string] $testProject, [string] $targetFramework, [str $args += " --no-build" } - if ($env:RunningAsPullRequest -ne "true" -and $noTestFilter -eq $false) { - $args += " --filter TestCategory!=PullRequest" - } - if ($asBackgroundJob) { Write-Host("Starting on the background: $args") Write-Host("------------------------------------") @@ -391,14 +387,6 @@ function TestUsingMSBuild([string] $testProject, [string] $targetFramework, [str } } -function TestUsingXUnit([string] $testProject, [string] $targetFramework, [string]$testadapterpath, [boolean] $asBackgroundJob = $false) { - TestUsingMsBuild -testProject $testProject -targetFramework $targetFramework -testadapterpath $testadapterpath -noTestFilter $true -asBackgroundJob $asBackgroundJob -} - -function TestUsingNUnit([string] $testProject, [string] $targetFramework, [string]$testadapterpath, [boolean] $asBackgroundJob = $false) { - TestUsingMsBuild -testProject $testProject -targetFramework $targetFramework -testadapterpath $testadapterpath -noTestFilter $false -asBackgroundJob $asBackgroundJob -} - function Prepare-TempDir() { Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.props") $TempDir Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.targets") $TempDir @@ -593,13 +581,13 @@ try { $script:BuildMessage = "Failure running tests" if ($testCoreClr) { - $bgJob = TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true + $bgJob = TestUsingMSBuild -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" # Collect output from background jobs Wait-job $bgJob | out-null @@ -607,13 +595,13 @@ try { } if ($testDesktop) { - $bgJob = TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true + $bgJob = TestUsingMSBuild -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" # Collect output from background jobs Wait-job $bgJob | out-null @@ -648,46 +636,46 @@ try { } if ($testFSharpCore) { - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" } if ($testCompiler) { - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" } if ($testCompilerComponentTests) { - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" } if ($testCompilerService) { - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" } if ($testCambridge) { - TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" - TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" } if ($testScripting) { - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" } if ($testVs -and -not $noVisualStudio) { - TestUsingXUnit -testProject "$RepoRoot\vsintegration\tests\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj" - TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\VisualFSharp.UnitTests\" + TestUsingMSBuild -testProject "$RepoRoot\vsintegration\tests\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj" + TestUsingMSBuild -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\VisualFSharp.UnitTests\" } if ($testIntegration) { - TestUsingXUnit -testProject "$RepoRoot\vsintegration\tests\FSharp.Editor.IntegrationTests\FSharp.Editor.IntegrationTests.csproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Editor.IntegrationTests\" + TestUsingMSBuild -testProject "$RepoRoot\vsintegration\tests\FSharp.Editor.IntegrationTests\FSharp.Editor.IntegrationTests.csproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Editor.IntegrationTests\" } if ($testAOT) { diff --git a/eng/build.sh b/eng/build.sh index e0a3348bfdb..ce85f543ef9 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -177,12 +177,11 @@ done # Import Arcade functions . "$scriptroot/common/tools.sh" -function TestUsingNUnit() { +function Test() { BuildCategory="Test" BuildMessage="Error running tests" testproject="" targetframework="" - notestfilter=0 while [[ $# > 0 ]]; do opt="$(echo "$1" | awk '{print tolower($0)}')" case "$opt" in @@ -194,10 +193,6 @@ function TestUsingNUnit() { targetframework=$2 shift ;; - --notestfilter) - notestfilter=1 - shift - ;; *) echo "Invalid argument: $1" exit 1 @@ -211,15 +206,10 @@ function TestUsingNUnit() { exit 1 fi - filterArgs="" - if [[ "${RunningAsPullRequest:-}" != "true" && $notestfilter == 0 ]]; then - filterArgs=" --filter TestCategory!=PullRequest" - fi - 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 \"nunit;LogFilePath=$testlogpath\"$filterArgs --blame --results-directory $artifacts_dir/TestResults/$configuration" + args="test \"$testproject\" --no-restore --no-build -c $configuration -f $targetframework --test-adapter-path . --logger \"nunit;LogFilePath=$testlogpath\" --blame --results-directory $artifacts_dir/TestResults/$configuration" "$DOTNET_INSTALL_DIR/dotnet" $args || exit $? } @@ -324,16 +314,16 @@ BuildSolution if [[ "$test_core_clr" == true ]]; then coreclrtestframework=$tfm - TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj" --targetframework $coreclrtestframework --notestfilter - TestUsingXUnit --testproject "$repo_root/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj" --targetframework $coreclrtestframework --notestfilter - TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj" --targetframework $coreclrtestframework - TestUsingXUnit --testproject "$repo_root/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj" --targetframework $coreclrtestframework - TestUsingNUnit --testproject "$repo_root/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj" --targetframework $coreclrtestframework + Test --testproject "$repo_root/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj" --targetframework $coreclrtestframework + Test --testproject "$repo_root/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj" --targetframework $coreclrtestframework + Test --testproject "$repo_root/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj" --targetframework $coreclrtestframework + Test --testproject "$repo_root/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj" --targetframework $coreclrtestframework + Test --testproject "$repo_root/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj" --targetframework $coreclrtestframework fi if [[ "$test_compilercomponent_tests" == true ]]; then coreclrtestframework=$tfm - TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj" --targetframework $coreclrtestframework --notestfilter + Test --testproject "$repo_root/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj" --targetframework $coreclrtestframework fi if [[ "$test_benchmarks" == true ]]; then diff --git a/tests/FSharp.Compiler.Service.Tests/AssemblyContentProviderTests.fs b/tests/FSharp.Compiler.Service.Tests/AssemblyContentProviderTests.fs index f20ec76253b..c237c94e024 100644 --- a/tests/FSharp.Compiler.Service.Tests/AssemblyContentProviderTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/AssemblyContentProviderTests.fs @@ -63,7 +63,7 @@ let private getSymbolMap (getSymbolProperty: AssemblySymbol -> 'a) (source: stri |> List.map (fun s -> getCleanedFullName s, getSymbolProperty s) |> Map.ofList -[<Fact>] +[<FactForDESKTOP>] let ``implicitly added Module suffix is removed``() = """ type MyType = { F: int } @@ -76,7 +76,7 @@ module MyType = "Test.MyType" "Test.MyType.func123"] -[<Fact>] +[<FactForDESKTOP>] let ``Module suffix added by an explicitly applied ModuleSuffix attribute is removed``() = """ [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] @@ -87,7 +87,7 @@ module MyType = "Test.MyType" "Test.MyType.func123" ] -[<Fact>] +[<FactForDESKTOP>] let ``Property getters and setters are removed``() = """ type MyType() = @@ -97,7 +97,7 @@ let ``Property getters and setters are removed``() = "Test.MyType" "Test.MyType.MyProperty" ] -[<Fact>] +[<FactForDESKTOP>] let ``TopRequireQualifiedAccessParent property should be valid``() = let source = """ module M1 = @@ -144,7 +144,7 @@ let ``TopRequireQualifiedAccessParent property should be valid``() = assertAreEqual (expectedResult, actual) -[<Fact>] +[<FactForDESKTOP>] let ``Check Unresolved Symbols``() = let source = """ namespace ``1 2 3`` From 4a867edde8a54f02b4f0c1d8ca7a4ca87556998a Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" <codecutter@hotmail.com> Date: Fri, 28 Jun 2024 06:33:58 -0700 Subject: [PATCH 2/3] Add --testScripting option to eng/build.sh (#17327) * arm64tests * Update build.sh --------- Co-authored-by: Petr <psfinaki@users.noreply.github.com> --- eng/build.sh | 10 ++++++++++ .../DependencyManagerInteractiveTests.fs | 12 ++++++++++++ .../FSharpScriptTests.fs | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/eng/build.sh b/eng/build.sh index ce85f543ef9..e678acefae3 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -26,6 +26,7 @@ usage() echo " --testcoreclr Run unit tests on .NET Core (short: --test, -t)" echo " --testCompilerComponentTests Run FSharp.Compiler.ComponentTests on .NET Core" echo " --testBenchmarks Build and Run Benchmark suite" + echo " --testScripting Run FSharp.Private.ScriptingTests on .NET Core" echo "" echo "Advanced settings:" echo " --ci Building in CI" @@ -60,6 +61,7 @@ publish=false test_core_clr=false test_compilercomponent_tests=false test_benchmarks=false +test_scripting=false configuration="Debug" verbosity='minimal' binary_log=false @@ -136,6 +138,9 @@ while [[ $# > 0 ]]; do --testbenchmarks) test_benchmarks=true ;; + --testscripting) + test_scripting=true + ;; --ci) ci=true ;; @@ -332,4 +337,9 @@ if [[ "$test_benchmarks" == true ]]; then popd fi +if [[ "$test_scripting" == true ]]; then + coreclrtestframework=$tfm + Test --testproject "$repo_root/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj" --targetframework $coreclrtestframework +fi + ExitWithExitCode 0 diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/DependencyManagerInteractiveTests.fs b/tests/FSharp.Compiler.Private.Scripting.UnitTests/DependencyManagerInteractiveTests.fs index 19c3009b17a..18e96ddbced 100644 --- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/DependencyManagerInteractiveTests.fs +++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/DependencyManagerInteractiveTests.fs @@ -264,6 +264,10 @@ TorchSharp.Tensor.LongTensor.From([| 0L .. 100L |]).Device [<Fact>] member _.``Use Dependency Manager to restore packages with native dependencies, build and run script that depends on the results``() = + // Skip test on arm64, because there is not an arm64 netive library + if RuntimeInformation.ProcessArchitecture = Architecture.Arm64 then + () + else let packagemanagerlines = [| "r", "Microsoft.ML,version=1.4.0-preview" "r", "Microsoft.ML.AutoML,version=0.16.0-preview" @@ -360,6 +364,10 @@ printfn ""%A"" result [<Fact>] member _.``Use NativeResolver to resolve native dlls.``() = + // Skip test on arm64, because there is not an arm64 netive library + if RuntimeInformation.ProcessArchitecture = Architecture.Arm64 then + () + else let packagemanagerlines = [| "r", "Microsoft.ML,version=1.4.0-preview" "r", "Microsoft.ML.AutoML,version=0.16.0-preview" @@ -442,6 +450,10 @@ printfn ""%A"" result [<Fact>] member _.``Use AssemblyResolver to resolve assemblies``() = + // Skip test on arm64, because there is not an arm64 netive library + if RuntimeInformation.ProcessArchitecture = Architecture.Arm64 then + () + else let packagemanagerlines = [| "r", "Microsoft.ML,version=1.4.0-preview" "r", "Microsoft.ML.AutoML,version=0.16.0-preview" diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs index 78a535c39b9..0e8175d950d 100644 --- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs +++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs @@ -247,6 +247,10 @@ System.Configuration.ConfigurationManager.AppSettings.Item "Environment" <- "LOC #if NETSTANDARD [<Fact>] member _.``ML - use assembly with native dependencies``() = + // Skip test on arm64, because there is not an arm64 netive library + if RuntimeInformation.ProcessArchitecture = Architecture.Arm64 then + () + else let code = @" #r ""nuget:Microsoft.ML,version=1.4.0-preview"" #r ""nuget:Microsoft.ML.AutoML,version=0.16.0-preview"" From df3382ce9d0d66b7e2e3830af5826b0f2dd49289 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii <vzaritovsky@hotmail.com> Date: Fri, 28 Jun 2024 16:31:16 +0200 Subject: [PATCH 3/3] .NET 9preview5 (#17224) * .NET 9preview4 * New macos + udpated prebuilts * p5 + some tests fixes * Update SourceBuildPrebuiltBaseline.xml * fix * Don't use msbuild output * Update OperatorsModuleDynamic.fs * reverting this, will be fixed separately * up * Update OperatorsModuleDynamic.fs * Revert "Update OperatorsModuleDynamic.fs" This reverts commit fc20f9e4565b82485b10fd6812fa327788d80bc4. * Update OperatorsModuleDynamic.fs * Update OperatorsModuleDynamic.fs * up * Update OperatorsModule1.fs * Update OperatorsModule2.fs * Update OperatorsModuleDynamic.fs * Update OperatorsModule1.fs * Update OperatorsModule2.fs * Update OperatorsModule2.fs * remove old workarond * Revert "remove old workarond" This reverts commit a27df0f826c01d4e353ee12d877f466a0f606339. * Update OperatorsModule2.fs * invert ifs, set up consts * comments --------- Co-authored-by: Petr <psfinaki@users.noreply.github.com> --- .devcontainer/devcontainer.json | 6 +- eng/Build.ps1 | 2 +- eng/SourceBuildPrebuiltBaseline.xml | 12 +- eng/build.sh | 2 +- global.json | 4 +- .../FSharp.Core/OperatorsModule1.fs | 32 +++- .../FSharp.Core/OperatorsModule2.fs | 137 ++++++++++---- .../FSharp.Core/OperatorsModuleDynamic.fs | 175 +++++++++++++----- 8 files changed, 274 insertions(+), 96 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8de3807c90d..03b4cb55daf 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,12 @@ // For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: { "name": "F#", - "image": "mcr.microsoft.com/dotnet/sdk:9.0.100-preview.3", + "image": "mcr.microsoft.com/dotnet/sdk:9.0.100-preview.5", "features": { - "ghcr.io/devcontainers/features/common-utils:2.4.2": {}, + "ghcr.io/devcontainers/features/common-utils:2.4.3": {}, "ghcr.io/devcontainers/features/git:1.2.0": {}, "ghcr.io/devcontainers/features/github-cli:1.0.11": {}, - "ghcr.io/devcontainers/features/dotnet:2.0.5": {} + "ghcr.io/devcontainers/features/dotnet:2.1.0": {} }, "hostRequirements": { "cpus": 2, diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 4f6d3b767b5..6003c7f7cb3 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -361,7 +361,7 @@ function TestUsingMSBuild([string] $testProject, [string] $targetFramework, [str $testLogPath = "$ArtifactsDir\TestResults\$configuration\${projectName}_$targetFramework.xml" $testBinLogPath = "$LogDir\${projectName}_$targetFramework.binlog" $args = "test $testProject -c $configuration -f $targetFramework -v n --test-adapter-path $testadapterpath --logger ""nunit;LogFilePath=$testLogPath"" /bl:$testBinLogPath" - $args += " --blame --results-directory $ArtifactsDir\TestResults\$configuration" + $args += " --blame --results-directory $ArtifactsDir\TestResults\$configuration -p:vstestusemsbuildoutput=false" if (-not $noVisualStudio -or $norestore) { $args += " --no-restore" diff --git a/eng/SourceBuildPrebuiltBaseline.xml b/eng/SourceBuildPrebuiltBaseline.xml index bd4b7f794d0..c14c248d78a 100644 --- a/eng/SourceBuildPrebuiltBaseline.xml +++ b/eng/SourceBuildPrebuiltBaseline.xml @@ -9,16 +9,16 @@ These will go away when repo updates targeting to net8.0 Tracked with https://github.com/dotnet/fsharp/issues/14765 --> - <UsagePattern IdentityGlob="Microsoft.AspNetCore.App.Ref/8.0.2" /> - <UsagePattern IdentityGlob="Microsoft.NETCore.App.Host.linux-x64/8.0.2" /> - <UsagePattern IdentityGlob="Microsoft.NETCore.App.Ref/8.0.2" /> + <UsagePattern IdentityGlob="Microsoft.AspNetCore.App.Ref/8.0.*" /> + <UsagePattern IdentityGlob="Microsoft.NETCore.App.Host.linux-x64/8.0.*" /> + <UsagePattern IdentityGlob="Microsoft.NETCore.App.Ref/8.0.*" /> <UsagePattern IdentityGlob="System.Configuration.ConfigurationManager/7.0.0" /> <UsagePattern IdentityGlob="System.Diagnostics.EventLog/7.0.0" /> <UsagePattern IdentityGlob="System.Security.Cryptography.ProtectedData/7.0.0" /> - <UsagePattern IdentityGlob="Microsoft.AspNetCore.App.Runtime.linux-x64/8.0.2" /> - <UsagePattern IdentityGlob="Microsoft.NETCore.App.Crossgen2.linux-x64/8.0.2" /> - <UsagePattern IdentityGlob="Microsoft.NETCore.App.Runtime.linux-x64/8.0.2" /> + <UsagePattern IdentityGlob="Microsoft.AspNetCore.App.Runtime.linux-x64/8.0.*" /> + <UsagePattern IdentityGlob="Microsoft.NETCore.App.Crossgen2.linux-x64/8.0.*" /> + <UsagePattern IdentityGlob="Microsoft.NETCore.App.Runtime.linux-x64/8.0.*" /> <!-- Tracked in https://github.com/dotnet/source-build/issues/3438 --> diff --git a/eng/build.sh b/eng/build.sh index e678acefae3..68a55be91e2 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -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 \"nunit;LogFilePath=$testlogpath\" --blame --results-directory $artifacts_dir/TestResults/$configuration" + args="test \"$testproject\" --no-restore --no-build -c $configuration -f $targetframework --test-adapter-path . --logger \"nunit;LogFilePath=$testlogpath\" --blame --results-directory $artifacts_dir/TestResults/$configuration -p:vstestusemsbuildoutput=false" "$DOTNET_INSTALL_DIR/dotnet" $args || exit $? } diff --git a/global.json b/global.json index ac61062b1c7..a4c3420ed66 100644 --- a/global.json +++ b/global.json @@ -1,10 +1,10 @@ { "sdk": { - "version": "9.0.100-preview.3.24204.13", + "version": "9.0.100-preview.5.24307.3", "allowPrerelease": true }, "tools": { - "dotnet": "9.0.100-preview.3.24204.13", + "dotnet": "9.0.100-preview.5.24307.3", "vs": { "version": "17.8", "components": [ diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs index a7672d9925f..727ed166b86 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs @@ -3,6 +3,10 @@ // Various tests for the: // Microsoft.FSharp.Core.Operators module +// For information on the runtime-dependent behavior differences in this file, see: +// - https://github.com/dotnet/runtime/issues/61885 +// - https://github.com/dotnet/runtime/pull/97529 + namespace FSharp.Core.UnitTests.Operators open System @@ -278,18 +282,24 @@ type OperatorsModule1() = // Overflow let result = Operators.byte Single.MinValue Assert.AreEqual(0uy, result) - + // Overflow let result = Operators.byte Single.MaxValue - Assert.AreEqual(0uy, result) - + if Info.isNetFramework then + Assert.AreEqual(0uy, result) + else + Assert.AreEqual(255uy, result) + // Overflow let result = Operators.byte Double.MinValue Assert.AreEqual(0uy, result) - + // Overflow let result = Operators.byte Double.MaxValue - Assert.AreEqual(0uy, result) + if Info.isNetFramework then + Assert.AreEqual(0uy, result) + else + Assert.AreEqual(255uy, result) // Overflow let result = Operators.byte (Int64.MaxValue * 8L) @@ -343,9 +353,15 @@ type OperatorsModule1() = // Overflow Assert.AreEqual('\000', Operators.char Single.MinValue) - Assert.AreEqual('\000', Operators.char Double.MinValue) - Assert.AreEqual('\000', Operators.char Single.MaxValue) - Assert.AreEqual('\000', Operators.char Double.MaxValue) + if Info.isNetFramework then + Assert.AreEqual('\000', Operators.char Single.MaxValue) + else + Assert.AreEqual('\uffff', Operators.char Single.MaxValue) + + if Info.isNetFramework then + Assert.AreEqual('\000', Operators.char Double.MaxValue) + else + Assert.AreEqual('\uffff', Operators.char Double.MaxValue) CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) // string type diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index d4197529ea6..57647ead9ed 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -3,6 +3,10 @@ // Various tests for the: // Microsoft.FSharp.Core.Operators module +// For information on the runtime-dependent behavior differences in this file, see: +// - https://github.com/dotnet/runtime/issues/61885 +// - https://github.com/dotnet/runtime/pull/97529 + namespace FSharp.Core.UnitTests.Operators open System @@ -53,7 +57,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int Single.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int Single.MinValue @@ -61,7 +68,10 @@ type OperatorsModule2() = // Overflow let result = Operators.int Double.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int Double.MinValue @@ -106,7 +116,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int16 Single.MaxValue - Assert.AreEqual(0s, result) + if Info.isNetFramework then + Assert.AreEqual(0s, result) + else + Assert.AreEqual(-1s, result) // Overflow let result = Operators.int16 Single.MinValue @@ -114,7 +127,10 @@ type OperatorsModule2() = // Overflow let result = Operators.int16 Double.MaxValue - Assert.AreEqual(0s, result) + if Info.isNetFramework then + Assert.AreEqual(0s, result) + else + Assert.AreEqual(-1s, result) // Overflow let result = Operators.int16 Double.MinValue @@ -158,7 +174,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int32 Single.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int32 Single.MinValue @@ -166,8 +185,11 @@ type OperatorsModule2() = // Overflow let result = Operators.int32 Double.MaxValue - Assert.AreEqual(Int32.MinValue, result) - + if Info.isNetFramework then + Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) + // Overflow let result = Operators.int32 Double.MinValue Assert.AreEqual(Int32.MinValue, result) @@ -211,7 +233,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int64 Single.MaxValue - Assert.AreEqual(Int64.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int64.MinValue, result) + else + Assert.AreEqual(Int64.MaxValue, result) // Overflow let result = Operators.int64 Single.MinValue @@ -219,7 +244,10 @@ type OperatorsModule2() = // Overflow. let result = Operators.int64 Double.MaxValue - Assert.AreEqual(Int64.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int64.MinValue, result) + else + Assert.AreEqual(Int64.MaxValue, result) // Overflow let result = Operators.int64 Double.MinValue @@ -365,8 +393,11 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual(-9223372036854775807n - 1n, result) + if Info.isNetFramework then + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + else + Assert.AreEqual(9223372036854775807n, result) // Overflow (depends on pointer size) let result = Operators.nativeint Single.MinValue @@ -381,9 +412,12 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual(-9223372036854775807n - 1n, result) - + if Info.isNetFramework then + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + else + Assert.AreEqual(9223372036854775807n, result) + // Overflow (depends on pointer size) let result = Operators.nativeint Double.MinValue if Info.isX86Runtime then @@ -414,8 +448,11 @@ type OperatorsModule2() = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual("-9223372036854775808", string result) + if Info.isNetFramework then + // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual("-9223372036854775808", string result) + else + Assert.AreEqual(9223372036854775807n, result) let result = Operators.nativeint System.Double.MinValue if Info.isX86Runtime then @@ -433,7 +470,6 @@ type OperatorsModule2() = Assert.AreEqual("-9223372036854775808", string -9223372036854775808n) Assert.AreEqual("9223372036854775807", string 9223372036854775807n) - [<Fact>] member _.not() = let result = Operators.not true @@ -445,7 +481,6 @@ type OperatorsModule2() = [<Fact>] member _.nullArg() = CheckThrowsArgumentNullException(fun () -> Operators.nullArg "A" |> ignore) - [<Fact>] member _.pown() = @@ -483,7 +518,6 @@ type OperatorsModule2() = member _.raise() = CheckThrowsArgumentException(fun () -> Operators.raise <| new ArgumentException("Invalid Argument ") |> ignore) - [<Fact>] member _.ref() = // value type @@ -596,7 +630,10 @@ type OperatorsModule2() = // Overflow let result = Operators.sbyte Double.MaxValue - Assert.AreEqual(0y, result) + if Info.isNetFramework then + Assert.AreEqual(0y, result) + else + Assert.AreEqual(-1y, result) // Overflow let result = Operators.sbyte (Int64.MaxValue * 8L) @@ -954,7 +991,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint16 Single.MaxValue - Assert.AreEqual(0us, result) + if Info.isNetFramework then + Assert.AreEqual(0us, result) + else + Assert.AreEqual(65535us, result) // Overflow let result = Operators.uint16 Single.MinValue @@ -962,7 +1002,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint16 Double.MaxValue - Assert.AreEqual(0us, result) + if Info.isNetFramework then + Assert.AreEqual(0us, result) + else + Assert.AreEqual(65535us, result) // Overflow let result = Operators.uint16 Double.MinValue @@ -987,7 +1030,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint32 Single.MaxValue - Assert.AreEqual(0u, result) + if Info.isNetFramework then + Assert.AreEqual(0u, result) + else + Assert.AreEqual(4294967295u, result) // Overflow let result = Operators.uint32 Single.MinValue @@ -995,7 +1041,10 @@ type OperatorsModule2() = // Overflow let result = Operators.uint32 Double.MaxValue - Assert.AreEqual(0u, result) + if Info.isNetFramework then + Assert.AreEqual(0u, result) + else + Assert.AreEqual(4294967295u, result) // Overflow let result = Operators.uint32 Double.MinValue @@ -1037,19 +1086,31 @@ type OperatorsModule2() = // Overflow let result = Operators.uint64 Single.MaxValue - Assert.AreEqual(0UL, result) + if Info.isNetFramework then + Assert.AreEqual(0UL, result) + else + Assert.AreEqual(18446744073709551615UL, result) // Overflow let result = Operators.uint64 Single.MinValue - Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + if Info.isNetFramework then + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Double.MaxValue - Assert.AreEqual(0UL, result) + if Info.isNetFramework then + Assert.AreEqual(0UL, result) + else + Assert.AreEqual(18446744073709551615UL, result) // Overflow let result = Operators.uint64 Double.MinValue - Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + if Info.isNetFramework then + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Int64.MinValue @@ -1079,25 +1140,37 @@ type OperatorsModule2() = // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Single.MaxValue - Assert.AreEqual(0un, result) + if Info.isNetFramework then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(18446744073709551615un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Single.MinValue if Info.isX86Runtime then Assert.AreEqual(0un, result) else - Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + if Info.isNetFramework then + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0un, result) // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Double.MaxValue - Assert.AreEqual(0un, result) + if Info.isNetFramework then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(18446744073709551615un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Double.MinValue if Info.isX86Runtime then Assert.AreEqual(0un, result) else - Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + if Info.isNetFramework then + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Int64.MinValue diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs index 9af581dca52..7d8b3678821 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -7,6 +7,10 @@ namespace FSharp.Core.UnitTests.Operators open System open Xunit +// For information on the runtime-dependent behavior differences in this file, see: +// - https://github.com/dotnet/runtime/issues/61885 +// - https://github.com/dotnet/runtime/pull/97529 + #nowarn "1204" // CompilerMessage: This function is for use by dynamic invocations of F# code and should not be used directly module OperatorsModuleDynamic = @@ -94,7 +98,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.byte Single.MaxValue - Assert.AreEqual(0uy, result) + if Info.isNetFramework then + Assert.AreEqual(0uy, result) + else + Assert.AreEqual(255uy, result) // Overflow let result = Operators.byte Double.MinValue @@ -102,7 +109,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.byte Double.MaxValue - Assert.AreEqual(0uy, result) + if Info.isNetFramework then + Assert.AreEqual(0uy, result) + else + Assert.AreEqual(255uy, result) // Overflow let result = Operators.byte (Int64.MaxValue * 8L) @@ -135,8 +145,16 @@ module OperatorsModuleDynamic = // Overflow Assert.AreEqual('\000', Operators.char Single.MinValue) Assert.AreEqual('\000', Operators.char Double.MinValue) - Assert.AreEqual('\000', Operators.char Single.MaxValue) - Assert.AreEqual('\000', Operators.char Double.MaxValue) + + if Info.isNetFramework then + Assert.AreEqual('\000', Operators.char Single.MaxValue) + else + Assert.AreEqual('\uffff', Operators.char Single.MaxValue) + + if Info.isNetFramework then + Assert.AreEqual('\000', Operators.char Double.MaxValue) + else + Assert.AreEqual('\uffff', Operators.char Double.MaxValue) CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) // string type @@ -233,7 +251,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int Single.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int Single.MinValue @@ -241,7 +262,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int Double.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int Double.MinValue @@ -286,7 +310,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int16 Single.MaxValue - Assert.AreEqual(0s, result) + if Info.isNetFramework then + Assert.AreEqual(0s, result) + else + Assert.AreEqual(-1s, result) // Overflow let result = Operators.int16 Single.MinValue @@ -294,7 +321,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int16 Double.MaxValue - Assert.AreEqual(0s, result) + if Info.isNetFramework then + Assert.AreEqual(0s, result) + else + Assert.AreEqual(-1s, result) // Overflow let result = Operators.int16 Double.MinValue @@ -338,7 +368,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int32 Single.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int32 Single.MinValue @@ -346,7 +379,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.int32 Double.MaxValue - Assert.AreEqual(Int32.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int32.MinValue, result) + else + Assert.AreEqual(Int32.MaxValue, result) // Overflow let result = Operators.int32 Double.MinValue @@ -391,7 +427,10 @@ module OperatorsModuleDynamic = // Overflow. let result = Operators.int64 Single.MaxValue - Assert.AreEqual(Int64.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int64.MinValue, result) + else + Assert.AreEqual(Int64.MaxValue, result) // Overflow let result = Operators.int64 Single.MinValue @@ -399,7 +438,10 @@ module OperatorsModuleDynamic = // Overflow. let result = Operators.int64 Double.MaxValue - Assert.AreEqual(Int64.MinValue, result) + if Info.isNetFramework then + Assert.AreEqual(Int64.MinValue, result) + else + Assert.AreEqual(Int64.MaxValue, result) // Overflow let result = Operators.int64 Double.MinValue @@ -444,9 +486,12 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual(-9223372036854775807n - 1n, result) - + if Info.isNetFramework then + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + else + Assert.AreEqual(9223372036854775807n, result) + // Overflow (depends on pointer size) let result = Operators.nativeint Single.MinValue if Info.isX86Runtime then @@ -454,15 +499,18 @@ module OperatorsModuleDynamic = else // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual(-9223372036854775807n - 1n, result) - + // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.nativeint Double.MaxValue if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual(-9223372036854775807n - 1n, result) - + if Info.isNetFramework then + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + else + Assert.AreEqual(9223372036854775807n, result) + // Overflow (depends on pointer size) let result = Operators.nativeint Double.MinValue if Info.isX86Runtime then @@ -470,7 +518,7 @@ module OperatorsModuleDynamic = else // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual(-9223372036854775807n - 1n, result) - + // Overflow (depends on pointer size) let result = Operators.nativeint Int64.MinValue if Info.isX86Runtime then @@ -492,8 +540,11 @@ module OperatorsModuleDynamic = if Info.isX86Runtime then Assert.AreEqual(-2147483648n, result) else - // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 - Assert.AreEqual("-9223372036854775808", string result) + if Info.isNetFramework then + // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual("-9223372036854775808", string result) + else + Assert.AreEqual(9223372036854775807n, result) let result = Operators.nativeint System.Double.MinValue if Info.isX86Runtime then @@ -501,7 +552,6 @@ module OperatorsModuleDynamic = else // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 Assert.AreEqual("-9223372036854775808", string result) - // Max and min value as literals (this breaks compilation if the lexer fails). // The following tests ensure that the proper value is parsed, which is similar to `nativeint Int64.MaxValue` etc. if Info.isX86Runtime then @@ -544,7 +594,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.sbyte Single.MaxValue - Assert.AreEqual(0y, result) + if Info.isNetFramework then + Assert.AreEqual(0y, result) + else + Assert.AreEqual(-1y, result) // Overflow let result = Operators.sbyte Double.MinValue @@ -552,7 +605,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.sbyte Double.MaxValue - Assert.AreEqual(0y, result) + if Info.isNetFramework then + Assert.AreEqual(0y, result) + else + Assert.AreEqual(-1y, result) // Overflow let result = Operators.sbyte (Int64.MaxValue * 8L) @@ -596,7 +652,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint16 Single.MaxValue - Assert.AreEqual(0us, result) + if Info.isNetFramework then + Assert.AreEqual(0us, result) + else + Assert.AreEqual(65535us, result) // Overflow let result = Operators.uint16 Single.MinValue @@ -604,7 +663,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint16 Double.MaxValue - Assert.AreEqual(0us, result) + if Info.isNetFramework then + Assert.AreEqual(0us, result) + else + Assert.AreEqual(65535us, result) // Overflow let result = Operators.uint16 Double.MinValue @@ -629,7 +691,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint32 Single.MaxValue - Assert.AreEqual(0u, result) + if Info.isNetFramework then + Assert.AreEqual(0u, result) + else + Assert.AreEqual(4294967295u, result) // Overflow let result = Operators.uint32 Single.MinValue @@ -637,8 +702,10 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint32 Double.MaxValue - Assert.AreEqual(0u, result) - + if Info.isNetFramework then + Assert.AreEqual(0u, result) + else + Assert.AreEqual(4294967295u, result) // Overflow let result = Operators.uint32 Double.MinValue Assert.AreEqual(0u, result) @@ -679,20 +746,31 @@ module OperatorsModuleDynamic = // Overflow let result = Operators.uint64 Single.MaxValue - Assert.AreEqual(0UL, result) - + if Info.isNetFramework then + Assert.AreEqual(0UL, result) + else + Assert.AreEqual(18446744073709551615UL, result) + // Overflow let result = Operators.uint64 Single.MinValue - Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 - + if Info.isNetFramework then + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0UL, result) + // Overflow let result = Operators.uint64 Double.MaxValue - Assert.AreEqual(0UL, result) - + if Info.isNetFramework then + Assert.AreEqual(0UL, result) + else + Assert.AreEqual(18446744073709551615UL, result) + // Overflow let result = Operators.uint64 Double.MinValue - Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 - + if Info.isNetFramework then + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0UL, result) // Overflow let result = Operators.uint64 Int64.MinValue Assert.AreEqual(9223372036854775808UL, result) @@ -721,26 +799,37 @@ module OperatorsModuleDynamic = // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Single.MaxValue - Assert.AreEqual(0un, result) + if Info.isNetFramework then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(18446744073709551615un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Single.MinValue if Info.isX86Runtime then Assert.AreEqual(0un, result) else - Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + if Info.isNetFramework then + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0un, result) // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Double.MaxValue - Assert.AreEqual(0un, result) + if Info.isNetFramework then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(18446744073709551615un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Double.MinValue if Info.isX86Runtime then Assert.AreEqual(0un, result) else - Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 - + if Info.isNetFramework then + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + else + Assert.AreEqual(0un, result) // Overflow (depends on pointer size) let result = Operators.unativeint Int64.MinValue if Info.isX86Runtime then