diff --git a/AltCover.Api.Tests/FSApiTests.fs b/AltCover.Api.Tests/FSApiTests.fs
index 2e6e16fb..5ca097c8 100644
--- a/AltCover.Api.Tests/FSApiTests.fs
+++ b/AltCover.Api.Tests/FSApiTests.fs
@@ -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
@@ -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
@@ -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
diff --git a/AltCover.Cake/Options.cs b/AltCover.Cake/Options.cs
index 00e34744..b1bebfba 100644
--- a/AltCover.Cake/Options.cs
+++ b/AltCover.Cake/Options.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
-using System.Text;
+using System.Linq;
using FSDotNet = AltCover.DotNet;
@@ -326,6 +326,11 @@ public class CollectOptions : Abstract.ICollectOptions
Justification = "Lcov is a name")]
public virtual string Cobertura => String.Empty;
+ ///
+ /// Corresponds to command line option `-p, --package=VALUE`
+ ///
+ public IEnumerable Packages => Enumerable.Empty();
+
///
/// Corresponds to command line option `-o, --outputFile=VALUE`
///
diff --git a/AltCover.DotNet/DotNet.fs b/AltCover.DotNet/DotNet.fs
index c1395220..cd6e4142 100644
--- a/AltCover.DotNet/DotNet.fs
+++ b/AltCover.DotNet/DotNet.fs
@@ -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)
@@ -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
+ []
+ 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 =
@@ -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
diff --git a/AltCover.DotNet/DotNet.fsi b/AltCover.DotNet/DotNet.fsi
index 44f81366..520add81 100644
--- a/AltCover.DotNet/DotNet.fsi
+++ b/AltCover.DotNet/DotNet.fsi
@@ -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 -> (string*string) * bool) * string *
+ System.String seq) list
val toSharedFromValueArgumentList :
verbosity : System.Diagnostics.TraceLevel ->
((string -> obj -> bool -> (string*string)*bool) * string * obj * bool) list
diff --git a/AltCover.DotNet/Options.fs b/AltCover.DotNet/Options.fs
index 6fdd14b3..07ae30bd 100644
--- a/AltCover.DotNet/Options.fs
+++ b/AltCover.DotNet/Options.fs
@@ -44,6 +44,8 @@ module Options =
Justification = "Cobertura is a name")>]
member val Cobertura = String.Empty with get, set
+ member val Packages = Seq.empty with get, set
+
member val OutputFile = String.Empty with get, set
member val CommandLine = Seq.empty with get, set
member val ExposeReturnCode = true with get, set
@@ -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
diff --git a/AltCover.Engine/Abstract.fs b/AltCover.Engine/Abstract.fs
index 65db963b..cdaa0fae 100644
--- a/AltCover.Engine/Abstract.fs
+++ b/AltCover.Engine/Abstract.fs
@@ -77,6 +77,10 @@ module Abstract =
Justification="Cobertura is a name")>] //// no doc
abstract member Cobertura : String with get
///
+ /// Corresponds to command line option `-p, --package=VALUE`
+ ///
+ abstract member Packages : IEnumerable with get
+ ///
/// Corresponds to command line option `-o, --outputFile=VALUE`
///
abstract member OutputFile : String with get
diff --git a/AltCover.Engine/AltCover.fs b/AltCover.Engine/AltCover.fs
index 1a2395eb..03023496 100644
--- a/AltCover.Engine/AltCover.fs
+++ b/AltCover.Engine/AltCover.fs
@@ -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
@@ -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
diff --git a/AltCover.Engine/AltCover.fsi b/AltCover.Engine/AltCover.fsi
index 26cf2dbd..7a7c8c29 100644
--- a/AltCover.Engine/AltCover.fsi
+++ b/AltCover.Engine/AltCover.fsi
@@ -100,6 +100,10 @@ namespace AltCoverFake.DotNet.Testing
///
member Cobertura : System.String
///
+ /// Corresponds to command line option `-p, --package=VALUE`
+ ///
+ member Packages : seq
+ ///
/// Corresponds to command line option `-o, --outputFile=VALUE`
///
member OutputFile : System.String
diff --git a/AltCover.Engine/Args.fs b/AltCover.Engine/Args.fs
index fb7442a4..e9c3285d 100644
--- a/AltCover.Engine/Args.fs
+++ b/AltCover.Engine/Args.fs
@@ -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
@@ -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)
diff --git a/AltCover.Engine/Cobertura.fs b/AltCover.Engine/Cobertura.fs
index 3caa6cc5..8d427095 100644
--- a/AltCover.Engine/Cobertura.fs
+++ b/AltCover.Engine/Cobertura.fs
@@ -17,6 +17,9 @@ module internal Cobertura =
let internal path: Option ref =
ref None
+ let internal packages: string list ref =
+ ref List.empty
+
module internal I =
let internal setRate hits total (rate: string) (target: XElement) =
@@ -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)
+
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))
@@ -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))))
diff --git a/AltCover.Engine/Primitive.fs b/AltCover.Engine/Primitive.fs
index e2addfe6..2a4a9ed4 100644
--- a/AltCover.Engine/Primitive.fs
+++ b/AltCover.Engine/Primitive.fs
@@ -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
@@ -43,6 +44,7 @@ module Primitive =
LcovReport = String.Empty
Threshold = String.Empty
Cobertura = String.Empty
+ Packages = []
OutputFile = String.Empty
CommandLine = []
ExposeReturnCode = true
diff --git a/AltCover.Engine/Primitive.fsi b/AltCover.Engine/Primitive.fsi
index fae9bf14..7d53e144 100644
--- a/AltCover.Engine/Primitive.fsi
+++ b/AltCover.Engine/Primitive.fsi
@@ -60,6 +60,10 @@ namespace AltCoverFake.DotNet.Testing
///
Cobertura: System.String
///
+ /// Corresponds to command line option `-p, --package=VALUE`
+ ///
+ Packages : seq
+ ///
/// Corresponds to command line option `-o, --outputFile=VALUE`
///
OutputFile: System.String
diff --git a/AltCover.Engine/Runner.fs b/AltCover.Engine/Runner.fs
index a65bee95..10aad560 100644
--- a/AltCover.Engine/Runner.fs
+++ b/AltCover.Engine/Runner.fs
@@ -198,6 +198,7 @@ module internal Runner =
executable.Value <- None
LCov.path.Value <- None
Cobertura.path.Value <- None
+ Cobertura.packages.Value <- List.empty
Json.path.Value <- None
collect.Value <- false
threshold <- None
@@ -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
diff --git a/AltCover.Engine/Strings.eo.resx b/AltCover.Engine/Strings.eo.resx
index f85118fe..6d9021c7 100644
--- a/AltCover.Engine/Strings.eo.resx
+++ b/AltCover.Engine/Strings.eo.resx
@@ -157,7 +157,7 @@ Vidu ankaŭ '--inplace'
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] [-- ] [...]
aŭ
-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] [-- ] [...]
aŭ
AltCover ImportModule
aŭ
@@ -474,4 +474,7 @@ Se la opcio ne ĉeestas, tiam la defaŭlta estas 'OC'.
Malsukcesis forigi dosieron {0}
+
+ Lauvola, multobla: paka radika vojo por Cobertura-raportoj
+
\ No newline at end of file
diff --git a/AltCover.Engine/Strings.resx b/AltCover.Engine/Strings.resx
index d924d199..68bbf40b 100644
--- a/AltCover.Engine/Strings.resx
+++ b/AltCover.Engine/Strings.resx
@@ -157,7 +157,7 @@ See also '--inplace'
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
@@ -478,4 +478,7 @@ If the option is not present, then the default is 'OC'.
Failed to delete file {0}
+
+ Optional, multiple: package root path for Cobertura reports
+
\ No newline at end of file
diff --git a/AltCover.Engine/Tasks.fs b/AltCover.Engine/Tasks.fs
index 7cddd726..89d9d531 100644
--- a/AltCover.Engine/Tasks.fs
+++ b/AltCover.Engine/Tasks.fs
@@ -221,6 +221,11 @@ type Collect() =
[]
member val Cobertura = String.Empty with get, set
+ []
+ member val Packages: string array = [||] with get, set
+
member val OutputFile = String.Empty with get, set
[
member Cobertura : string with get, set
///
+ /// Corresponds to command line option `-p, --package=VALUE`
+ ///
+ member Packages : string array with get, set
+ ///
/// Corresponds to command line option `-o, --outputFile=VALUE`
///
member OutputFile : string with get, set
diff --git a/AltCover.Engine/TypeSafe.fs b/AltCover.Engine/TypeSafe.fs
index a49b32f5..f6ac9352 100644
--- a/AltCover.Engine/TypeSafe.fs
+++ b/AltCover.Engine/TypeSafe.fs
@@ -59,6 +59,22 @@ module TypeSafe =
| NoCommand -> Seq.empty
| CommandArguments c -> c |> Seq.map _.AsString()
+ []
+ type Package =
+ | Package of String
+ member self.AsString() =
+ match self with
+ | Package s -> s
+
+ []
+ type Packages =
+ | Packages of Package seq
+ | NoPackage
+ member self.AsStrings() =
+ match self with
+ | NoPackage -> Seq.empty
+ | Packages c -> c |> Seq.map _.AsString()
+
[]
type Thresholds =
{ Statements: uint8
@@ -249,6 +265,7 @@ module TypeSafe =
"CA1704:IdentifiersShouldBeSpelledCorrectly",
Justification = "Cobertura is a name")>]
Cobertura: FilePath
+ Packages: Packages
OutputFile: FilePath
CommandLine: CommandLine
ExposeReturnCode: Flag
@@ -261,6 +278,7 @@ module TypeSafe =
LcovReport = NoFile
Threshold = NoThreshold
Cobertura = NoFile
+ Packages = NoPackage
OutputFile = NoFile
CommandLine = NoCommand
ExposeReturnCode = Set
diff --git a/AltCover.Engine/TypeSafe.fsi b/AltCover.Engine/TypeSafe.fsi
index 1f7a9d80..9c108b0b 100644
--- a/AltCover.Engine/TypeSafe.fsi
+++ b/AltCover.Engine/TypeSafe.fsi
@@ -115,6 +115,45 @@ namespace AltCoverFake.DotNet.Testing
member AsStrings : unit -> seq
end
// ```
+// ### Cobertura package roots
+// ```
+ ///
+ /// Corresponds to a value after `-- ` on the command line
+ ///
+ []
+ type Package =
+ ///
+ /// Strongly typed string value
+ ///
+ | Package of System.String
+ with
+ ///
+ /// Returns the string to be used in the effective command line
+ ///
+ ///the string to be used in the effective command line
+ member AsString : unit -> System.String
+ end
+ ///
+ /// Corresponds to the values after `-- ` on the command line
+ ///
+ []
+ type Packages =
+ ///
+ /// Strongly typed string collection
+ ///
+ | Packages of seq
+ ///
+ /// Nothing
+ ///
+ | NoPackage
+ with
+ ///
+ /// Returns the strings to be used in the effective command line
+ ///
+ ///the strings to be used in the effective command line
+ member AsStrings : unit -> seq
+ end
+// ```
// ### Coverage thresholds
// ```
///
@@ -490,6 +529,10 @@ namespace AltCoverFake.DotNet.Testing
///
Cobertura: FilePath
///
+ /// Corresponds to command line option `-p, --package=VALUE`
+ ///
+ Packages : Packages
+ ///
/// Corresponds to command line option `-o, --outputFile=VALUE`
///
OutputFile: FilePath
diff --git a/AltCover.Fake.DotNet.Testing.AltCover/AltCoverCommand.fs b/AltCover.Fake.DotNet.Testing.AltCover/AltCoverCommand.fs
index c7638177..b6144ebd 100644
--- a/AltCover.Fake.DotNet.Testing.AltCover/AltCoverCommand.fs
+++ b/AltCover.Fake.DotNet.Testing.AltCover/AltCoverCommand.fs
@@ -40,6 +40,7 @@ module AltCoverCommand =
LcovReport = a.LcovReport
Threshold = a.Threshold
Cobertura = a.Cobertura
+ Packages = a.Packages
OutputFile = a.OutputFile
CommandLine = a.CommandLine
ExposeReturnCode = a.ExposeReturnCode
@@ -59,6 +60,7 @@ module AltCoverCommand =
LcovReport = a.LcovReport
Threshold = a.Threshold
Cobertura = a.Cobertura
+ Packages = a.Packages
OutputFile = a.OutputFile
CommandLine = args |> toSeq
ExposeReturnCode = a.ExposeReturnCode
@@ -328,30 +330,30 @@ module AltCoverCommand =
"CA1823:AvoidUnusedPrivateFields",
Scope = "member",
Target =
- "AltCoverFake.DotNet.Testing.AltCoverCommand+withMono@300T.#monoPath",
+ "AltCoverFake.DotNet.Testing.AltCoverCommand+withMono@302T.#monoPath",
Justification = "Generated code")>]
[]
[]
[]
[]
()
\ No newline at end of file
diff --git a/AltCover.PowerShell/Command.fs b/AltCover.PowerShell/Command.fs
index 9e6a54c9..ebff89c6 100644
--- a/AltCover.PowerShell/Command.fs
+++ b/AltCover.PowerShell/Command.fs
@@ -181,6 +181,20 @@ type InvokeAltCoverCommand() =
[]
member val Cobertura = String.Empty with get, set
+ ///
+ /// Package roots for cobertura reports
+ ///
+ []
+ []
+ []
+ member val Package: string array = [||] with get, set
+
///
/// Write the recorded coverage to this file rather than overwriting the original report file.
///
@@ -678,6 +692,7 @@ type InvokeAltCoverCommand() =
LcovReport = self.LcovReport
Threshold = self.Threshold
Cobertura = self.Cobertura
+ Packages = self.Package
OutputFile = self.OutputFile
CommandLine = self.CommandLine
ExposeReturnCode = not self.DropReturnCode.IsPresent
diff --git a/AltCover.PowerShell/CoverageFormats.fs b/AltCover.PowerShell/CoverageFormats.fs
index 989330c1..db91836b 100644
--- a/AltCover.PowerShell/CoverageFormats.fs
+++ b/AltCover.PowerShell/CoverageFormats.fs
@@ -248,6 +248,26 @@ type ConvertToCoberturaCommand() =
ValueFromPipelineByPropertyName = false)>]
member val OutputFile: string = String.Empty with get, set
+ ///
+ /// Output as file path
+ ///
+ []
+ []
+ []
+ []
+ member val Package: string array = [||] with get, set
+
///
/// Create transformed document
///
@@ -264,7 +284,7 @@ type ConvertToCoberturaCommand() =
self.XDocument <- XDocument.Load self.InputFile
let rewrite =
- AltCover.CoverageFormats.ConvertToCobertura self.XDocument
+ AltCover.CoverageFormats.ConvertToCobertura self.XDocument self.Package
if
self.OutputFile
diff --git a/AltCover.Tests/AltCover.Runner.Usage.txt b/AltCover.Tests/AltCover.Runner.Usage.txt
index f64ca3e0..53f4806e 100644
--- a/AltCover.Tests/AltCover.Runner.Usage.txt
+++ b/AltCover.Tests/AltCover.Runner.Usage.txt
@@ -30,6 +30,8 @@
such methods.
-c, --cobertura=VALUE Optional: File for Cobertura format version of the
collected data
+ -p, --package=VALUE Optional, multiple: package root path for
+ Cobertura reports
-o, --outputFile=VALUE Optional: write the recorded coverage to this file
rather than overwriting the original report file.
--dropReturnCode Optional: Do not report any non-zero return code
diff --git a/AltCover.Tests/Expecto.fs b/AltCover.Tests/Expecto.fs
index 35ebe4fe..30842a39 100644
--- a/AltCover.Tests/Expecto.fs
+++ b/AltCover.Tests/Expecto.fs
@@ -130,6 +130,10 @@ module ExpectoTestManifest =
"Runner.ParsingMultipleCoberturaGivesFailure"
Tests.AltCoverRunnerTests.ParsingNoCoberturaGivesFailure,
"Runner.ParsingNoCoberturaGivesFailure"
+ Tests.AltCoverRunnerTests.ParsingNoPackagesGivesFailure,
+ "Runner.ParsingPackagesGivesPackages"
+ Tests.AltCoverRunnerTests.ParsingPackagesGivesPackages,
+ "Runner.ParsingNoPackagesGivesFailure"
Tests.AltCoverRunnerTests.ParsingOutputGivesOutput,
"Runner.ParsingOutputGivesOutput"
Tests.AltCoverRunnerTests.ParsingMultipleOutputGivesFailure,
diff --git a/AltCover.Tests/NCover122.cobertura b/AltCover.Tests/NCover122.cobertura
index e24afa5b..e521cc64 100644
--- a/AltCover.Tests/NCover122.cobertura
+++ b/AltCover.Tests/NCover122.cobertura
@@ -2,12 +2,12 @@
- altcover/Sample1
+ altcover/
-
+
@@ -19,7 +19,7 @@
-
+
diff --git a/AltCover.Tests/NCoverWithPartials.cob.xml b/AltCover.Tests/NCoverWithPartials.cob.xml
index 9ef7e26c..50105846 100644
--- a/AltCover.Tests/NCoverWithPartials.cob.xml
+++ b/AltCover.Tests/NCoverWithPartials.cob.xml
@@ -3,7 +3,7 @@
C:/
- d:/a01/_work/5/s/src/vctools/crt/crtw32/msilcrt
+ d:/a01/_work/5/s/src/
@@ -48,7 +48,7 @@
-
+
diff --git a/AltCover.Tests/Runner.Tests.fs b/AltCover.Tests/Runner.Tests.fs
index 8e4442f0..5de4a326 100644
--- a/AltCover.Tests/Runner.Tests.fs
+++ b/AltCover.Tests/Runner.Tests.fs
@@ -604,7 +604,7 @@ module AltCoverRunnerTests =
let ShouldHaveExpectedOptions () =
Runner.init ()
let options = Runner.declareOptions ()
- let optionCount = 12
+ let optionCount = 13
let optionNames =
options
@@ -1677,6 +1677,60 @@ module AltCoverRunnerTests =
Runner.I.initSummary ()
Cobertura.path.Value <- None)
+ []
+ let ParsingPackagesGivesPackages () =
+ Runner.init ()
+
+ lock Cobertura.packages (fun () ->
+ try
+ Cobertura.packages.Value <- []
+ Runner.I.initSummary ()
+
+ let options = Runner.declareOptions ()
+ let unique = Guid.NewGuid().ToString()
+ let unique2 = Guid.NewGuid().ToString()
+
+ let input =
+ [| "-p"; unique; "--package"; unique2 |]
+
+ let parse =
+ CommandLine.parseCommandLine input options
+
+ match parse with
+ | Right(x, y) ->
+ Assert.That(y, Is.SameAs options)
+ Assert.That(x, Is.Empty)
+ test <@ Cobertura.packages.Value = [ unique2; unique ] @>
+
+ finally
+ Runner.I.initSummary ()
+ Cobertura.packages.Value <- [])
+
+ []
+ let ParsingNoPackagesGivesFailure () =
+ Runner.init ()
+
+ lock Cobertura.packages (fun () ->
+ try
+ Cobertura.packages.Value <- []
+ Runner.I.initSummary ()
+
+ let options = Runner.declareOptions ()
+ let blank = " "
+ let input = [| "-p"; blank |]
+
+ let parse =
+ CommandLine.parseCommandLine input options
+
+ match parse with
+ | Left(x, y) ->
+ Assert.That(y, Is.SameAs options)
+ Assert.That(x, Is.EqualTo "UsageError")
+ test <@ CommandLine.error = [ "--package : cannot be ' '" ] @>
+ finally
+ Runner.I.initSummary ()
+ Cobertura.packages.Value <- [])
+
[]
let ParsingOutputGivesOutput () =
Runner.init ()
@@ -6332,6 +6386,7 @@ module AltCoverRunnerTests =
)
Cobertura.path.Value <- Some unique
+ Cobertura.packages.Value <- [ "altcover" ]
unique
|> Path.GetDirectoryName
@@ -6379,9 +6434,7 @@ module AltCoverRunnerTests =
.Replace(
"""version="3.0.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
Assert.That(result.Replace("\r", String.Empty), Is.EqualTo expected, result)
@@ -6462,9 +6515,7 @@ module AltCoverRunnerTests =
.Replace(
"""version="8.8.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
Assert.That(result.Replace("\r", String.Empty), Is.EqualTo expected, result)
@@ -6498,6 +6549,7 @@ module AltCoverRunnerTests =
)
Cobertura.path.Value <- Some unique
+ Cobertura.packages.Value <- [ "d:/a01/_work/5/s/src/" ]
unique
|> Path.GetDirectoryName
@@ -6545,9 +6597,7 @@ module AltCoverRunnerTests =
.Replace(
"""version="8.2.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
Assert.That(result.Replace("\r", String.Empty), Is.EqualTo expected, result)
@@ -6628,9 +6678,7 @@ module AltCoverRunnerTests =
.Replace(
"""version="3.0.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
Assert.That(result.Replace("\r", String.Empty), Is.EqualTo expected, result)
@@ -6713,9 +6761,7 @@ module AltCoverRunnerTests =
.Replace(
"""version="3.0.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
Assert.That(result.Replace("\r", String.Empty), Is.EqualTo expected, result)
@@ -6798,9 +6844,7 @@ module AltCoverRunnerTests =
.Replace(
"""version="3.0.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
.Replace( // different computations TODO!!
"""complexity="2.2""",
@@ -6895,9 +6939,7 @@ module AltCoverRunnerTests =
.Replace(
"""version="3.0.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
Assert.That(result.Replace("\r", String.Empty), Is.EqualTo expected, result)
@@ -7128,9 +7170,7 @@ module AltCoverRunnerTests =
.Replace(
"""version="3.5.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
Assert.That(result.Replace("\r", String.Empty), Is.EqualTo expected, result)
@@ -7203,9 +7243,7 @@ module AltCoverRunnerTests =
.Replace(
"""version="8.2.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
Assert.That(
@@ -7284,11 +7322,9 @@ module AltCoverRunnerTests =
.Replace("\r", String.Empty)
.Replace("\\", "/")
.Replace(
- """version="3.0.0.0""",
+ """version="8.8.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
Assert.That(
@@ -7369,9 +7405,7 @@ module AltCoverRunnerTests =
.Replace(
"""version="3.0.0.0""",
"version=\""
- + typeof.Assembly
- .GetName()
- .Version.ToString()
+ + AssemblyVersionInformation.AssemblyVersion
)
Assert.That(
diff --git a/AltCover.Tests/XTests.fs b/AltCover.Tests/XTests.fs
index 9fe06918..ed68f31b 100644
--- a/AltCover.Tests/XTests.fs
+++ b/AltCover.Tests/XTests.fs
@@ -237,6 +237,7 @@ module AltCoverXTests =
Threshold = TypeSafe.Threshold t
SummaryFormat = TypeSafe.BPlus
Verbosity = System.Diagnostics.TraceLevel.Verbose
+ Packages = TypeSafe.Packages [ TypeSafe.Package "/agent/" ]
Executable = TypeSafe.Tool "dotnet" }
let instance =
@@ -254,6 +255,8 @@ module AltCoverXTests =
"dotnet"
"-t"
"S23B16M7C3"
+ "-p"
+ "/agent/"
"--summary:BOC"
"--verbose" ]
@>
@@ -263,7 +266,7 @@ module AltCoverXTests =
test
<@
- validate.ToString() = "altcover Runner -x dotnet -t S23B16M7C3 --summary:BOC --verbose"
+ validate.ToString() = "altcover Runner -x dotnet -t S23B16M7C3 -p /agent/ --summary:BOC --verbose"
@>
[]
@@ -318,9 +321,12 @@ module AltCoverXTests =
let subject =
TypeSafe.CollectOptions.Create()
- let scan =
- (AltCover.CollectOptions.TypeSafe subject)
- .Validate(true)
+ let instance =
+ AltCover.CollectOptions.TypeSafe subject
+
+ let scan = instance.Validate(true)
+
+ test <@ instance |> Args.collect = [ "Runner"; "--collect" ] @>
test <@ scan.Length = 1 @>
diff --git a/AltCover.Toolkit/CoverageFormats.fs b/AltCover.Toolkit/CoverageFormats.fs
index 543ea1e6..b459db55 100644
--- a/AltCover.Toolkit/CoverageFormats.fs
+++ b/AltCover.Toolkit/CoverageFormats.fs
@@ -25,11 +25,17 @@ module CoverageFormats =
[]
- let ConvertToCobertura (document: XDocument) =
+ let ConvertToCobertura (document: XDocument) (packages: string seq) =
let format =
XmlUtilities.discoverFormat document
- AltCover.Cobertura.convertReport document format
+ try
+ AltCover.Cobertura.packages.Value <- packages |> Seq.toList
+
+ AltCover.Cobertura.convertReport document format
+
+ finally
+ AltCover.Cobertura.packages.Value <- []
let ConvertToJson (document: XDocument) =
let format =
diff --git a/AltCover.Toolkit/CoverageFormats.fsi b/AltCover.Toolkit/CoverageFormats.fsi
index ee749444..d5fcba5d 100644
--- a/AltCover.Toolkit/CoverageFormats.fsi
+++ b/AltCover.Toolkit/CoverageFormats.fsi
@@ -24,9 +24,10 @@ namespace AltCover
/// Writes the Cobertura report to the object pipeline as an `XDocument`, and optionally to a file.
///
/// The report to convert.
+ /// Possibly empty list of package root folders.
/// The converted document
val ConvertToCobertura :
- document:System.Xml.Linq.XDocument -> System.Xml.Linq.XDocument
+ document:System.Xml.Linq.XDocument -> packages : string seq -> System.Xml.Linq.XDocument
///
/// Takes either OpenCover or classic NCover format input as an `XDocument`, as an argument or from the object pipeline. Writes the JSON report to a atring.
diff --git a/ReleaseNotes.md b/ReleaseNotes.md
index 39da359b..90523875 100644
--- a/ReleaseNotes.md
+++ b/ReleaseNotes.md
@@ -6,6 +6,9 @@ read the FAQ : https://github.com/SteveGilham/altcover/wiki/FAQ
# (Indori series release 1)
* [BREAKING] Minimum platforms net472, netstandard2.0 and net7.0
* [BREAKING] SDK updates to latest current for Cake and MSBuild-related packages
+
+# 8.9.3 (Habu series release 33)
+* Add `-p/--package` and equivalents to specify package roots for Cobertura output for all coverage collection methods, plus the PowerShell `ConvertTo-Cobertura` cmdlet
* [ADVISORY] The Fake.build related assemblies (in the `altcover.api` and `altcover.fake` packages) support Fake 6.1.0
* [PERFORMANCE] revise the OpenCover to LCov conversion to speed the mapping of methods from source files.
diff --git a/nupkg/build/AltCover.proj b/nupkg/build/AltCover.proj
index ac93010e..9dc02c1c 100644
--- a/nupkg/build/AltCover.proj
+++ b/nupkg/build/AltCover.proj
@@ -208,6 +208,7 @@
LcovReport="$(AltCoverLcovReport)"
Threshold="$(AltCoverThreshold)"
Cobertura="$(AltCoverCobertura)"
+ Packages="$(AltCoverPackages)"
SummaryFormat="$(AltCoverSummaryFormat)"
Verbosity="$(AltCoverVerbosity)">
diff --git a/version.json b/version.json
index e8075cdb..80a08a5a 100644
--- a/version.json
+++ b/version.json
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
- "version": "8.8",
+ "version": "8.9",
"release": {
"branchName": "release/v{version}",
"versionIncrement": "build",