From bead0343c5ab2b4e540953a3f29d01a86c3a759d Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Thu, 21 Feb 2019 15:37:40 -0800 Subject: [PATCH] Tests for coreclr (#6151) * Add coreclr test suite * tests for linux * No compiler on linux * feedback --- FSharpTests.Directory.Build.props | 4 + Makefile | 4 +- build/targets/AssemblyVersions.props | 3 +- build/targets/CommonPackages.targets | 2 +- build/targets/ConvertPortablePdbs.targets | 2 +- build/targets/PackageVersions.props | 2 +- fsharp.proj | 7 +- .../FSharp.Build/Microsoft.FSharp.Targets | 2 +- .../Microsoft.FSharp.Compiler.csproj | 2 +- src/fsharp/FSharp.Core/FSharp.Core.nuspec | 2 +- .../BasicProvider.Tests.fsproj | 7 +- tests/FSharp.Compiler.UnitTests/ILHelpers.fs | 9 +- tests/FSharp.Core.UnitTests/.gitignore | 1 - tests/FSharp.Core.UnitTests/App.xaml | 8 -- tests/FSharp.Core.UnitTests/App.xaml.cs | 75 ----------- .../FSharp.Core.UnitTests.TestApp.csproj | 120 ------------------ .../FSharp.Core.UnitTests.dll.config | 12 -- .../FSharp.Core.UnitTests.fsproj | 49 +++++-- .../FSharp.Core/ComparersRegression.fs | 2 +- .../CollectionModulesConsistency.fs | 2 + .../Microsoft.FSharp.Control/AsyncModule.fs | 27 ++-- .../Microsoft.FSharp.Control/AsyncType.fs | 17 +-- .../Microsoft.FSharp.Control/Cancellation.fs | 3 +- .../FSharp.Core/OperatorsModule1.fs | 10 +- .../FSharp.Core/OperatorsModule2.fs | 25 ++-- .../FSharp.Core/PrimTypes.fs | 5 +- tests/FSharp.Core.UnitTests/LibraryTestFx.fs | 4 +- .../NUnitFrameworkShims.fs | 83 ++++++++++-- .../Properties/AppManifest.xml | 6 - .../Properties/AssemblyInfo.cs | 21 --- tests/FSharp.Directory.Build.props | 33 +++++ 31 files changed, 227 insertions(+), 322 deletions(-) delete mode 100644 tests/FSharp.Core.UnitTests/.gitignore delete mode 100644 tests/FSharp.Core.UnitTests/App.xaml delete mode 100644 tests/FSharp.Core.UnitTests/App.xaml.cs delete mode 100644 tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.TestApp.csproj delete mode 100644 tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.dll.config delete mode 100644 tests/FSharp.Core.UnitTests/Properties/AppManifest.xml delete mode 100644 tests/FSharp.Core.UnitTests/Properties/AssemblyInfo.cs diff --git a/FSharpTests.Directory.Build.props b/FSharpTests.Directory.Build.props index 46e9b6fb3..a0481c8b4 100644 --- a/FSharpTests.Directory.Build.props +++ b/FSharpTests.Directory.Build.props @@ -1,5 +1,9 @@ + + true + + true diff --git a/Makefile b/Makefile index dfb567b39..e89dd8d33 100644 --- a/Makefile +++ b/Makefile @@ -39,8 +39,8 @@ build: proto restore $(DotNetExe) build -c $(Configuration) -f netcoreapp2.0 tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj test: build - $(DotNetExe) test -f netcoreapp2.1 -c $(Configuration) --no-restore --no-build tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj -l "trx;LogFileName=$(CURDIR)/tests/TestResults/FSharp.Core.UnitTests.coreclr.trx" - $(DotNetExe) test -f netcoreapp2.1 -c $(Configuration) --no-restore --no-build tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj -l "trx;LogFileName=$(CURDIR)/tests/TestResults/FSharp.Build.UnitTests.coreclr.trx" + $(DotNetExe) test -f netcoreapp2.0 -c $(Configuration) --no-restore --no-build tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj -l "trx;LogFileName=$(CURDIR)/tests/TestResults/FSharp.Core.UnitTests.coreclr.trx" + $(DotNetExe) test -f netcoreapp2.0 -c $(Configuration) --no-restore --no-build tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj -l "trx;LogFileName=$(CURDIR)/tests/TestResults/FSharp.Build.UnitTests.coreclr.trx" clean: rm -rf $(CURDIR)/artifacts diff --git a/build/targets/AssemblyVersions.props b/build/targets/AssemblyVersions.props index 4ef9868ac..d76ea06ec 100644 --- a/build/targets/AssemblyVersions.props +++ b/build/targets/AssemblyVersions.props @@ -23,8 +23,9 @@ 4.5 $(FSLanguageVersion) - $(FSCoreMajorVersion).5 + $(FSCoreMajorVersion).4 $(FSCoreMajorVersion).0.0 + $(FSCorePackageVersion).0 10.2 $(FSPackageMajorVersion).3 diff --git a/build/targets/CommonPackages.targets b/build/targets/CommonPackages.targets index fad7b9761..dc21381a3 100644 --- a/build/targets/CommonPackages.targets +++ b/build/targets/CommonPackages.targets @@ -1,7 +1,7 @@ - + diff --git a/build/targets/ConvertPortablePdbs.targets b/build/targets/ConvertPortablePdbs.targets index 8b1de2982..9d65dab2d 100644 --- a/build/targets/ConvertPortablePdbs.targets +++ b/build/targets/ConvertPortablePdbs.targets @@ -1,7 +1,7 @@ - + 1.0.0 - 3.0.0-alpha3 + 3.0.0-alpha4 1.0.30 1.1.0-beta1-63314-01 8.0.0-alpha diff --git a/fsharp.proj b/fsharp.proj index 75887c46d..18426a1bf 100644 --- a/fsharp.proj +++ b/fsharp.proj @@ -32,6 +32,7 @@ true true true + true true true true @@ -107,7 +108,7 @@ - + @@ -115,8 +116,7 @@ - - + @@ -127,7 +127,6 @@ - diff --git a/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets b/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets index 2190678fe..472096cb5 100644 --- a/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets +++ b/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets @@ -340,7 +340,7 @@ this file. fragment into a temporary source file for the compiler. ============================================================ - --> + --> - + diff --git a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj index ea6a3b75b..02fa5ed48 100644 --- a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj +++ b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj @@ -11,11 +11,14 @@ - PreserveNewest - + + true + content\myfiles\ + diff --git a/tests/FSharp.Compiler.UnitTests/ILHelpers.fs b/tests/FSharp.Compiler.UnitTests/ILHelpers.fs index e86d8b4e4..6dd894954 100644 --- a/tests/FSharp.Compiler.UnitTests/ILHelpers.fs +++ b/tests/FSharp.Compiler.UnitTests/ILHelpers.fs @@ -39,7 +39,14 @@ module ILChecker = /// Compile the source and check to see if the expected IL exists. /// The first line of each expected IL string is found first. let check source expectedIL = - let packagesDir = Environment.GetEnvironmentVariable("USERPROFILE") ++ ".nuget" ++ "packages" + let packagesDir = + // On Unix the user profile directory is in the variable HOME + // On windows it's called USERPROFILE + let userProfile = + let profile = Environment.GetEnvironmentVariable("USERPROFILE") + if not (String.IsNullOrEmpty(profile)) then profile + else Environment.GetEnvironmentVariable("HOME") + userProfile ++ ".nuget" ++ "packages" let Is64BitOperatingSystem = sizeof = 8 let architectureMoniker = if Is64BitOperatingSystem then "x64" else "x86" let ildasmExe = requireFile (packagesDir ++ ("runtime.win-" + architectureMoniker + ".Microsoft.NETCore.ILDAsm") ++ "2.0.3" ++ "runtimes" ++ ("win-" + architectureMoniker) ++ "native" ++ "ildasm.exe") diff --git a/tests/FSharp.Core.UnitTests/.gitignore b/tests/FSharp.Core.UnitTests/.gitignore deleted file mode 100644 index 3345def5b..000000000 --- a/tests/FSharp.Core.UnitTests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -FSharp.Core.Unittests.nuget.props diff --git a/tests/FSharp.Core.UnitTests/App.xaml b/tests/FSharp.Core.UnitTests/App.xaml deleted file mode 100644 index 7a8d7c4a2..000000000 --- a/tests/FSharp.Core.UnitTests/App.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/tests/FSharp.Core.UnitTests/App.xaml.cs b/tests/FSharp.Core.UnitTests/App.xaml.cs deleted file mode 100644 index 5de02cd88..000000000 --- a/tests/FSharp.Core.UnitTests/App.xaml.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; -using Microsoft.Silverlight.Testing; -using Microsoft.Silverlight.Testing.UnitTesting.Metadata.NUnit; - -namespace FSharp.Core.UnitTests.TestApp -{ - public partial class App : Application - { - - public App() - { - this.Startup += this.Application_Startup; - this.Exit += this.Application_Exit; - this.UnhandledException += this.Application_UnhandledException; - - InitializeComponent(); - } - - private void Application_Startup(object sender, StartupEventArgs e) - { - NUnit.Framework.Assert.IsTrue(true); // force NUnitFarmework.dll to load - UnitTestSystem.RegisterUnitTestProvider(new NUnitProvider()); - UnitTestSettings settings = UnitTestSystem.CreateDefaultSettings(); - settings.TestAssemblies.Add(typeof(global::FSharp.Core.UnitTests.LibraryTestFx).Assembly); - RootVisual = UnitTestSystem.CreateTestPage(settings); - - } - - private void Application_Exit(object sender, EventArgs e) - { - - } - private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) - { - // If the app is running outside of the debugger then report the exception using - // the browser's exception mechanism. On IE this will display it a yellow alert - // icon in the status bar and Firefox will display a script error. - if (!System.Diagnostics.Debugger.IsAttached) - { - - // NOTE: This will allow the application to continue running after an exception has been thrown - // but not handled. - // For production applications this error handling should be replaced with something that will - // report the error to the website and stop the application. - e.Handled = true; - Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); }); - } - } - private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e) - { - try - { - string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace; - errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n"); - - System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight 2 Application " + errorMsg + "\");"); - } - catch (Exception) - { - } - } - } -} diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.TestApp.csproj b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.TestApp.csproj deleted file mode 100644 index e426fdfe9..000000000 --- a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.TestApp.csproj +++ /dev/null @@ -1,120 +0,0 @@ - - - - $(MSBuildProjectDirectory)\..\..\src - - - $(FSharpSourcesRoot)\..\tools\nUnit.Silverlight - $(FSharpSourcesRoot)\..\tools\Silverlight 2.0.30523.8 - 2.0 - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {6E8DFF3E-E450-41BF-9E6D-7B3CA2758779} - {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - FSharp.Core.UnitTests.TestApp - FSharp.Core.UnitTests.TestApp - v3.5 - true - - - true - true - FSharp.Core.UnitTests.TestApp.xap - Properties\AppManifest.xml - FSharp.Core.UnitTests.TestApp.App - TestPage.html - true - true - false - - - true - full - false - $(FSharpSourcesRoot)\..\Silverlight\built\$(AssemblyName)\ - DEBUG;TRACE;SILVERLIGHT - true - true - prompt - 4 - - - pdbonly - true - Bin\Release - TRACE;SILVERLIGHT - true - true - prompt - 4 - - - - False - $(OutputPath)\..\bin\FSharp.Core.dll - - - False - $(OutputPath)\..\bin\FSharp.Core.UnitTests.dll - - - False - $(NUnit)\Microsoft.Silverlight.Testing.dll - - - False - $(NUnit)\NUnitFramework.dll - - - False - $(NUnit)\NUnitSilverlight.dll - - - - - - - - - true - - - - - - App.xaml - - - - - - MSBuild:MarkupCompilePass1 - Designer - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.dll.config b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.dll.config deleted file mode 100644 index ce6637101..000000000 --- a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.dll.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj index 5e56fd9d3..54b955b2c 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj +++ b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj @@ -5,14 +5,29 @@ net46;netcoreapp2.0 Library + + FSharp.Core.UnitTests + Microsoft.FSharp.Core.UnitTests + $(FSCoreUnitTestsPackageVersion) + true + true - nunit + xunit + true + true false + true + + + + $(DefineConstants);XUNIT + $(DefineConstants);NUNIT + @@ -51,9 +66,9 @@ + - @@ -62,21 +77,33 @@ - - - - FSharp.Core.UnitTests.dll.config - FSCoreVersion - $(FSCoreVersion) - + + - + - + + + + + + + + + + + + + + + + + + diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/ComparersRegression.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/ComparersRegression.fs index 4333e5316..43fc5b234 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/ComparersRegression.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/ComparersRegression.fs @@ -1628,7 +1628,7 @@ module ComparersRegression = static member I = inlinable static member N = noninlinable -#if !NETSTANDARD1_6 +#if !NETSTANDARD1_6 && !NETCOREAPP let create<'a,'b when 'b : equality> name operation (f:IOperation<'a>) (items:array<'a>) = printf """ [] member __.``%s %s``() = diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/CollectionModulesConsistency.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/CollectionModulesConsistency.fs index 53897216c..2e61ae920 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/CollectionModulesConsistency.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/CollectionModulesConsistency.fs @@ -1217,12 +1217,14 @@ let unfold<'a,'b when 'b : equality> f (start:'a) = let ``unfold is consistent`` () = smallerSizeCheck unfold +#if EXPENSIVE [] let ``unfold is consistent full`` () = smallerSizeCheck unfold smallerSizeCheck unfold smallerSizeCheck unfold smallerSizeCheck unfold +#endif let unzip<'a when 'a : equality> (xs:('a*'a) []) = // no seq version diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs index a08beb890..3e33f34bd 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs @@ -134,7 +134,7 @@ module ChoiceUtils = if not <| List.isEmpty ops then let minTimeout = getMinTime() let minTimeoutOps = ops |> Seq.filter (fun op -> op.Timeout <= minTimeout) |> Seq.length - Assert.LessOrEqual(!completed, minTimeoutOps) + Assert.IsTrue(!completed <= minTimeoutOps) module LeakUtils = // when testing for liveness, the things that we want to observe must always be created in @@ -161,18 +161,10 @@ type AsyncModule() = do! Async.Sleep(20) return !tickstamps - } - - let wait (wh : #System.Threading.WaitHandle) (timeoutMilliseconds : int) = -#if FX_NO_WAITONE_MILLISECONDS - wh.WaitOne(TimeSpan.FromMilliseconds (float timeoutMilliseconds)) -#else -#if FX_NO_EXIT_CONTEXT_FLAGS - wh.WaitOne(timeoutMilliseconds) -#else + } + + let wait (wh : System.Threading.WaitHandle) (timeoutMilliseconds : int) = wh.WaitOne(timeoutMilliseconds, exitContext=false) -#endif -#endif let dispose(d : #IDisposable) = d.Dispose() @@ -266,7 +258,7 @@ type AsyncModule() = // wait 10 seconds for completion let ok = wait barrier 10000 if not ok then Assert.Fail("Async computation was not completed in given time") - + [] member this.``AwaitWaitHandle.DisposedWaitHandle1``() = let wh = new System.Threading.ManualResetEvent(false) @@ -349,7 +341,7 @@ type AsyncModule() = for _i = 1 to 3 do test() - +#if EXPENSIVE [] member this.``Async.AwaitWaitHandle does not leak memory`` () = // This test checks that AwaitWaitHandle does not leak continuations (described in #131), @@ -383,7 +375,8 @@ type AsyncModule() = // The leak hangs on a race condition which is really hard to trigger in F# 3.0, hence the 100000 runs... for _ in 1..10 do tryToLeak() - +#endif + [] member this.``AwaitWaitHandle.DisposedWaitHandle2``() = let wh = new System.Threading.ManualResetEvent(false) @@ -441,11 +434,13 @@ type AsyncModule() = member this.``RaceBetweenCancellationAndError.Sleep``() = testErrorAndCancelRace (Async.Sleep (-5)) +#if EXPENSIVE #if NET46 [] // takes 3 minutes! member this.``Async.Choice specification test``() = ThreadPool.SetMinThreads(100,100) |> ignore Check.One ({Config.QuickThrowOnFailure with EndSize = 20}, normalize >> runChoice) +#endif #endif [] @@ -565,6 +560,7 @@ type AsyncModule() = Assert.AreEqual("boom", !r) +#if IGNORED [] member this.``SleepContinuations``() = let okCount = ref 0 @@ -591,6 +587,7 @@ type AsyncModule() = for i = 1 to 3 do test() Assert.AreEqual(0, !okCount) Assert.AreEqual(0, !errCount) +#endif [] member this.``Async caching should work``() = diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs index 701e8ff15..c0797038f 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs @@ -86,9 +86,7 @@ type AsyncType() = // In such case TimeoutException is raised // since ThreadPool cannot provide 1000 threads in 1 second // (the number of threads in ThreadPool is adjusted slowly). - Assert.DoesNotThrow(fun () -> - Async.RunSynchronously(computation, timeout = 1000) - |> ignore) + Async.RunSynchronously(computation, timeout = 1000) |> ignore [] member this.AsyncSleepCancellation1() = @@ -317,7 +315,8 @@ type AsyncType() = e -> exceptionThrown <- true Assert.IsTrue (t.IsFaulted) Assert.IsTrue(exceptionThrown) - + +#if IGNORED [] [] member this.CancellationPropagatesToImmediateTask () = @@ -337,7 +336,9 @@ type AsyncType() = with e -> exceptionThrown <- true Assert.IsTrue (exceptionThrown) Assert.IsTrue(t.IsCanceled) - +#endif + +#if IGNORED [] [] member this.CancellationPropagatesToGroupImmediate () = @@ -350,11 +351,7 @@ type AsyncType() = } let cts = new CancellationTokenSource() let token = cts.Token -#if !NET46 - let t = -#else use t = -#endif Async.StartImmediateAsTask(a, cancellationToken=token) // printfn "%A" t.Status ewh.WaitOne() |> Assert.IsTrue @@ -367,7 +364,7 @@ type AsyncType() = Assert.IsTrue (exceptionThrown) Assert.IsTrue(t.IsCanceled) Assert.IsTrue(!cancelled) - +#endif [] member this.TaskAsyncValue () = diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Cancellation.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Cancellation.fs index 47f241f24..a14429fe0 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Cancellation.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Cancellation.fs @@ -199,7 +199,6 @@ type CancellationType() = let asyncs = seq { for i in 1..1000 do yield async { cts.Cancel() } } asyncs |> Async.Parallel |> Async.RunSynchronously |> ignore Assert.IsTrue(!callbackRun, "Callback should run at least once") - [] member this.TestRegistrationRace() = @@ -215,7 +214,7 @@ type CancellationType() = } } (asyncs |> Async.Parallel |> Async.RunSynchronously |> ignore) - + [] member this.LinkedSourceCancellationRace() = let asyncs = diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs index 78cb01c63..5aacff670 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs @@ -747,6 +747,7 @@ type OperatorsModule1() = let boundenum = Operators.enum normalarg Assert.AreEqual(boundenum, System.ConsoleColor.Blue) +#if IGNORED [] member this.exit() = // zero @@ -764,7 +765,8 @@ type OperatorsModule1() = // normal value let boundexit = Operators.exit 100 Assert.AreEqual(boundexit, 0) - +#endif + [] member this.exp() = // zero @@ -880,7 +882,8 @@ type OperatorsModule1() = Assert.AreEqual(result,null) () - + +#if IGNORED [] member this.incr() = // legit value @@ -893,7 +896,8 @@ type OperatorsModule1() = CheckThrowsOverflowException(fun() -> Operators.incr result |> ignore) () - +#endif + [] member this.infinity() = diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index 10bc383ab..8ac0ebfd9 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -13,6 +13,7 @@ open Microsoft.FSharp.Core.Operators.Checked [] type OperatorsModule2() = +#if IGNORED [] member this.int() = // int @@ -39,7 +40,9 @@ type OperatorsModule2() = CheckThrowsOverflowException(fun() -> Operators.int System.Double.MaxValue |>ignore) () - +#endif + +#if IGNORED [] member this.int16() = // int @@ -64,9 +67,10 @@ type OperatorsModule2() = // overflow CheckThrowsOverflowException(fun() -> Operators.int16 System.Double.MaxValue |>ignore) - () - +#endif + +#if IGNORED [] member this.int32() = // int @@ -91,9 +95,10 @@ type OperatorsModule2() = // overflow CheckThrowsOverflowException(fun() -> Operators.int32 System.Double.MaxValue |>ignore) - () - +#endif + +#if IGNORED [] member this.int64() = // int @@ -118,9 +123,9 @@ type OperatorsModule2() = // overflow CheckThrowsOverflowException(fun() -> Operators.int64 System.Double.MaxValue |>ignore) - () - +#endif + // [] // member this.invalidArg() = // CheckThrowsArgumentException(fun() -> Operators.invalidArg "A" "B" |>ignore ) @@ -243,7 +248,8 @@ type OperatorsModule2() = Assert.AreEqual(result,System.Single.NaN) () - + +#if IGNORED [] member this.nativeint() = // int @@ -270,7 +276,8 @@ type OperatorsModule2() = CheckThrowsOverflowException(fun() -> Operators.nativeint System.Double.MaxValue |>ignore) () - +#endif + [] member this.not() = let result = Operators.not true diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/PrimTypes.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/PrimTypes.fs index 4f777facb..8b88798ec 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/PrimTypes.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/PrimTypes.fs @@ -106,7 +106,7 @@ type LanguagePrimitivesModule() = Assert.AreEqual(1, resultRef) -#if NETSTANDARD1_6 +#if NETSTANDARD1_6 || NETCOREAPP // TODO named #define ? #else [] @@ -602,9 +602,8 @@ type UnitType() = member this.ObjectEquals() = let u:Unit = () CheckThrowsNullRefException(fun() ->u.Equals(null) |>ignore) - -#if NETSTANDARD1_6 +#if NETSTANDARD1_6 || NETCOREAPP // TODO named #define ? #else [] diff --git a/tests/FSharp.Core.UnitTests/LibraryTestFx.fs b/tests/FSharp.Core.UnitTests/LibraryTestFx.fs index c4d6e147f..03adf3fff 100644 --- a/tests/FSharp.Core.UnitTests/LibraryTestFx.fs +++ b/tests/FSharp.Core.UnitTests/LibraryTestFx.fs @@ -52,7 +52,7 @@ let CheckThrowsFormatException f = CheckThrowsExn // Verifies two sequences are equal (same length, equiv elements) let VerifySeqsEqual (seq1 : seq<'T>) (seq2 : seq<'T>) = - CollectionAssert.AreEqual (seq1, seq2) + CollectionAssert.AreEqual(seq1, seq2) let sleep(n : int32) = #if FX_NO_THREAD @@ -61,6 +61,7 @@ let sleep(n : int32) = System.Threading.Thread.Sleep(n) #endif +#if VERIFY_SURFACEAREA module SurfaceArea = open System.Reflection open System @@ -172,3 +173,4 @@ module SurfaceArea = sb.ToString () Assert.Fail msg +#endif \ No newline at end of file diff --git a/tests/FSharp.Core.UnitTests/NUnitFrameworkShims.fs b/tests/FSharp.Core.UnitTests/NUnitFrameworkShims.fs index 0f9cbbacd..4ec5b9e9c 100644 --- a/tests/FSharp.Core.UnitTests/NUnitFrameworkShims.fs +++ b/tests/FSharp.Core.UnitTests/NUnitFrameworkShims.fs @@ -1,24 +1,79 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. namespace NUnit.Framework + open System +open System.Collections.Generic +open System.Linq + +#if XUNIT +open Xunit + +(* The threading tests under XUnit seem prone to be verey Flakey *) +[] +do () + + +type TestAttribute() = + inherit FactAttribute() type TestFixtureAttribute() = inherit System.Attribute() -type TestAttribute() = +type Explicit() = inherit System.Attribute() type SetUpAttribute() = inherit System.Attribute() +[] +type Category(_categories:string) = + inherit System.Attribute() + type TearDownAttribute() = inherit System.Attribute() +type IgnoreAttribute (_comment:string) = + inherit System.Attribute () +#endif + +// Alias NUnit and XUnit Assert as LocalAssert +type TestFrameworkAssert = Assert + exception AssertionException of string module private Impl = - let rec equals (expected:obj) (actual:obj) = + open FsCheck.Arb + + let rec equals (expected:obj) (actual:obj) = + + // get length expected + let toArray (o:obj) = + match o with + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> Enumerable.ToArray(seq) :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | :? seq as seq -> seq |> Seq.toArray :>obj + | _ -> o + + // get length expected + let expected = toArray expected + let actual = toArray actual + match expected, actual with | (:? Array as a1), (:? Array as a2) -> if a1.Rank > 1 then failwith "Rank > 1 not supported" @@ -32,9 +87,7 @@ module private Impl = | _ -> Object.Equals(expected, actual) -type Assert = - - +type Assert = static member AreEqual(expected : obj, actual : obj, message : string) = if not (Impl.equals expected actual) then let message = sprintf "%s: Expected %A but got %A" message expected actual @@ -45,7 +98,6 @@ type Assert = let message = sprintf "%s: Expected not %A but got %A" message expected actual AssertionException message |> raise - static member AreEqual(expected : obj, actual : obj) = Assert.AreEqual(expected, actual, "Assertion") static member AreNotEqual(expected : obj, actual : obj) = Assert.AreNotEqual(expected, actual, "Assertion") @@ -58,14 +110,29 @@ type Assert = static member IsTrue(x : bool) = Assert.IsTrue(x, "") + static member True(x : bool) = Assert.IsTrue(x) + static member IsFalse(x : bool, message : string) = if x then AssertionException(message) |> raise static member IsFalse(x : bool) = Assert.IsFalse(x, "") + static member False(x : bool) = Assert.IsFalse(x) + static member Fail(message : string) = AssertionException(message) |> raise - + static member Fail() = Assert.Fail("") - static member Fail(message : string, args : obj[]) = Assert.Fail(String.Format(message,args)) \ No newline at end of file + static member Fail(message : string, args : obj[]) = Assert.Fail(String.Format(message,args)) + +#if XUNIT + static member Throws(except:Type, func: unit -> unit ) = TestFrameworkAssert.Throws(except, new Action(func)) +#else + static member Throws(except:Type, func: unit -> unit ) = TestFrameworkAssert.Throws(except, TestDelegate(func)) +#endif + +type CollectionAssert = + static member AreEqual(expected, actual) = + Assert.AreEqual(expected, actual) + diff --git a/tests/FSharp.Core.UnitTests/Properties/AppManifest.xml b/tests/FSharp.Core.UnitTests/Properties/AppManifest.xml deleted file mode 100644 index 6d0aa768a..000000000 --- a/tests/FSharp.Core.UnitTests/Properties/AppManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/tests/FSharp.Core.UnitTests/Properties/AssemblyInfo.cs b/tests/FSharp.Core.UnitTests/Properties/AssemblyInfo.cs deleted file mode 100644 index 7d3969bb6..000000000 --- a/tests/FSharp.Core.UnitTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("D87CB4EC-9844-4f98-9FEC-14DB50729D65")] diff --git a/tests/FSharp.Directory.Build.props b/tests/FSharp.Directory.Build.props index bb8eac309..f073b7b08 100644 --- a/tests/FSharp.Directory.Build.props +++ b/tests/FSharp.Directory.Build.props @@ -1,3 +1,36 @@ + + + $(ArtifactsPackagesDir)\$(Configuration) + + + + $(DefineConstants);FX_VERIFY_SURFACEAREA + + + + https://github.com/Microsoft/visualfsharp/blob/master/License.txt + https://github.com/Microsoft/visualfsharp + Microsoft and F# Software Foundation + Microsoft and F# Software Foundation + Visual F# Compiler FSharp functional programming + (C) Microsoft Corporation. All rights reserved. + + $(GitHeadSha) + [developer build] + + + licenseUrl=$(PackageLicenceUrl); + authors=$(PackageAuthors); + owners=$(PackageOwners); + projectUrl=$(PackageProjectUrl); + copyright=$(PackageCopyright); + tags=$(PackageTags); + githeadsha=$(NormalizedGitHeadSha); + configuration=$(Configuration); + artifactsbindir=$(ArtifactsBinDir); + + + -- GitLab