Skip to content

Commit

Permalink
Merge branch 'develop/github/maintenance' into release/Habu
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Aug 17, 2024
2 parents f196713 + 2afa553 commit af20985
Show file tree
Hide file tree
Showing 58 changed files with 522 additions and 349 deletions.
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
"version": "5.3.6",
"version": "5.3.8",
"commands": [
"reportgenerator"
],
Expand Down Expand Up @@ -38,7 +38,7 @@
"rollForward": false
},
"nbgv": {
"version": "3.6.139",
"version": "3.6.141",
"commands": [
"nbgv"
],
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.300'
dotnet-version: '8.0.400'
- name: Tools
run: dotnet tool restore
- name: Setup
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.300'
dotnet-version: '8.0.400'
- name: Tools
run: dotnet tool restore
- name: Setup
Expand Down
2 changes: 2 additions & 0 deletions AltCover.Api.Tests/AltCover.Api.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<AssemblySearchPaths Condition="'$(TargetFramework)' == 'net472'">$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<NoWarn Condition="'$(LocalCecil)' == 'true'">MSB3277</NoWarn>
<NoWarn>NU1901;NU1902;NU1903;$(NoWarn)</NoWarn>
<MSBuildWarningsAsMessages>NU1901;NU1902;NU1903</MSBuildWarningsAsMessages>
</PropertyGroup>

<ItemGroup>
Expand Down
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
5 changes: 3 additions & 2 deletions AltCover.Avalonia/AltCover.Avalonia.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<UseStandardResourceNames>True</UseStandardResourceNames>
<Win32Resource>$(ProjectDir)../AltCover.Visualizer/Resource.res</Win32Resource>
<NoWarn>NU1902,NU1903,NU1904</NoWarn>
<MSBuildWarningsAsMessages>NU1901;NU1902;NU1903;NU1904</MSBuildWarningsAsMessages>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand All @@ -29,10 +30,10 @@
<EmbeddedResource Include="AltCover.App.xaml">
<LogicalName>AltCover.App.xaml</LogicalName>
</EmbeddedResource>

<EmbeddedResource Include="AltCover.AboutBox.xaml">
<LogicalName>AltCover.AboutBox.xaml</LogicalName>
</EmbeddedResource>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
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 @@ -104,6 +104,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 @@ -145,6 +151,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
14 changes: 11 additions & 3 deletions 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 Expand Up @@ -267,7 +275,7 @@ module internal Cobertura =
(mname, signature)

(key, (signature, m)))
|> LCov.sortByFirst
|> LCov.sortByFirst id
|> Seq.fold (processMethod document methods) (0, 0)

let processClass
Expand Down Expand Up @@ -528,7 +536,7 @@ module internal Cobertura =
fn.Substring(start, argsAt - start)

(key, (signature, method)))
|> LCov.sortByFirst
|> LCov.sortByFirst id
|> Seq.filter (fun (_, (_, mt)) ->
mt.Descendants("SequencePoint".X)
|> Seq.isEmpty
Expand Down
Loading

0 comments on commit af20985

Please sign in to comment.