Skip to content

Commit 9129c34

Browse files
enricosadaKevinRansom
authored andcommitted
Squashed commit of the following:
Merge branch 'up_nunit3_final' of https://github.com/enricosada/visualfsharp into enricosada-up_nunit3_final git stats tests disable failing tests from ci ( using NO_CI tag ) - core/load-script - core/members/basics - typeProviders/negTests Merge branch 'visualfsharp' into up_nunit3_final Merge pull request #757 from enricosada/remove_nodes_from_tests_proj excluded files (not in build) from fsharp suite project excluded files (not in build) from fsharp suite project fix upload xml tests results fsharp tests suite, parallelize tests execution by testfixture cleanup quote peverify path argument removed unused categories fix false negative, the bat does not check fsi errorlevel (was 1 instead of 0) remove duplicated code updated test to latest version test tests/fsharp/core/load-script is a false positive fixed the test, the result is same as the new implementation diff.exe does not support anymore the -dew argument update to latest version of bat (previous version was a false positive) Seq.take throws if less items than count, Seq.truncate return up to count items nunit 3 breaking change, TestCaseSourceAttribute require a static method ignore env var ILX_CONFIG fix build use nunit 2 xml format use fsx instead of powershell upgrade from nunit-console.exe (nunit v2) to nunit3-console.exe (nunit v3) remove unused
1 parent c4de13e commit 9129c34

17 files changed

+198
-1132
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#r "System.Core.dll"
2+
3+
open System
4+
5+
type CmdArgs = { IncludeCategories: string option; ExcludeCategories: string option }
6+
7+
type Expr =
8+
| And of Expr list
9+
| Or of Expr list
10+
| Equal of Prop * string
11+
| NotEqual of Prop * string
12+
and Prop =
13+
| Category
14+
| Property of string
15+
16+
let toWhereExpr (cmdArgs: CmdArgs) =
17+
18+
let split (line: string) =
19+
line.Split([| "," |], StringSplitOptions.RemoveEmptyEntries)
20+
|> Array.map (fun s -> s.Trim())
21+
|> List.ofArray
22+
23+
let includesList =
24+
cmdArgs.IncludeCategories
25+
|> Option.map split
26+
|> function None -> [] | Some l -> l
27+
let excludesList =
28+
cmdArgs.ExcludeCategories
29+
|> Option.map split
30+
|> function None -> [] | Some l -> l
31+
32+
let il = includesList |> List.map (fun c -> Equal(Category, c)) |> Or
33+
34+
let el = excludesList |> List.map (fun c -> NotEqual(Category, c)) |> And
35+
36+
And([il; el])
37+
38+
let rec exprToString (w: Expr) =
39+
let addParens = sprintf "(%s)"
40+
let sanitize (s: string) = if s.Contains(" ") then sprintf "'%s'" s else s
41+
let propS p = match p with Category -> "cat" | Property name -> sanitize name
42+
43+
match w with
44+
| And [] -> None
45+
| Or [] -> None
46+
| And l ->
47+
match l |> List.map exprToString |> List.choose id with
48+
| [] -> None
49+
| [x] -> Some x
50+
| xs -> Some (xs |> List.map addParens |> String.concat " and ")
51+
| Or l ->
52+
match l |> List.map exprToString |> List.choose id with
53+
| [] -> None
54+
| [x] -> Some x
55+
| xs -> Some (xs |> List.map addParens |> String.concat " or ")
56+
| Equal (prop, v) -> Some (sprintf "%s == %s" (propS prop) (sanitize v))
57+
| NotEqual (prop, v) -> Some (sprintf "%s != %s" (propS prop) (sanitize v))
58+
59+
let parseCmdArgs (args: string list) =
60+
match args with
61+
| [a; b] -> { IncludeCategories = Some a; ExcludeCategories = Some b }
62+
| xs -> failwithf "Invalid arguments %A" xs
63+
64+
let main args =
65+
args
66+
|> parseCmdArgs
67+
|> toWhereExpr
68+
|> exprToString
69+
|> function None -> "" | Some s -> s
70+
|> printfn "%s"
71+
72+
let rec getScriptArgs l =
73+
match l with
74+
| [] -> []
75+
| "--" :: rest -> rest
76+
| _ :: tail -> getScriptArgs tail
77+
78+
try
79+
Environment.GetCommandLineArgs()
80+
|> List.ofArray
81+
|> getScriptArgs
82+
|> main
83+
exit 0
84+
with e ->
85+
printfn "%s" e.Message
86+
exit 1

tests/RunTests.cmd

+27-11
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ if not exist "%~dp0%..\packages\NUnit.Console.3.0.0\tools\" (
1818
popd
1919
)
2020
SET NUNIT3_CONSOLE=%~dp0%..\packages\NUnit.Console.3.0.0\tools\nunit3-console.exe
21+
SET LKG_FSI=%~dp0%..\lkg\FSharp-14.0.23413.0\bin\Fsi.exe
2122

