diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4c80008a..5dd0bb86 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -124,6 +124,8 @@ jobs: ./configure.sh && sudo make install + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: run tests run: make check - name: compile this repo's .fsx scripts with fsx @@ -151,6 +153,8 @@ jobs: ./configure.sh && sudo make install + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: run tests run: make check - name: compile this repo's .fsx scripts with fsx @@ -178,6 +182,8 @@ jobs: ./configure.sh && sudo make install + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: run tests run: make check - name: compile this repo's .fsx scripts with fsx @@ -216,6 +222,8 @@ jobs: ./configure.sh && sudo make install + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: run tests run: make check - name: compile this repo's .fsx scripts with fsx @@ -256,6 +264,8 @@ jobs: ./configure.sh && sudo make install + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: run tests run: make check - name: compile this repo's .fsx scripts with fsx @@ -283,6 +293,8 @@ jobs: ./configure.sh && sudo make install + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: run tests run: make check - name: compile this repo's .fsx scripts with fsx @@ -310,6 +322,8 @@ jobs: ./configure.sh && sudo make install + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: run tests run: make check - name: compile this repo's .fsx scripts with fsx @@ -348,6 +362,8 @@ jobs: ./configure.sh && sudo make install + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: run tests run: make check - name: compile this repo's .fsx scripts with fsx @@ -388,6 +404,8 @@ jobs: ./configure.sh && sudo make install + - name: run unit tests + run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx - name: run tests run: make check - name: compile this repo's .fsx scripts with fsx @@ -422,6 +440,8 @@ jobs: ./configure.sh && sudo make install + - name: run unit tests + run: dotnet fsi scripts/runUnitTests.fsx - name: run tests run: make check - name: compile this repo's .fsx scripts with fsx @@ -464,6 +484,8 @@ jobs: .\make.bat install + - name: run unit tests + run: dotnet fsi scripts/runUnitTests.fsx - name: run tests run: .\make.bat check - name: compile this repo's .fsx scripts with fsx diff --git a/Fsdk.Tests/Fsdk.Tests-legacy.fsproj b/Fsdk.Tests/Fsdk.Tests-legacy.fsproj new file mode 100644 index 00000000..396640b3 --- /dev/null +++ b/Fsdk.Tests/Fsdk.Tests-legacy.fsproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + 2.0 + 4634f264-784e-42da-b5a1-fe72125deafc + Library + Fsdk.Tests + Fsdk.Tests + v4.7.1 + 4.4.0.0 + true + Fsdk + + + + 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 + + + + + True + + + + + + + + + + + + + + + + + + + + + + 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/scripts/make.fsx b/scripts/make.fsx index c1bd286b..29d6ea90 100644 --- a/scripts/make.fsx +++ b/scripts/make.fsx @@ -23,6 +23,7 @@ let FsdkDir = Path.Combine(RootDir.FullName, "Fsdk") |> DirectoryInfo let NugetDir = Path.Combine(RootDir.FullName, ".nuget") |> DirectoryInfo let NugetExe = Path.Combine(NugetDir.FullName, "nuget.exe") |> FileInfo + type BinaryConfig = | Debug | Release diff --git a/scripts/runUnitTests.fsx b/scripts/runUnitTests.fsx new file mode 100644 index 00000000..e9b9df36 --- /dev/null +++ b/scripts/runUnitTests.fsx @@ -0,0 +1,119 @@ +open System +open System.IO +open System.Net +open System.Linq +open System.Diagnostics + +#r "System.Configuration" +open System.Configuration + +#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 + } + | _ -> + //if not NugetExe.Exists then + // MakeAll() |> ignore + + 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()