Skip to content

Commit

Permalink
Migrate "fsharpqa" suite to use NUnit
Browse files Browse the repository at this point in the history
commit 9db27bae8df0444f794b70b12c4873cf55af08fc
Merge: 2597c84 fc0ac12
Author: KevinRansom <codecutter@hotmail.com>
Date:   Thu Jan 21 16:49:35 2016 -0800

    Merge branch 'fsharpqa_nunit' of https://github.com/enricosada/visualfsharp into enricosada-fsharpqa_nunit

commit fc0ac12
Author: enricosada <enrico@sada.io>
Date:   Thu Jan 14 11:22:01 2016 +0100

    add support for "<<OUTPUT" match

commit c74d920
Author: enricosada <enrico@sada.io>
Date:   Wed Jan 13 12:59:55 2016 +0100

    FIX TEST SPEC: use lowercase name for status attribute

commit a86bb3b
Author: enricosada <enrico@sada.io>
Date:   Tue Jan 12 23:16:25 2016 +0100

    FIX TEST SPEC: use valid xml

commit 12d683d
Author: enricosada <enrico@sada.io>
Date:   Tue Jan 12 17:53:45 2016 +0100

    deprecate some helper functions in tests

    attempt instead of processor computation
    ++ instead of / for Path.Combine

commit e2d38c9
Author: enricosada <enrico@sada.io>
Date:   Sun Jan 10 17:33:03 2016 +0100

    add fsharpqa tests
  • Loading branch information
