Skip to content

Commit

Permalink
Merge branch 'master' into develop/maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Jan 1, 2023
2 parents 6f19cd1 + 702f23a commit ad2b65c
Show file tree
Hide file tree
Showing 81 changed files with 1,016 additions and 311 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- feature/*
- release/*
- develop/github/*
pull_request:
branches:
Expand All @@ -27,6 +28,7 @@ jobs:
- name: Build
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
NUGET_API_TOKEN: ${{ secrets.NUGET_API_TOKEN }}
run: dotnet run --project .\Build\Build.fsproj
- uses: actions/upload-artifact@v3
with:
Expand Down
18 changes: 2 additions & 16 deletions AltCover.DotNet/DotNet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ module DotNet =
let private fromList name (s: String seq) = (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)
let internal join (l: string seq) = String.Join(" ", l)

[<SuppressMessage("Gendarme.Rules.Design.Generic",
"AvoidMethodWithUnusedGenericTypeRule",
Expand Down Expand Up @@ -202,34 +201,21 @@ module DotNet =

#if RUNNER
let ToTestArgumentList
#else
let internal toTestArgumentList
#endif
(prepare: Abstract.IPrepareOptions)
(collect: Abstract.ICollectOptions)
(options: ICLIOptions)
=
ToTestPropertiesList prepare collect options
|> List.map (fun (name, value) -> sprintf """/p:%s="%s%c""" name value '"')

#if RUNNER
let ToTestArguments
#else
let internal toTestArguments
#endif
(prepare: Abstract.IPrepareOptions)
(collect: Abstract.ICollectOptions)
(options: ICLIOptions)
=
#if RUNNER
ToTestArgumentList
#else
toTestArgumentList
let join (l: string seq) = String.Join(" ", l)
ToTestArgumentList prepare collect options |> join
#endif
prepare
collect
options
|> I.join

let ImportModuleProperties =
[ ("AltCoverImportModule", "true") ]
Expand Down
9 changes: 0 additions & 9 deletions AltCover.DotNet/DotNet.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ module DotNet = begin
val private isSet : s:string -> bool
val private fromList : name:string -> s:seq<System.String> -> (string*string) * bool
val fromArg : name:string -> s:string -> (string*string) * bool
val join : l:seq<string> -> string
val toPrepareListArgumentList :
prepare:Abstract.IPrepareOptions ->
((string -> #seq<System.String> -> (string*string) * bool) * string *
Expand Down Expand Up @@ -158,14 +157,6 @@ module DotNet = begin
// The former creates the `/p:AltCoverXXX="yyy"` elements for a `dotnet test` invocation as a list of strings, the latter concatenates them, with space separators, into a single command line string.
#else
#if TRACE // cheat mode here
val internal toTestArgumentList :
prepare:Abstract.IPrepareOptions ->
collect:Abstract.ICollectOptions -> options:ICLIOptions -> string list
val internal toTestArguments :
prepare:Abstract.IPrepareOptions ->
collect:Abstract.ICollectOptions -> options:ICLIOptions -> string
val ImportModuleProperties : (string*string) list
val GetVersionProperties : (string*string) list
end
#endif
#endif
Expand Down
4 changes: 3 additions & 1 deletion AltCover.Engine/StringExtension.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ module internal StringExtension =
let (==) (x: string) (y: string) =
x.Equals(y, System.StringComparison.Ordinal)

#if !FAKEAPI
#if !DEBUG && !NET20
[<MethodImplAttribute(MethodImplOptions.AggressiveInlining)>]
#endif
let (!=) (x: string) (y: string) = (x == y) |> not
let (!=) (x: string) (y: string) = (x == y) |> not
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>AltCover.Fake.DotNet.Testing.AltCover</RootNamespace>
<AssemblyName>AltCover.Fake.DotNet.Testing.AltCover</AssemblyName>
<GlobalDefineConstants>NoCanonicalDirectories</GlobalDefineConstants>
<GlobalDefineConstants>NoCanonicalDirectories;FAKEAPI</GlobalDefineConstants>
<!-- something; Could not locate the assembly "Mono.Posix" -->
<MSBuildWarningsAsMessages>MSB3277;MSB3245</MSBuildWarningsAsMessages>
<NoWarn>NU1701;NU1605</NoWarn>
Expand Down
1 change: 0 additions & 1 deletion AltCover.Fake/AltCover.Fake.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

<ItemGroup>
<Compile Include="..\_Generated\AssemblyVersion.fs" Link="AssemblyVersion.fs" />
<Compile Include="..\AltCover.Engine\StringExtension.fs" Link="StringExtension.fs" />
<Compile Include="Fake.fsi" />
<Compile Include="Fake.fs" />
</ItemGroup>
Expand Down
97 changes: 10 additions & 87 deletions AltCover.Fake/Fake.fs
Original file line number Diff line number Diff line change
Expand Up @@ -83,110 +83,35 @@ open AltCover.Shared
module DotNet =
open Fake.DotNet

let internal activate (info: ParameterInfo) =
let t = info.ParameterType

if t.GetTypeInfo().IsValueType then
Activator.CreateInstance(t)
else
null

let internal setCustomParams common extended current (f: FieldInfo) =
f.SetValue(
common,
(if f.Name != "CustomParams@" then
f.GetValue current
else
extended :> obj)
)

let internal setCommonParams result common self (f: FieldInfo) =
f.SetValue(
result,
(if f.Name != "Common@" then
f.GetValue self
else
common)
)

let internal extractParameters (o: DotNet.TestOptions) =
let t = o.Common.GetType()
let p = t.GetProperty("CustomParams")
p.GetValue(o.Common, null) :?> string Option

let internal join (l: string seq) = String.Join(" ", l)

let internal toArgs a =
a
|> List.map (fun (name, value) -> sprintf """/p:%s="%s" """ name value)
|> join

type DotNet.TestOptions with

// NOTE: the MSBuildParams member of TestOptions did not exist in Fake 5.0.0
// so do it this way for backwards compatibility
[<SuppressMessage("Microsoft.Usage",
"CA2208",
Justification = "Inlined calls to ArgumentNullException")>]
member private self.ExtendCustomParams options =

// the constructors are version dependent
let optionsConstructor =
self.Common.GetType().GetConstructors().[0]

let args =
optionsConstructor.GetParameters()
|> Array.map activate

let common = optionsConstructor.Invoke(args)

let extended =
match self |> extractParameters with
| None -> Some options
| Some thing -> Some(thing + " " + options)

self
.Common
.GetType()
.GetFields(BindingFlags.NonPublic ||| BindingFlags.Instance)
|> Array.iter (setCustomParams common extended self.Common)

let testOptionsConstructor =
self.GetType().GetConstructors().[0]

let args' =
testOptionsConstructor.GetParameters()
|> Array.map activate

let result =
testOptionsConstructor.Invoke(args')
member private self.ExtendCLIProperties options =
let cliargs = self.MSBuildParams

self
.GetType()
.GetFields(BindingFlags.NonPublic ||| BindingFlags.Instance)
|> Array.iter (setCommonParams result common self)
let nargs =
{ cliargs with Properties = List.concat [ cliargs.Properties; options ] }

result :?> DotNet.TestOptions
{ self with MSBuildParams = nargs }

#if RUNNER
member self.WithAltCoverOptions
(prepare: Abstract.IPrepareOptions)
(collect: Abstract.ICollectOptions)
(force: DotNet.ICLIOptions)
=
DotNet.ToTestArguments
DotNet.ToTestPropertiesList
#else
member self.WithAltCoverOptions
(prepare: Testing.Abstract.IPrepareOptions)
(collect: Testing.Abstract.ICollectOptions)
(force: AltCoverFake.DotNet.Testing.DotNet.ICLIOptions)
=
AltCoverFake.DotNet.Testing.DotNet.toTestArguments
AltCoverFake.DotNet.Testing.DotNet.ToTestPropertiesList
#endif
prepare
collect
force
|> self.ExtendCustomParams
|> self.ExtendCLIProperties

[<SuppressMessage("Microsoft.Naming", "CA1704", Justification = "Anonymous parameter")>]
member self.WithAltCoverImportModule() =
Expand All @@ -195,8 +120,7 @@ module DotNet =
#else
AltCoverFake.DotNet.Testing.DotNet.ImportModuleProperties
#endif
|> toArgs
|> self.ExtendCustomParams
|> self.ExtendCLIProperties

[<SuppressMessage("Microsoft.Naming", "CA1704", Justification = "Anonymous parameter")>]
member self.WithAltCoverGetVersion() =
Expand All @@ -205,8 +129,7 @@ module DotNet =
#else
AltCoverFake.DotNet.Testing.DotNet.GetVersionProperties
#endif
|> toArgs
|> self.ExtendCustomParams
|> self.ExtendCLIProperties

#if RUNNER
[<assembly: CLSCompliant(true)>]
Expand Down
21 changes: 12 additions & 9 deletions Build/DriveApi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,20 @@ module DriveApi =
WorkingDirectory = Path.getFullName "./_DotnetTest"
Verbosity = Some DotNet.Verbosity.Minimal }

let cliArguments =
{ MSBuild.CliArguments.Create() with
ConsoleLogParameters = []
DistributedLoggers = None
Properties = []
DisableInternalBinLog = true }
let testWithCLIArguments (o: Fake.DotNet.DotNet.TestOptions) =
let msb =
{ o.MSBuildParams with
ConsoleLogParameters = []
DistributedLoggers = None
DisableInternalBinLog = true }

{ o with MSBuildParams = msb }

DotNet.test
(fun to' ->
{ (to'.WithCommon(setBaseOptions)
|> (withAltCoverOptions pp2 cc2 forceTrue)) with MSBuildParams = cliArguments })
((fun to' ->
to'.WithCommon(setBaseOptions)
|> (withAltCoverOptions pp2 cc2 forceTrue))
>> testWithCLIArguments)
"apiuse_dotnettest.fsproj"

let im = AltCover.Command.ImportModule()
Expand Down
33 changes: 25 additions & 8 deletions Build/targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,30 @@ module Targets =
{ dotnetOptions o with WorkingDirectory = Path.getFullName dir }

let testWithCLIArguments (o: Fake.DotNet.DotNet.TestOptions) =
{ o with MSBuildParams = cliArguments }
let msb =
{ o.MSBuildParams with
ConsoleLogParameters = []
DistributedLoggers = None
DisableInternalBinLog = true }

{ o with MSBuildParams = msb }

let buildWithCLIArguments (o: Fake.DotNet.DotNet.BuildOptions) =
{ o with MSBuildParams = cliArguments }

let testWithCLITaggedArguments tag (o: Fake.DotNet.DotNet.TestOptions) =
{ o with MSBuildParams = cliTaggedArguments tag }
let p =
("AltCoverTag", (tag + "_"))
:: o.MSBuildParams.Properties

let msb =
{ o.MSBuildParams with
ConsoleLogParameters = []
Properties = p
DistributedLoggers = None
DisableInternalBinLog = true }

{ o with MSBuildParams = msb }

let buildWithCLITaggedArguments tag (o: Fake.DotNet.DotNet.BuildOptions) =
{ o with MSBuildParams = cliTaggedArguments tag }
Expand Down Expand Up @@ -746,7 +763,7 @@ module Targets =
rn
|> Array.findIndex (fun l -> l.StartsWith("# ", StringComparison.Ordinal))

rn.[tag] <- String.Format (rn.[tag], Version)
rn.[tag] <- String.Format(rn.[tag], Version)
printfn "%s" rn.[tag]
File.WriteAllLines("./_Generated/ReleaseNotes.md", rn)

Expand Down Expand Up @@ -5099,7 +5116,7 @@ module Targets =
DotNet.build
(fun p ->
{ p.WithCommon dotnetOptions with
Configuration = DotNet.BuildConfiguration.Debug }
Configuration = DotNet.BuildConfiguration.Debug }
|> (buildWithCLITaggedArguments "CoverletForPester"))
sample

Expand Down Expand Up @@ -6898,8 +6915,8 @@ module Targets =
({ to'.WithCommon(
withWorkingDirectoryVM "./RegressionTesting/issue20/xunit-tests"
) with
Configuration = DotNet.BuildConfiguration.Debug
NoBuild = false })
Configuration = DotNet.BuildConfiguration.Debug
NoBuild = false })
.WithAltCoverOptions
pp0
cc0
Expand Down Expand Up @@ -6941,8 +6958,8 @@ module Targets =
({ to'.WithCommon(
withWorkingDirectoryVM "./RegressionTesting/issue20/xunit-tests"
) with
Configuration = DotNet.BuildConfiguration.Debug
NoBuild = false })
Configuration = DotNet.BuildConfiguration.Debug
NoBuild = false })
.WithAltCoverOptions
pp1
cc0
Expand Down
4 changes: 3 additions & 1 deletion ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
A. Start with the Quick Start guide : https://github.com/SteveGilham/altcover/wiki/QuickStart-Guide and
read the FAQ : https://github.com/SteveGilham/altcover/wiki/FAQ

# {0} (Habu series release 19)
# {0} (Habu series release 20)

# 8.6.14 (Habu series release 19)
* [GTKVisualizer] Fix an off-by-one crash for `coverlet` generated files
* [AvaloniaVisualizer] Fix possible crash launching the About dialog
* [Visualizer] Display coverage percentages against nodes of the tree (known issue that the synthetic F# module nodes are not thus decorated)
Expand Down
1 change: 1 addition & 0 deletions docs/AltCover.DotNet/AltCover.DotNet-apidoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
| public type | description |
| --- | --- |
| static class [DotNet](./AltCover/DotNet-apidoc) | Construction of `dotnet test` command line options. |
| static class [Options](./AltCover/Options-apidoc) | Containst concrete `...Options` implementations |

<!-- DO NOT EDIT: generated by xmldocmd for AltCover.DotNet.dll -->
20 changes: 20 additions & 0 deletions docs/AltCover.DotNet/AltCover/Options-apidoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Options class

```csharp
public static class Options
```

## Public Members

| name | description |
| --- | --- |
| class [CLI](Options.CLI-apidoc) | |
| class [Collect](Options.Collect-apidoc) | |
| class [Logging](Options.Logging-apidoc) | |
| class [Prepare](Options.Prepare-apidoc) | |

## See Also

* namespace [AltCover](../AltCover.DotNet-apidoc)

<!-- DO NOT EDIT: generated by xmldocmd for AltCover.DotNet.dll -->

0 comments on commit ad2b65c

Please sign in to comment.