Skip to content

Commit

Permalink
Merge branch 'develop/github/maintenance' into develop/Indori
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/main.yml
#	AltCover.Engine/Visitor.fs
#	ReleaseNotes.md
#	global.json
  • Loading branch information
SteveGilham committed Aug 17, 2024
2 parents f18b439 + 2afa553 commit f40275b
Show file tree
Hide file tree
Showing 33 changed files with 308 additions and 62 deletions.
6 changes: 4 additions & 2 deletions AltCover.Api.Tests/FSApiTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ module FSApiTests =
|> Seq.iter (fun a -> a.Value <- "false")

let cob =
CoverageFormats.ConvertToCobertura doc
CoverageFormats.ConvertToCobertura doc []

use stream2 = new MemoryStream()
cob.Save stream2
Expand Down Expand Up @@ -947,7 +947,7 @@ module FSApiTests =
|> Seq.iter (fun a -> a.Value <- "false")

let cob =
CoverageFormats.ConvertToCobertura doc
CoverageFormats.ConvertToCobertura doc [ "d:/a01/_work/5/s/src/" ]

use stream2 = new MemoryStream()
cob.Save stream2
Expand Down Expand Up @@ -1200,6 +1200,8 @@ module FSApiTests =

let collectFragments =
[ DotNet.I.toCollectFromArgArgumentList
>> (List.map (fun (_, n, _) -> n))
DotNet.I.toCollectListArgArgumentList
>> (List.map (fun (_, n, _) -> n))
_.Verbosity
>> DotNet.I.toSharedFromValueArgumentList
Expand Down
7 changes: 6 additions & 1 deletion AltCover.Cake/Options.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Linq;

using FSDotNet = AltCover.DotNet;

Expand Down Expand Up @@ -326,6 +326,11 @@ public class CollectOptions : Abstract.ICollectOptions
Justification = "Lcov is a name")]
public virtual string Cobertura => String.Empty;

///<summary>
/// Corresponds to command line option `-p, --package=VALUE`
///</summary>
public IEnumerable<string> Packages => Enumerable.Empty<string>();

///<summary>
/// Corresponds to command line option `-o, --outputFile=VALUE`
///</summary>
Expand Down
18 changes: 16 additions & 2 deletions AltCover.DotNet/DotNet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ module DotNet =
let private arg name (s: string) = (sprintf """AltCover%s""" name, s)

let private listArg name (s: String seq) =
(sprintf """AltCover%s""" name, String.Join("|", s))
(sprintf """AltCover%s""" name, String.Join("|", s) + "|")

let private isSet s = s |> String.IsNullOrWhiteSpace |> not

let private fromList name (s: String seq) = (listArg name s, s.Any())
let private fromList name (s: String seq) =
let s' =
s |> Seq.filter (String.IsNullOrWhiteSpace >> not)

(listArg name s', s'.Any())

let internal fromArg name s = (arg name s, isSet s)
let internal fromValue name (s: obj) (b: bool) = (arg name <| s.ToString(), b)

Expand Down Expand Up @@ -136,6 +141,12 @@ module DotNet =
fromArg, "Threshold", collect.Threshold //=`"coverage threshold required"
fromArg, "SummaryFormat", collect.SummaryFormat ] //=[BROCN+]` one or more of TeamCity Block format/TeamCity bRanch format/Classic OpenCover/CRAP score or none at all; `+` means the same as `OC` which is also the default

[<SuppressMessage("Gendarme.Rules.Design.Generic",
"AvoidMethodWithUnusedGenericTypeRule",
Justification = "It just be like that")>]
let internal toCollectListArgArgumentList (collect: Abstract.ICollectOptions) =
[ fromList, "Packages", collect.Packages ] //=`"pipe `'|'` separated list of method name regexs"

let internal toSharedFromValueArgumentList
(verbosity: System.Diagnostics.TraceLevel)
: ((string -> obj -> bool -> (string * string) * bool) * string * obj * bool) list =
Expand Down Expand Up @@ -181,6 +192,9 @@ module DotNet =
collect
|> I.toCollectFromArgArgumentList
|> List.map (fun (f, n, a) -> f n a)
collect
|> I.toCollectListArgArgumentList
|> List.map (fun (f, n, a) -> f n a)

Math.Min(int prepare.Verbosity, int collect.Verbosity)
|> enum<System.Diagnostics.TraceLevel>
Expand Down
4 changes: 4 additions & 0 deletions AltCover.DotNet/DotNet.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ module DotNet = begin
val toCollectFromArgArgumentList :
collect:Abstract.ICollectOptions ->
((string -> string -> (string*string)* bool) * string * System.String) list
val toCollectListArgArgumentList :
collect:Abstract.ICollectOptions ->
((string -> #seq<System.String> -> (string*string) * bool) * string *
System.String seq) list
val toSharedFromValueArgumentList :
verbosity : System.Diagnostics.TraceLevel ->
((string -> obj -> bool -> (string*string)*bool) * string * obj * bool) list
Expand Down
4 changes: 4 additions & 0 deletions AltCover.DotNet/Options.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ module Options =
Justification = "Cobertura is a name")>]
member val Cobertura = String.Empty with get, set

