Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 46 additions & 3 deletions tests/fsharp/test-framework.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>
Expand All @@ -132,7 +146,9 @@ type TestConfig =
PEVERIFY : string
Directory: string
DotNetExe: string
DefaultPlatform: string}
DefaultPlatform: string
GitExe: string
NunitConsoleRunner: string }


module WindowsPlatform =
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -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 "---------------------------------------------------------------"
Expand Down Expand Up @@ -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()
Expand Down
78 changes: 78 additions & 0 deletions tests/fsharp/tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
[<Test>]
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"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the --branch argument to git clone to clone at a specific commit


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"
]

[<Test>]
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
[<Test>]
let ``access-FSC_BASIC``() = singleTestBuildAndRun "core/access" FSC_BASIC
Expand Down