enricosada authored and KevinRansom committed Jan 22, 2016
1 parent 2597c84 commit 736e9c1
Show file tree
Hide file tree
Showing 13 changed files with 2,301 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/fsharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{E49B77EA
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Tests", "..\tests\fsharp\FSharp.Tests.fsproj", "{C163E892-5BF7-4B59-AA99-B0E8079C67C4}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpQA.Tests", "..\tests\fsharpqa\Source\FSharpQA.Tests.fsproj", "{21958DEB-133B-4760-A238-1293ED9687EC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -89,6 +91,10 @@ Global
{C163E892-5BF7-4B59-AA99-B0E8079C67C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C163E892-5BF7-4B59-AA99-B0E8079C67C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C163E892-5BF7-4B59-AA99-B0E8079C67C4}.Release|Any CPU.Build.0 = Release|Any CPU
{21958DEB-133B-4760-A238-1293ED9687EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21958DEB-133B-4760-A238-1293ED9687EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21958DEB-133B-4760-A238-1293ED9687EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21958DEB-133B-4760-A238-1293ED9687EC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -97,5 +103,6 @@ Global
{88E2D422-6852-46E3-A740-83E391DC7973} = {E49B77EA-64DE-451A-A5E6-A6632FC1F03C}
{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5} = {E49B77EA-64DE-451A-A5E6-A6632FC1F03C}
{C163E892-5BF7-4B59-AA99-B0E8079C67C4} = {E49B77EA-64DE-451A-A5E6-A6632FC1F03C}
{21958DEB-133B-4760-A238-1293ED9687EC} = {E49B77EA-64DE-451A-A5E6-A6632FC1F03C}
EndGlobalSection
EndGlobal
15 changes: 12 additions & 3 deletions tests/fsharp/PlatformHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ type AttemptBuilder() =
this.While(enum.MoveNext,
this.Delay(fun () -> body enum.Current)))

let processor = new AttemptBuilder()

let attempt = new AttemptBuilder()
let processor = attempt //TODO deprecated

let log format = Printf.ksprintf (printfn "%s") format

Expand All @@ -201,4 +201,13 @@ let redirectTo (writer: TextWriter) =

let redirectToLog () = redirectTo System.Console.Out

let inline (/) a (b: string) = System.IO.Path.Combine(a,b)
let inline (++) a (b: string) = System.IO.Path.Combine(a,b)
let inline (/) a b = a ++ b //TODO deprecated

let splitAtFirst (c: char -> bool) (s: string) =
let rec helper x (rest: string) =
match x with
| [] -> rest, None
| x :: xs when c(x) -> rest, Some (xs |> Array.ofList |> System.String)
| x :: xs -> helper xs (rest + x.ToString())
helper (s.ToCharArray() |> List.ofArray) ""
5 changes: 5 additions & 0 deletions tests/fsharpqa/Source/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#ignore all build outputs
*.exe
*.dll
*.pdb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// #Regression #Conformance #LexicalAnalysis
// string embedded in a comment: malformed string
// which yield to a compilation error
//<Expects Status="error" id="FS0517" span="(9,1-9,3)>End of file in string embedded in comment begun at or before here</Expects>
//<Expects status="error" id="FS0517" span="(9,1-9,3)>End of file in string embedded in comment begun at or before here</Expects>



Expand Down
87 changes: 87 additions & 0 deletions tests/fsharpqa/Source/EnvLst.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
module EnvLst

open System

open PlatformHelpers

type EnvLstFile = EnvLstLine list
and EnvLstLine =
| Comment of string
| Data of EnvLstLineData
and EnvLstLineData = {
Tags: string list
Vars: (string * string) list
Comment: string option }

let private (|Comment|_|) (s: string) =
match s with
| s when s.StartsWith("#") -> Some (s.TrimStart([| '#' |]))
| _ -> None

[<RequireQualifiedAccess>]
type private DataPart =
| Var of string * string
| Comment of string

let private parseDataParts (from: string) =
let rec parseDataPartsHelper (v: string) xs =
match (v.TrimStart()) with
| s when s.Trim() = "" ->
Choice1Of2 xs
| Comment (comment) ->
Choice1Of2 (DataPart.Comment comment :: xs)
| s ->
match s |> splitAtFirst ((=) '=') with
| name, None ->
Choice2Of2 (sprintf "Expected '=' after %s" name)
| name, Some(v) ->
match v.TrimStart() with
| a when a.StartsWith("\"") -> //quoted (escape char \ ), like SOURCE="some value with spaces"
let rec innerQuote (alreadyParsed: string) (s: string) =
let current, rest = match s with "" -> "","" | x -> (x.Substring(0,1)), (x.Substring(1))
match alreadyParsed, current, rest with
| pre, "", _ ->
pre, ""
| pre, "\"", xs when pre.EndsWith("\\") -> //escaped "
innerQuote (pre + "\"") xs
| pre, "\"", xs -> //final "
pre, xs
| pre, x, xs ->
innerQuote (pre + x) xs
let value, rest = innerQuote "" (a.Substring(1))
parseDataPartsHelper rest (DataPart.Var(name, value) :: xs)
| a -> //unquoted, like SOURCE=avalue
let value, rest =
match a |> splitAtFirst Char.IsWhiteSpace with
| p0, None -> p0, ""
| p0, Some (rest) -> p0, rest
parseDataPartsHelper rest (DataPart.Var(name, value) :: xs)

match parseDataPartsHelper from [] with
| Choice1Of2 parts -> parts |> List.rev |> Choice1Of2
| failure -> failure

let parseLine (line: string) =
match line with
| s when s.Trim() = "" -> Choice1Of2 None
| Comment(comment) -> Comment (comment) |> Some |> Choice1Of2
| s ->
match s |> splitAtFirst ((=) '\t') with
| s, None -> Choice2Of2 (sprintf "Expected '\\t' not found")
| tagList, Some rest ->
let tags = tagList.Split([| " " |], StringSplitOptions.RemoveEmptyEntries)
match parseDataParts rest with
| Choice1Of2 parts ->
let vars =
parts
|> List.choose (function DataPart.Var (k,v) -> Some (k,v) | _ -> None)
let comment =
parts
|> List.choose (function DataPart.Comment c -> Some c | _ -> None)
|> List.tryHead
Data { Tags = tags |> List.ofArray; Vars = vars; Comment = comment }
|> Some |> Choice1Of2
| Choice2Of2 failure ->
Choice2Of2 failure


88 changes: 88 additions & 0 deletions tests/fsharpqa/Source/FSharpQA.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<FSharpSourcesRoot>..\..\..\src</FSharpSourcesRoot>
<FSharpTestsRoot>..\..\..\tests</FSharpTestsRoot>
<ProjectGuid>{21958DEB-133B-4760-A238-1293ED9687EC}</ProjectGuid>
</PropertyGroup>
<Import Project="$(FSharpSourcesRoot)\FSharpSource.Settings.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<AllowCrossTargeting>true</AllowCrossTargeting>
<ReferenceVsAssemblies>true</ReferenceVsAssemblies>
<OutputType>Library</OutputType>
<AssemblyName>FSharp.Tests.FSharpQA</AssemblyName>
<Name>SystematicUnitTests</Name>
<!-- Prevent compiler from inlining calls to FSharp.Core to improve code coverage accuracy -->
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);EXTENSIONTYPING</DefineConstants>
<NoWarn>$(NoWarn);3180</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>3</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>3</WarningLevel>
</PropertyGroup>
<Import Project="$(FSharpSourcesRoot)\FSharpSource.targets" />
<ItemGroup>
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj">
<Project>{DED3BBD7-53F4-428A-8C9F-27968E768605}</Project>
<Name>FSharp.Core</Name>
</ProjectReference>
<Reference Include="mscorlib" />
<Reference Include="nunit.framework">
<HintPath>..\..\..\packages\NUnit.3.0.0\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(FSharpTestsRoot)\fsharp\PlatformHelpers.fs">
<Link>PlatformHelpers.fs</Link>
</Compile>
<Compile Include="$(FSharpTestsRoot)\fsharp\Commands.fs">
<Link>Commands.fs</Link>
</Compile>
<Compile Include="$(FSharpTestsRoot)\fsharp\FSharpTestSuiteTypes.fs">
<Link>FSharpTestSuiteTypes.fs</Link>
</Compile>
<Compile Include="$(FSharpTestsRoot)\windowsPlatform.fs">
<Link>windowsPlatform.fs</Link>
</Compile>
<Compile Include="$(FSharpTestsRoot)\config.fs">
<Link>config.fs</Link>
</Compile>
<Compile Include="$(FSharpSourcesRoot)\update.fs">
<Link>update.fs</Link>
</Compile>
<Compile Include="EnvLst.fs" />
<Compile Include="nunitConf.fs" />
<Compile Include="run.fs" />
</ItemGroup>
<ItemGroup>
<Compile Include="test_EnvLst.fs" />
</ItemGroup>
<ItemGroup>
<Compile Include="test_simple.fs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// #Regression #NoMT #FSI
// Regression test for FSHARP1.0:5427
//<Expects Status="success"></Expects>
//<Expects status="success"></Expects>

//<<Output
//let f x = x \+ 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// This test should probably go under the SystematicUnitTests suite, but
// I could not decide how to make it fit... so I'm leaving it here.
//
//<Expect status=success><Expect>
//<Expect status="success"></Expect>

let mutable dispose_called_in_E = 0 // we expect this to be incremented 3 times
let mutable dispose_called_in_C = 0 // we expect this to be incremented once (=this is what the bug was about, i.e. .Dispose() was never invoked)
Expand Down
2 changes: 1 addition & 1 deletion tests/fsharpqa/Source/Simple/hellow.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//<Expects Status=success></Expects>
//<Expects status="success"></Expects>

//<<Output
//Hello, world.
Expand Down
Loading

0 comments on commit 736e9c1

Please sign in to comment.