diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4c80008a..f1dabbb7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -116,6 +116,8 @@ jobs: run: ./configure.sh - name: build in DEBUG mode run: make + - name: run unit tests + run: dotnet fsi scripts/runUnitTests.fsx - name: install run: | @@ -143,6 +145,8 @@ jobs: run: ./configure.sh && cat build.config - name: build in DEBUG mode run: make + - name: run unit tests + run: dotnet fsi scripts/runUnitTests.fsx - name: install run: | @@ -170,6 +174,8 @@ jobs: run: ./configure.sh - name: build in DEBUG mode run: make + - name: run unit tests + run: dotnet fsi scripts/runUnitTests.fsx - name: install run: | @@ -208,6 +214,8 @@ jobs: run: ./configure.sh - name: build in DEBUG mode run: make + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: install run: | @@ -248,6 +256,8 @@ jobs: run: ./configure.sh - name: build in DEBUG mode run: make + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: install run: | @@ -275,6 +285,8 @@ jobs: run: ./configure.sh - name: build in DEBUG mode run: make + - name: run unit tests + run: dotnet fsi scripts/runUnitTests.fsx - name: install run: | @@ -302,6 +314,8 @@ jobs: run: ./configure.sh - name: build in DEBUG mode run: make + - name: run unit tests + run: dotnet fsi scripts/runUnitTests.fsx - name: install run: | @@ -340,6 +354,8 @@ jobs: run: ./configure.sh - name: build in DEBUG mode run: make + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: install run: | @@ -380,6 +396,8 @@ jobs: run: ./configure.sh - name: build in DEBUG mode run: make + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: install run: | @@ -414,6 +432,8 @@ jobs: run: ./configure.sh - name: build in DEBUG mode run: make + - name: run unit tests + run: dotnet fsi scripts/runUnitTests.fsx - name: install run: | @@ -456,6 +476,8 @@ jobs: dotnet-version: '6.0.x' - name: build in DEBUG mode run: .\make.bat + - name: run unit tests + run: dotnet fsi scripts/runUnitTests.fsx - name: install run: | diff --git a/Fsdk.Tests/FSharpUtil.fs b/Fsdk.Tests/FSharpUtil.fs index 5503029a..34888474 100644 --- a/Fsdk.Tests/FSharpUtil.fs +++ b/Fsdk.Tests/FSharpUtil.fs @@ -10,18 +10,6 @@ open Fsdk type UnexpectedTaskCanceledException(message: string, innerException) = inherit TaskCanceledException(message, innerException) -type TypeWithStringOverridenManually = - | FOO - | BAR - - override self.ToString() = - match self with - | FOO -> "FOO" - | BAR -> "BAR" - -type TypeWithNoToStringOverriden = - | FOO - | BAR [] type FSharpUtilCoverage() = diff --git a/Fsdk.Tests/Fsdk.Tests-legacy.fsproj b/Fsdk.Tests/Fsdk.Tests-legacy.fsproj new file mode 100644 index 00000000..4b353efe --- /dev/null +++ b/Fsdk.Tests/Fsdk.Tests-legacy.fsproj @@ -0,0 +1,66 @@ + + + + + 2.0 + {43BA7E25-975B-4DF9-B274-EEF6C806C1D0} + Library + Fsdk.Tests + Fsdk.Tests + v4.7.1 + 4.7.0.0 + true + Fsdk.Tests + + + true + full + false + false + bin\Debug\ + DEBUG;TRACE + 3 + bin\Debug\Fsdk.Tests.XML + + + pdbonly + true + true + bin\Release\ + TRACE + 3 + bin\Release\Fsdk.Tests.XML + + + $(DefineConstants);LEGACY_FRAMEWORK + + + + + ..\..\packages\FSharp.Core.4.7.0\lib\net45\FSharp.Core.dll + + + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + + + + + + + + + + + + + + + + diff --git a/Fsdk.Tests/Program.fs b/Fsdk.Tests/Program.fs index 82efadee..7b1ab6c0 100644 --- a/Fsdk.Tests/Program.fs +++ b/Fsdk.Tests/Program.fs @@ -1,3 +1,5 @@ +namespace Fsdk.Tests + module Program = [] diff --git a/Fsdk.Tests/packages.config b/Fsdk.Tests/packages.config new file mode 100644 index 00000000..29124d6d --- /dev/null +++ b/Fsdk.Tests/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Fsdk/Fsdk-legacy.fsproj b/Fsdk/Fsdk-legacy.fsproj index 1cc4c8a0..115017bd 100644 --- a/Fsdk/Fsdk-legacy.fsproj +++ b/Fsdk/Fsdk-legacy.fsproj @@ -10,7 +10,7 @@ Fsdk Fsdk v4.7.1 - 4.4.0.0 + 4.7.0.0 true Fsdk @@ -39,8 +39,8 @@ - - True + + ..\..\packages\FSharp.Core.4.7.0\lib\net45\FSharp.Core.dll @@ -51,6 +51,7 @@ + diff --git a/Fsdk/packages.config b/Fsdk/packages.config new file mode 100644 index 00000000..cc622f22 --- /dev/null +++ b/Fsdk/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/fsx-legacy.sln b/fsx-legacy.sln index 0ca29bf8..490a4d37 100644 --- a/fsx-legacy.sln +++ b/fsx-legacy.sln @@ -51,6 +51,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{DBAE02AB scripts\fsx.bat = scripts\fsx.bat EndProjectSection EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fsdk.Tests", "Fsdk.Tests\Fsdk.Tests-legacy.fsproj", "{43BA7E25-975B-4DF9-B274-EEF6C806C1D0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -65,6 +67,10 @@ Global {56DA5F03-8F7F-44AB-B692-5A24DB134A8B}.Debug|Any CPU.Build.0 = Debug|Any CPU {56DA5F03-8F7F-44AB-B692-5A24DB134A8B}.Release|Any CPU.ActiveCfg = Release|Any CPU {56DA5F03-8F7F-44AB-B692-5A24DB134A8B}.Release|Any CPU.Build.0 = Release|Any CPU + {43BA7E25-975B-4DF9-B274-EEF6C806C1D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43BA7E25-975B-4DF9-B274-EEF6C806C1D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43BA7E25-975B-4DF9-B274-EEF6C806C1D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43BA7E25-975B-4DF9-B274-EEF6C806C1D0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/fsx.sln b/fsx.sln index 21ffa724..7bdebec3 100644 --- a/fsx.sln +++ b/fsx.sln @@ -69,6 +69,10 @@ Global {B532D664-2864-4532-9673-3E52DD363BB9}.Debug|Any CPU.Build.0 = Debug|Any CPU {B532D664-2864-4532-9673-3E52DD363BB9}.Release|Any CPU.ActiveCfg = Release|Any CPU {B532D664-2864-4532-9673-3E52DD363BB9}.Release|Any CPU.Build.0 = Release|Any CPU + {43BA7E25-975B-4DF9-B274-EEF6C806C1D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43BA7E25-975B-4DF9-B274-EEF6C806C1D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43BA7E25-975B-4DF9-B274-EEF6C806C1D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43BA7E25-975B-4DF9-B274-EEF6C806C1D0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/scripts/runUnitTests.fsx b/scripts/runUnitTests.fsx new file mode 100644 index 00000000..5a6c0f9e --- /dev/null +++ b/scripts/runUnitTests.fsx @@ -0,0 +1,113 @@ +open System +open System.IO +open System.Net +open System.Linq +open System.Diagnostics + +#load "../Fsdk/Misc.fs" +#load "../Fsdk/Process.fs" +#load "../Fsdk/Network.fs" +#load "../Fsdk/Git.fs" + +open Fsdk +open Fsdk.Process + +let ScriptsDir = __SOURCE_DIRECTORY__ |> DirectoryInfo +let RootDir = Path.Combine(ScriptsDir.FullName, "..") |> DirectoryInfo +let TestDir = Path.Combine(RootDir.FullName, "test") |> DirectoryInfo +let NugetDir = Path.Combine(RootDir.FullName, ".nuget") |> DirectoryInfo +let NugetExe = Path.Combine(NugetDir.FullName, "nuget.exe") |> FileInfo +let NugetPackages = Path.Combine(RootDir.FullName, "packages") |> DirectoryInfo + +let NugetScriptsPackagesDir() = + let dir = Path.Combine(NugetDir.FullName, "packages") |> DirectoryInfo + + if not dir.Exists then + Directory.CreateDirectory dir.FullName |> ignore + + dir + +let MakeCheckCommand(commandName: string) = + if not(Process.CommandWorksInShell commandName) then + Console.Error.WriteLine( + sprintf "%s not found, please install it first" commandName + ) + + Environment.Exit 1 + +let RunUnitTests() = + Console.WriteLine "Running unit tests...\n" + + let testProjectName = "Fsdk.Tests" +#if !LEGACY_FRAMEWORK + let testTarget = + Path.Combine( + RootDir.FullName, + testProjectName, + testProjectName + ".fsproj" + ) + |> FileInfo +#else + // so that we get file names in stack traces + Environment.SetEnvironmentVariable("MONO_ENV_OPTIONS", "--debug") + + let testTarget = + Path.Combine( + RootDir.FullName, + testProjectName, + "bin", + "Debug", + testProjectName + ".dll" + ) + |> FileInfo +#endif + + if not testTarget.Exists then + failwithf "File not found: %s" testTarget.FullName + + let runnerCommand = +#if !LEGACY_FRAMEWORK + { + Command = "dotnet" + Arguments = "test " + testTarget.FullName + } +#else + match Misc.GuessPlatform() with + | Misc.Platform.Linux -> + let nunitCommand = "nunit-console" + MakeCheckCommand nunitCommand + + { + Command = nunitCommand + Arguments = testTarget.FullName + } + | _ -> + let nunitVersion = "2.7.1" + let pkgOutputDir = NugetScriptsPackagesDir() + + Network.InstallNugetPackage + NugetExe + pkgOutputDir + "NUnit.Runners" + (Some nunitVersion) + Echo.All + |> ignore + + { + Command = + Path.Combine( + NugetScriptsPackagesDir().FullName, + sprintf "NUnit.Runners.%s" nunitVersion, + "tools", + "nunit-console.exe" + ) + Arguments = testTarget.FullName + } +#endif + + Process + .Execute(runnerCommand, Echo.All) + .UnwrapDefault() + |> ignore + +RunUnitTests()