diff --git a/tests/fsharp/test-framework.fs b/tests/fsharp/test-framework.fs index aeb90af5ae8..36853e17341 100644 --- a/tests/fsharp/test-framework.fs +++ b/tests/fsharp/test-framework.fs @@ -114,6 +114,20 @@ module Commands = Directory.CreateDirectory path |> ignore path + let dotnet workDir exec dotnetExe flag srcFiles = + let args = (sprintf "%s %s" flag (srcFiles |> Seq.ofList |> String.concat " ")) + ignore workDir + exec dotnetExe args + + let git exec gitExe args = + let args = (sprintf "%s" (args |> Seq.ofList |> String.concat " ")) + printfn "Executing git." + exec gitExe args + + let nunit exec nunitExe workdir args = + let args = (sprintf "%s --work:\"%s\"" (args |> Seq.ofList |> String.concat " ") workdir) + printfn "Running external nunit tests." + exec nunitExe args type TestConfig = { EnvironmentVariables : Map @@ -132,7 +146,9 @@ type TestConfig = PEVERIFY : string Directory: string DotNetExe: string - DefaultPlatform: string} + DefaultPlatform: string + GitExe: string + NunitConsoleRunner: string } module WindowsPlatform = @@ -174,7 +190,21 @@ let config configurationName envVars = | [| dir |] -> Path.Combine(dir, "tools", "fsi.exe") | _ -> failwithf "Found more than one 'FSharp.Compiler.Tools' inside '%s', please clean up." packagesDir let toolsDir = SCRIPT_ROOT ++ ".." ++ ".." ++ "Tools" - let dotNetExe = toolsDir ++ "dotnetcli" ++ "dotnet.exe" + let dotNetExe = +#if !FSHARP_SUITE_DRIVES_CORECLR_TESTS + let CI_DotnetPath = "dotnet20" +#else + let CI_DotnetPath = "dotnetcli" +#endif + if File.Exists(toolsDir ++ CI_DotnetPath ++ "dotnet.exe") then + toolsDir ++ CI_DotnetPath ++ "dotnet.exe" + else + let path = envVars.["Path"].Split(';') + let dotnetPath = + path + |> Array.filter(fun path -> path.Contains("dotnet")) + |> Array.find(fun path -> File.Exists(path ++ "dotnet.exe")) + dotnetPath ++ "dotnet.exe" // ildasm requires coreclr.dll to run which has already been restored to the packages directory File.Copy(coreclrdll, Path.GetDirectoryName(ILDASM) ++ "coreclr.dll", overwrite=true) @@ -189,6 +219,14 @@ let config configurationName envVars = let FSC = SCRIPT_ROOT ++ ".." ++ ".." ++ "tests" ++ "testbin" ++ configurationName ++ "coreclr" ++ "FSC" ++ "fsc.exe" let FSCOREDLLPATH = "" #endif + let gitExe = + let gitPath = + envVars.["Path"].Split(';') + |> Array.filter(fun path -> path.Contains("Git")) + |> Array.find(fun path -> File.Exists(path ++ "git.exe")) + gitPath ++ "git.exe" + let nunitExe = + packagesDir ++ "NUnit.Console.3.0.0" ++ "tools" ++ "nunit3-console.exe" let defaultPlatform = match Is64BitOperatingSystem with @@ -213,7 +251,9 @@ let config configurationName envVars = fsi_flags = fsi_flags Directory="" DotNetExe = dotNetExe - DefaultPlatform = defaultPlatform } + DefaultPlatform = defaultPlatform + GitExe = gitExe + NunitConsoleRunner = nunitExe } let logConfig (cfg: TestConfig) = log "---------------------------------------------------------------" @@ -450,6 +490,9 @@ let rm cfg x = Commands.rm cfg.Directory x let rmdir cfg x = Commands.rmdir cfg.Directory x let mkdir cfg = Commands.mkdir_p cfg.Directory let copy_y cfg f = Commands.copy_y cfg.Directory f >> checkResult +let dotnet cfg flag args = Commands.dotnet cfg.Directory (exec cfg) cfg.DotNetExe flag args +let git cfg x = Commands.git (exec cfg) (cfg.GitExe) x +let nunit cfg x = Commands.nunit (exec cfg) (cfg.NunitConsoleRunner) (cfg.Directory) x let diff normalize path1 path2 = let result = System.Text.StringBuilder() diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index d29f92e5e79..be749a0652b 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -28,6 +28,84 @@ let FSI_BASIC = FSI_FILE // ^^^^^^^^^^^^ To run these tests in F# Interactive , 'build net40', then send this chunk, then evaluate body of a test ^^^^^^^^^^^^ module CoreTests = + open TestFramework + +#if !FSHARP_SUITE_DRIVES_CORECLR_TESTS + [] + let testFSharpPlusBuild () = + let cfg = testConfig "" + mkdir cfg "repos" + + if Commands.directoryExists cfg.Directory "repos/FSharpPlus" |> Option.isNone then + let cfg = testConfig "repos" + git cfg ["clone"; "http://github.com/fsprojects/FSharpPlus"; "FSharpPlus"] + + let cfg2 = testConfig "repos/FSharpPlus" + + git cfg2 ["reset"; "--hard"; "aba256430a86a4022941800f06421dda16aa4cb0"] + + exec cfg2 "build.cmd" "restore" + + // Reference the freshly built compiler + let fullPath = cfg2.FSCBinPath |> getFullPath + + let cfg3 = testConfig "repos/FSharpPlus/src/FSharpPlus" + + // Debug build isn't working + //dotnet cfg3 "msbuild" [ + // "FSharpPlus.fsproj" + // "/p:Configuration=Debug" + // "/p:CompilerTest=true" + // sprintf "/p:FSC_ToolPathCompilerBuild=%s" fullPath + // sprintf "/p:FSC_ExePathCompilerBuild=%s" (fullPath ++ "fsc.exe") + //] + + dotnet cfg3 "build" [ + "/p:Configuration=Release" + "/p:CompilerTest=true" + "/p:TargetFramework=net45" + sprintf "/p:FSC_ToolPathCompilerBuild=%s" fullPath + sprintf "/p:FSC_ExePathCompilerBuild=%s" (fullPath ++ "fsc.exe") + "FSharpPlus.fsproj" + ] + + [] + let testFSharpPlusTests () = + let cfg = testConfig "repos/FSharpPlus/tests/FSharpPlus.Tests" + + // Reference the freshly built compiler + let fullPath = cfg.FSCBinPath |> getFullPath + + // Debug build isn't working + //dotnet cfg "msbuild" [ + // "FSharpPlus.Tests.fsproj" + // "/p:Configuration=Debug" + // "/p:CompilerTest=true" + // sprintf "/p:FSC_ToolPathCompilerBuild=%s" fullPath + // sprintf "/p:FSC_ExePathCompilerBuild=%s" (fullPath ++ "fsc.exe") + //] + + dotnet cfg "build" [ + "/p:Configuration=Release" + "/p:CompilerTest=true" + "/p:TargetFramework=net45" + sprintf "/p:FSC_ToolPathCompilerBuild=%s" fullPath + sprintf "/p:FSC_ExePathCompilerBuild=%s" (fullPath ++ "fsc.exe") + "FSharpPlus.Tests.fsproj" + ] + + // Debug build isn't working so no testing of it + //nunit cfg [ + // "--verbose" + // "./bin/Debug/FSharpPlus.Tests.dll" + //] + + nunit cfg [ + "--verbose" + (cfg.Directory ++ "./bin/Release/net45/FSharpPlus.Tests.dll" |> getFullPath) + ] +#endif + // These tests are enabled for .NET Framework and .NET Core [] let ``access-FSC_BASIC``() = singleTestBuildAndRun "core/access" FSC_BASIC