2223
rem "ttags" indicates what test areas will be run, based on the tags in the test.lst files
2324
set TTAGS_ARG=
@@ -63,6 +64,29 @@ rem folder where test logs/results will be dropped
6364
set RESULTSDIR=%~dp0\TestResults
6465
if not exist "%RESULTSDIR%" (mkdir "%RESULTSDIR%")
6566

67+
setlocal EnableDelayedExpansion
68+
69+
SET CONV_V2_TO_V3_CMD="%LKG_FSI%" --exec --nologo "%~dp0%\Convert-NUnit2Args-to-NUnit3Where.fsx" -- "!TTAGS!" "!NO_TTAGS!"
70+
echo %CONV_V2_TO_V3_CMD%
71+
72+
SET CONV_V2_TO_V3_CMD_TEMPFILE=%~dp0%nunit3args.txt
73+
74+
%CONV_V2_TO_V3_CMD% >%CONV_V2_TO_V3_CMD_TEMPFILE%
75+
76+
IF ERRORLEVEL 1 (
77+
echo Error converting args to nunit 3 test selection language, the nunit3-console --where argument
78+
type "%CONV_V2_TO_V3_CMD_TEMPFILE%"
79+
del /Q "%CONV_V2_TO_V3_CMD_TEMPFILE%"
80+
exit /b 1
81+
)
82+
83+
set /p TTAGS_NUNIT_WHERE=<%CONV_V2_TO_V3_CMD_TEMPFILE%
84+
if not '!TTAGS_NUNIT_WHERE!' == '' (set TTAGS_NUNIT_WHERE=--where "!TTAGS_NUNIT_WHERE!")
85+
86+
del /Q "%CONV_V2_TO_V3_CMD_TEMPFILE%"
87+
88+
setlocal DisableDelayedExpansion
89+
6690
if /I "%2" == "fsharp" (goto :FSHARP)
6791
if /I "%2" == "fsharpqa" (goto :FSHARPQA)
6892
if /I "%2" == "fsharpqadowntarget" (goto :FSHARPQA)
@@ -129,17 +153,9 @@ goto :EOF
129153

130154
set FSHARP_TEST_SUITE_CONFIGURATION=%FLAVOR%
131155

132-
set XMLFILE=%RESULTSDIR%\FSharpNunit_Xml.xml
133-
set OUTPUTFILE=%RESULTSDIR%\FSharpNunit_Output.log
134-
set ERRORFILE=%RESULTSDIR%\FSharpNunit_Error.log
135-
136-
setlocal EnableDelayedExpansion
137-
138-
set TTAGS_NUNIT_ARG=
139-
if not '!TTAGS!' == '' (set TTAGS_NUNIT_ARG=--where "cat == !TTAGS!")
140-
141-
set NO_TTAGS_NUNIT_ARG=
142-
rem if not '!NO_TTAGS!' == '' (set NO_TTAGS_NUNIT_ARG=--where "cat != !NO_TTAGS!")
156+
set XMLFILE=FSharpNunit_Xml.xml
157+
set OUTPUTFILE=FSharpNunit_Output.log
158+
set ERRORFILE=FSharpNunit_Error.log
143159

144160
echo "%NUNIT3_CONSOLE%" "%FSCBINPATH%\FSharp.Tests.FSharp.dll" --framework:V4.0 !TTAGS_NUNIT_ARG! !NO_TTAGS_NUNIT_ARG! --work="%FSCBINPATH%" --output="%OUTPUTFILE%" --err="%ERRORFILE%" --result="%XMLFILE%;format=nunit2"
145161
"%NUNIT3_CONSOLE%" "%FSCBINPATH%\FSharp.Tests.FSharp.dll" --framework:V4.0 !TTAGS_NUNIT_ARG! !NO_TTAGS_NUNIT_ARG! --work="%FSCBINPATH%" --output="%OUTPUTFILE%" --err="%ERRORFILE%" --result="%XMLFILE%;format=nunit2"

tests/fsharp/Commands.fs

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ let internal quotepath (p: FilePath) =
109109
let ildasm exec ildasmExe flags assembly =
110110
exec ildasmExe (sprintf "%s %s" flags (quotepath assembly))
111111

112-
let peverify exec peverifyExe path =
113-
exec peverifyExe path
112+
let peverify exec peverifyExe flags path =
113+
exec peverifyExe (sprintf "%s %s" (quotepath path) flags)
114114

115115
let createTempDir () =
116116
let path = Path.GetTempFileName ()
@@ -142,9 +142,9 @@ let where envVars cmd =
142142
| ErrorLevel _ -> None
143143
| CmdResult.Success -> !result
144144

145-
let fsdiff exec fsdiffExe ignoreWhiteSpaceChanges file1 file2 =
145+
let fsdiff exec fsdiffExe file1 file2 =
146146
// %FSDIFF% %testname%.err %testname%.bsl
147-
exec fsdiffExe (sprintf "%s%s %s" (if ignoreWhiteSpaceChanges then "-dew " else "") file1 file2)
147+
exec fsdiffExe (sprintf "%s %s" file1 file2)
148148

149149
let ``for /f`` path =
150150
// FOR /F processing of a text file consists of reading the file, one line of text at a time and then breaking the line up into individual

0 commit comments

Comments
 (0)