member val Packages = Seq.empty<String> with get, set

member val OutputFile = String.Empty with get, set
member val CommandLine = Seq.empty<String> with get, set
member val ExposeReturnCode = true with get, set
Expand Down Expand Up @@ -71,6 +73,8 @@ module Options =
Justification = "Cobertura is a name")>]
member self.Cobertura = self.Cobertura

member self.Packages = self.Packages

member self.OutputFile = self.OutputFile
member self.CommandLine = self.CommandLine

Expand Down
4 changes: 4 additions & 0 deletions AltCover.Engine/Abstract.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ module Abstract =
Justification="Cobertura is a name")>] //// no doc
abstract member Cobertura : String with get
///<summary>
/// Corresponds to command line option `-p, --package=VALUE`
///</summary>
abstract member Packages : IEnumerable<String> with get
///<summary>
/// Corresponds to command line option `-o, --outputFile=VALUE`
///</summary>
abstract member OutputFile : String with get
Expand Down
7 changes: 7 additions & 0 deletions AltCover.Engine/AltCover.fs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ module AltCover =
| Abstract a -> a.Cobertura
| TypeSafe t -> t.Cobertura.AsString()

member self.Packages =
match self with
| Primitive p -> p.Packages
| Abstract a -> a.Packages
| TypeSafe t -> t.Packages.AsStrings()

member self.OutputFile =
match self with
| Primitive p -> p.OutputFile
Expand Down Expand Up @@ -156,6 +162,7 @@ module AltCover =
member self.LcovReport = self.LcovReport
member self.Threshold = self.Threshold
member self.Cobertura = self.Cobertura
member self.Packages = self.Packages
member self.OutputFile = self.OutputFile
member self.CommandLine = self.CommandLine

Expand Down
4 changes: 4 additions & 0 deletions AltCover.Engine/AltCover.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ namespace AltCoverFake.DotNet.Testing
///</summary>
member Cobertura : System.String
///<summary>
/// Corresponds to command line option `-p, --package=VALUE`
///</summary>
member Packages : seq<System.String>
///<summary>
/// Corresponds to command line option `-o, --outputFile=VALUE`
///</summary>
member OutputFile : System.String
Expand Down
7 changes: 7 additions & 0 deletions AltCover.Engine/Args.fs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ module internal Args =
[ parameters; trailing ] |> List.concat

let internal buildCollect (args: Abstract.ICollectOptions) =
let packages =
args.Packages
|> Seq.map (fun p -> [ "-p"; p ])
|> Seq.toList
|> List.concat

let argsList =
args.CommandLine |> Seq.toList

Expand Down Expand Up @@ -156,6 +162,7 @@ module internal Args =
item "-l" args.LcovReport
item "-t" args.Threshold
item "-c" args.Cobertura
packages
item "-o" args.OutputFile
flag "--collect" (exe |> String.IsNullOrWhiteSpace)
flag "--dropReturnCode" (args.ExposeReturnCode |> not)
Expand Down
10 changes: 9 additions & 1 deletion AltCover.Engine/Cobertura.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module internal Cobertura =
let internal path: Option<string> ref =
ref None

let internal packages: string list ref =
ref List.empty<string>

module internal I =

let internal setRate hits total (rate: string) (target: XElement) =
Expand Down Expand Up @@ -157,8 +160,12 @@ module internal Cobertura =
|> Seq.map (fun (a, s) -> a, s |> Seq.map fst)
|> Seq.sortBy fst // seq of (directory, files full names)

let packaged =
packages.Value
|> Seq.map (fun x -> x, Seq.empty<string>)

let groupable = // seq of ((directory, files full names), facets)
rawsources
Seq.concat [ packaged; rawsources ]
|> Seq.map (fun x -> (x, x |> fst |> splitPath))

let groups = // seq of (root, seq of ((directory, files full names), facets))
Expand All @@ -168,6 +175,7 @@ module internal Cobertura =
groups |> Seq.map (snd >> extractSource)

