Skip to content
Closed
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
34 changes: 32 additions & 2 deletions tests/fsharpqa/run.fsharpqa.test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

open System.IO
open System.Diagnostics

type Env = System.Environment
let releaseOrDebug = "Debug"
let setEnvVar name value =
System.Environment.SetEnvironmentVariable(name, value)
Expand All @@ -17,27 +17,57 @@ let addToPath path =

let rootFolder = Path.Combine(__SOURCE_DIRECTORY__, "..", "..")
let compilerBinFolder = Path.Combine(rootFolder, releaseOrDebug, "net40", "bin")

// this needs to be kept in sync with something else somewhere else
// this is probably outdated
setEnvVar "CSC_PIPE" (Path.Combine(rootFolder, "packages", "Microsoft.Net.Compilers.2.7.0", "tools", "csc.exe"))
setEnvVar "FSC" (Path.Combine(compilerBinFolder, "fsc.exe"))
setEnvVar "FSCOREDLLPATH" (Path.Combine(compilerBinFolder, "FSharp.Core.dll"))

addToPath compilerBinFolder

let runPerl arguments =
// a bit expeditive, but does the deed
Process.GetProcessesByName("perl") |> Array.iter (fun p -> p.Kill())
use perlProcess = new Process()
perlProcess.StartInfo.set_FileName (Path.Combine(rootFolder, "packages", "StrawberryPerl64.5.22.2.1", "Tools", "perl", "bin", "perl.exe"))
let userRoot = Env.SpecialFolder.UserProfile |> Env.GetFolderPath

let perlExe =
[| userRoot
".nuget"
"packages"
"strawberryperl64"
"5.22.2.1"
"Tools"
"perl"
"bin"
"perl.exe" |]
|> Path.Combine
|> FileInfo

if not perlExe.Exists then failwithf "couldn't find %s, please adjust this script" perlExe.FullName else

printfn "found perl.exe in %s" perlExe.Directory.FullName

perlProcess.StartInfo.set_FileName (perlExe.FullName)
perlProcess.StartInfo.set_Arguments (arguments |> Array.map(fun a -> @"""" + a + @"""") |> String.concat " ")
perlProcess.StartInfo.set_WorkingDirectory (Path.Combine(rootFolder, "tests", "fsharpqa", "source"))
perlProcess.StartInfo.set_RedirectStandardOutput true
perlProcess.StartInfo.set_RedirectStandardError true
perlProcess.StartInfo.set_UseShellExecute false

printfn "starting perl.exe from directory: %s\nwith arguments: %s" perlProcess.StartInfo.WorkingDirectory perlProcess.StartInfo.Arguments

perlProcess.Start() |> ignore

while (not perlProcess.StandardOutput.EndOfStream) do
perlProcess.StandardOutput.ReadLine() |> printfn "%s"

while (not perlProcess.StandardError.EndOfStream) do
perlProcess.StandardError.ReadLine() |> printfn "%s"

perlProcess.WaitForExit()

if perlProcess.ExitCode <> 0 then
failwithf "exit code: %i" perlProcess.ExitCode

Expand Down