diff --git a/tests/fsharpqa/Source/run.fs b/tests/fsharpqa/Source/run.fs index 240fd8f4788..58b17b34693 100644 --- a/tests/fsharpqa/Source/run.fs +++ b/tests/fsharpqa/Source/run.fs @@ -253,6 +253,7 @@ type ExpectedResults = | CmdLine of string | ExpectMatch of string * string | ExpectNotMatch of string + | ExeOutputMatch of string list // ############################################################# // # GetExpectedResults -- @@ -346,8 +347,19 @@ let GetExpectedResults cwd (srcListSepByBlank: string) = let first,_ = src |> PlatformHelpers.splitAtFirst System.Char.IsWhiteSpace src <- first //grab only the first source file + let srcPath = src |> getfullpath + //open SRC, $src or RunExit(TEST_FAIL, "GetExpectedResults::Can't open source file: $src: $!\n"); - let SRC = System.IO.File.ReadLines (src |> getfullpath) + let SRC () = srcPath |> System.IO.File.ReadLines + + // parse //< Seq.skipWhile ((<>) "//< List.ofSeq + |> function x :: xs -> xs | [] -> [] + |> List.takeWhile ((<>) "//Output") + |> List.map (fun line -> line.TrimStart('/')) //########################################################## @@ -362,7 +374,7 @@ let GetExpectedResults cwd (srcListSepByBlank: string) = Choice2Of2 e //ITEM: while() { - SRC + SRC () |> Seq.map (fun line -> line.TrimStart()) //ignore whitespace before // |> Seq.choose (fun line -> if line.StartsWith("//") then Some (line.TrimStart('/')) else None) //only comments `//` |> Seq.choose (fun line -> @@ -557,7 +569,12 @@ let GetExpectedResults cwd (srcListSepByBlank: string) = |> List.choose (fun level -> seekHash |> Map.tryFind level) |> List.fold max 0 - succeed (levelMax, expects) + let expectExeOutput = + match Output with + | [] -> [] + | l -> [ExeOutputMatch l] + + succeed (levelMax, expects @ expectExeOutput) | f :: fs -> fs |> List.iter (log "test spec error: %s") NUnitConf.genericError f @@ -1059,8 +1076,6 @@ let runpl cwd initialEnvVars = attempt { let! mType, dd = GetExpectedResults sources let Type = mType - let Output = "" //TODO temp, need to check what is the real value - //################################################################################# //# Compiling.......... //# @@ -1276,7 +1291,7 @@ let runpl cwd initialEnvVars = attempt { // # Running the EXE // # // # Now we scan the output of the EXE if we must - let checkRunningExe () = attempt { + let checkRunningExe expectedExeOutput () = attempt { //my $status = TEST_PASS; let status = TEST_PASS @@ -1386,7 +1401,27 @@ let runpl cwd initialEnvVars = attempt { // } //} //print("\n"); - TODO "check output" + do! match expectedExeOutput with + | None -> + Success + | Some [] -> + Success + | Some (x :: xs) -> + let possible = + commandOutput.Split([| System.Environment.NewLine |], StringSplitOptions.RemoveEmptyEntries) + |> Array.skipWhile ((<>) x) + |> Array.truncate (x::xs |> List.length) + |> List.ofArray + + if (x :: xs) = possible then + printfn "Output match: [passed]" + Success + else + printfn "Output match: [failed]" + printfn "Output:" + printfn "%s" commandOutput + NUnitConf.genericError "exe output doesnt match" + //RunExit(TEST_FAIL, "Generated Test EXE Failed \n") if ($ExitCode); do! if (exitCode <> 0) then @@ -1419,6 +1454,9 @@ let runpl cwd initialEnvVars = attempt { } //} + let expectedExeOutput = + dd |> List.tryPick (function ExeOutputMatch(l) -> Some l | _ -> None) + // # If this is a compile only run, call post command and exit //if ($compileOnlyRun) { return! @@ -1427,7 +1465,7 @@ let runpl cwd initialEnvVars = attempt { else attempt { //if ($targetType == TARGET_EXE) { do! if targetType = TARGET_EXE then - checkRunningExe () + checkRunningExe expectedExeOutput () else Success diff --git a/tests/fsharpqa/Source/test_simple.fs b/tests/fsharpqa/Source/test_simple.fs index 9e0dd2959f8..9ea853f302e 100644 --- a/tests/fsharpqa/Source/test_simple.fs +++ b/tests/fsharpqa/Source/test_simple.fs @@ -8,14 +8,12 @@ open NUnitConf open PlatformHelpers open FSharpTestSuiteTypes -let testContext = FSharpTestSuite.testContext -let envLstData = FSharpQATestSuite.envLstData - let runpl = attempt { - let { Directory = dir; Config = cfg } = testContext () - let! vars = envLstData () + let { Directory = dir; Config = cfg } = FSharpTestSuite.testContext () + let! vars = FSharpQATestSuite.envLstData () + printfn "Directory: %s" dir printfn "%A" vars let allVars = @@ -64,8 +62,18 @@ module CompilerOptions_fsc_cliversion = let cliversion () = runpl |> check -//codepage -//crossoptimize +module CompilerOptions_fsc_codepage = + + [] + let codepage () = + runpl |> check + +module CompilerOptions_fsc_crossoptimize = + + [] + let crossoptimize () = + runpl |> check + module CompilerOptions_fsc_debug = @@ -73,13 +81,47 @@ module CompilerOptions_fsc_debug = let debug () = runpl |> check -//dumpAllCommandLineOptions -//flaterrors -//gccerrors -//help -//highentropyva -//invalid -//lib +module CompilerOptions_fsc_dumpAllCommandLineOptions = + + [] + let dumpAllCommandLineOptions () = + runpl |> check + +module CompilerOptions_fsc_flaterrors = + + [] + let flaterrors () = + runpl |> check + +module CompilerOptions_fsc_gccerrors = + + [] + let gccerrors () = + runpl |> check + +module CompilerOptions_fsc_help = + + [] + let help () = + runpl |> check + +module CompilerOptions_fsc_highentropyva = + + [] + let highentropyva () = + runpl |> check + +module CompilerOptions_fsc_invalid = + + [] + let invalid () = + runpl |> check + +module CompilerOptions_fsc_lib = + + [] + let lib () = + runpl |> check module CompilerOptions_fsc_noframework =