results
|> Seq.sortBy fst
|> Seq.iter (fun f ->
target.Descendants("sources".X)
|> Seq.iter _.Add(XElement("source".X, XText(fst f))))
Expand Down
2 changes: 2 additions & 0 deletions AltCover.Engine/Primitive.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Primitive =
"CA1704:IdentifiersShouldBeSpelledCorrectly",
Justification = "Cobertura is a name")>]
Cobertura: String
Packages: String seq
OutputFile: String
CommandLine: String seq
ExposeReturnCode: bool
Expand All @@ -43,6 +44,7 @@ module Primitive =
LcovReport = String.Empty
Threshold = String.Empty
Cobertura = String.Empty
Packages = []
OutputFile = String.Empty
CommandLine = []
ExposeReturnCode = true
Expand Down
4 changes: 4 additions & 0 deletions AltCover.Engine/Primitive.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ namespace AltCoverFake.DotNet.Testing
///</summary>
Cobertura: System.String
///<summary>
/// Corresponds to command line option `-p, --package=VALUE`
///</summary>
Packages : seq<System.String>
///<summary>
/// Corresponds to command line option `-o, --outputFile=VALUE`
///</summary>
OutputFile: System.String
Expand Down
10 changes: 10 additions & 0 deletions AltCover.Engine/Runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ module internal Runner =
executable.Value <- None
LCov.path.Value <- None
Cobertura.path.Value <- None
Cobertura.packages.Value <- List.empty<string>
Json.path.Value <- None
collect.Value <- false
threshold <- None
Expand Down Expand Up @@ -827,6 +828,15 @@ module internal Runner =
else
Cobertura.path.Value <- x |> canonicalPath |> Some
I.addCoberturaSummary ()))
("p|package=",
(fun x ->
if x |> String.IsNullOrWhiteSpace |> not then
Cobertura.packages.Value <- x :: Cobertura.packages.Value
else
CommandLine.error <-
CommandLine.Format.Local("InvalidValue", "--package", x)
:: CommandLine.error))

("o|outputFile=",
(fun x ->
if CommandLine.validatePath "--outputFile" x then
Expand Down
5 changes: 4 additions & 1 deletion AltCover.Engine/Strings.eo.resx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Vidu ankaŭ '--inplace'</value>
<data name="HelpText" xml:space="preserve">
<value>AltCover [/i[nputDirectory]=VALO] [/o[utputDirectory]=VALO] [/y|symbolDirectory=VALO] [/d[ependency]=VALO] [/k[ey]=VALO] [/sn|strongNameKey=VALO] [/r[eport]=VALO] [/f[ileFilter]=VALO] [/p[athFilter]=VALO] [/s|assemblyFilter=VALO] [/e|assemblyExcludeFilter=VALO] [/t[ypeFilter]=VALO] [/m[ethodFilter]=VALO] [/a[ttributeFilter]=VALO] [/attributetoplevel=VALO] [/typetoplevel=VALO] [/methodtoplevel=VALO] [--l[ocalSource]] [/c[allContext]=VALO] [/reportFormat=VALO] [--inplace] [--save] [--zipfile] [--methodpoint] [--all] [--linecover] [--branchcover] [--dropReturnCode] [--sourcelink] [--eager] [--v[isibleBranches]] [/showstatic[=VALO]] [--showGenerated] [--trivia] [--portable] [-q] [--verbose] [--?|help|h] [-- ] [...]
AltCover Runner [/r[ecorderDirectory]=VALO] [/w[orkingDirectory]=VALO] [/x|executable=VALO] [--collect] [/l[covReport]=VALO] [/t[hreshold]=VALO] [/c[obertura]=VALO] [/o[utputFile]=VALO] [--dropReturnCode] [/summary|teamcity[=VALO]] [-q] [--verbose] [--?|help|h] [-- ] [...]
AltCover Runner [/r[ecorderDirectory]=VALO] [/w[orkingDirectory]=VALO] [/x|executable=VALO] [--collect] [/l[covReport]=VALO] [/t[hreshold]=VALO] [/c[obertura]=VALO] [/p[ackage]=VALO] [/o[utputFile]=VALO] [--dropReturnCode] [/summary|teamcity[=VALO]] [-q] [--verbose] [--?|help|h] [-- ] [...]
AltCover ImportModule
Expand Down Expand Up @@ -474,4 +474,7 @@ Se la opcio ne ĉeestas, tiam la defaŭlta estas 'OC'.</value>
<data name="FailedToDelete" xml:space="preserve">
<value>Malsukcesis forigi dosieron {0}</value>
</data>
<data name="p|package=" xml:space="preserve">
<value>Lauvola, multobla: paka radika vojo por Cobertura-raportoj</value>
</data>
</root>
5 changes: 4 additions & 1 deletion AltCover.Engine/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ See also '--inplace'</value>
<data name="HelpText" xml:space="preserve">
<value>AltCover [/i[nputDirectory]=VALUE] [/o[utputDirectory]=VALUE] [/y|symbolDirectory=VALUE] [/d[ependency]=VALUE] [/k[ey]=VALUE] [/sn|strongNameKey=VALUE] [/r[eport]=VALUE] [/f[ileFilter]=VALUE] [/p[athFilter]=VALUE] [/s|assemblyFilter=VALUE] [/e|assemblyExcludeFilter=VALUE] [/t[ypeFilter]=VALUE] [/m[ethodFilter]=VALUE] [/a[ttributeFilter]=VALUE] [/attributetoplevel=VALUE] [/typetoplevel=VALUE] [/methodtoplevel=VALUE] [--l[ocalSource]] [/c[allContext]=VALUE] [/reportFormat=VALUE] [--inplace] [--save] [--zipfile] [--methodpoint] [--all] [--linecover] [--branchcover] [--dropReturnCode] [--sourcelink] [--eager] [--v[isibleBranches]] [/showstatic[=VALUE]] [--showGenerated] [--trivia] [--portable] [-q] [--verbose] [--?|help|h] [-- ] [...]
or
AltCover Runner [/r[ecorderDirectory]=VALUE] [/w[orkingDirectory]=VALUE] [/x|executable=VALUE] [--collect] [/l[covReport]=VALUE] [/t[hreshold]=VALUE] [/c[obertura]=VALUE] [/o[utputFile]=VALUE] [--dropReturnCode] [/summary|teamcity[=VALUE]] [-q] [--verbose] [--?|help|h] [-- ] [...]
AltCover Runner [/r[ecorderDirectory]=VALUE] [/w[orkingDirectory]=VALUE] [/x|executable=VALUE] [--collect] [/l[covReport]=VALUE] [/t[hreshold]=VALUE] [/c[obertura]=VALUE] [/p[ackage]=VALUE] [/o[utputFile]=VALUE] [--dropReturnCode] [/summary|teamcity[=VALUE]] [-q] [--verbose] [--?|help|h] [-- ] [...]
or
AltCover ImportModule
or
Expand Down Expand Up @@ -478,4 +478,7 @@ If the option is not present, then the default is 'OC'.</value>
<data name="FailedToDelete" xml:space="preserve">
<value>Failed to delete file {0}</value>
</data>
<data name="p|package=" xml:space="preserve">
<value>Optional, multiple: package root path for Cobertura reports</value>
</data>
</root>
6 changes: 6 additions & 0 deletions AltCover.Engine/Tasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ type Collect() =
[<SuppressMessage("Microsoft.Naming", "CA1704", Justification = "'Cobertura' is jargon")>]
member val Cobertura = String.Empty with get, set

[<SuppressMessage("Gendarme.Rules.Performance",
"AvoidReturningArraysOnPropertiesRule",
Justification = "MSBuild tasks use arrays")>]
member val Packages: string array = [||] with get, set

member val OutputFile = String.Empty with get, set

[<SuppressMessage("Gendarme.Rules.Performance",
Expand Down Expand Up @@ -260,6 +265,7 @@ type Collect() =
LcovReport = self.LcovReport
Threshold = self.Threshold
Cobertura = self.Cobertura
Packages = self.Packages
OutputFile = self.OutputFile
CommandLine = self.CommandLine
ExposeReturnCode = self.ExposeReturnCode
Expand Down
4 changes: 4 additions & 0 deletions AltCover.Engine/Tasks.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ type Collect =
///</summary>
member Cobertura : string with get, set
///<summary>
/// Corresponds to command line option `-p, --package=VALUE`
///</summary>
member Packages : string array with get, set
///<summary>
/// Corresponds to command line option `-o, --outputFile=VALUE`
///</summary>
member OutputFile : string with get, set
Expand Down
18 changes: 18 additions & 0 deletions AltCover.Engine/TypeSafe.fs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ module TypeSafe =
| NoCommand -> Seq.empty<String>
| CommandArguments c -> c |> Seq.map _.AsString()

[<ExcludeFromCodeCoverage; NoComparison>]
type Package =
| Package of String
member self.AsString() =
match self with
| Package s -> s

[<ExcludeFromCodeCoverage; NoComparison; AutoSerializable(false)>]
type Packages =
| Packages of Package seq
| NoPackage
member self.AsStrings() =
match self with
| NoPackage -> Seq.empty<String>
| Packages c -> c |> Seq.map _.AsString()

[<ExcludeFromCodeCoverage; NoComparison>]
type Thresholds =
{ Statements: uint8
Expand Down Expand Up @@ -249,6 +265,7 @@ module TypeSafe =
"CA1704:IdentifiersShouldBeSpelledCorrectly",
Justification = "Cobertura is a name")>]
Cobertura: FilePath
Packages: Packages
OutputFile: FilePath
CommandLine: CommandLine
ExposeReturnCode: Flag
Expand All @@ -261,6 +278,7 @@ module TypeSafe =
LcovReport = NoFile
Threshold = NoThreshold
Cobertura = NoFile
Packages = NoPackage
OutputFile = NoFile
CommandLine = NoCommand
ExposeReturnCode = Set
Expand Down
Loading

0 comments on commit f40275b

Please sign in to comment.