Skip to content

Commit

Permalink
Merge branch 'master' into release/Habu
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Apr 6, 2024
2 parents c273b0a + 796b419 commit 9d0f1c4
Show file tree
Hide file tree
Showing 82 changed files with 791 additions and 282 deletions.
16 changes: 16 additions & 0 deletions AltCover.Api.Tests/AltCover.Api.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@
<PackageReference Include="FSharp.Core">
<ExcludeAssets>contentfiles</ExcludeAssets>
</PackageReference>
<PackageReference Include="Mono.Cecil" Condition="'$(LocalCecil)' != 'true'" />
<Reference Include="Mono.Cecil" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Unquote" Condition="'$(TargetFramework)' == 'net472'">
<HintPath>..\ThirdParty\Unquote.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions AltCover.Cake/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ public class PrepareOptions : Abstract.IPrepareOptions
/// Corresponds to dotnet test option `/p:AltCoverOutputRoot`
///</summary>
public virtual string OutputRoot => String.Empty;

///<summary>
/// Corresponds to command line option `--portable`
///</summary>
public virtual bool Portable => false;
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions AltCover.DotNet/Options.fs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ module Options =
member val Verbosity = System.Diagnostics.TraceLevel.Info with get, set
member val Trivia = false with get, set
member val OutputRoot = String.Empty with get, set
member val Portable = false with get, set

interface Abstract.IPrepareOptions with
member self.InputDirectories =
Expand Down Expand Up @@ -190,6 +191,7 @@ module Options =
member self.Verbosity = self.Verbosity
member self.Trivia = self.Trivia
member self.OutputRoot = self.OutputRoot
member self.Portable = self.Portable

#if RUNNER
[<AutoSerializable(false)>]
Expand Down
4 changes: 4 additions & 0 deletions AltCover.Engine/Abstract.fs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ module Abstract =
/// Corresponds to dotnet test option `/p:AltCoverOutputRoot`
///</summary>
abstract member OutputRoot : string with get
///<summary>
/// Corresponds to command line option `--portable`
///</summary>
abstract member Portable : bool with get
// ```
#if RUNNER
// ### interface `ILoggingOptions`
Expand Down
14 changes: 13 additions & 1 deletion AltCover.Engine/AltCover.Engine.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,19 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Mono.Cecil" />
<PackageReference Include="Mono.Cecil" Condition="'$(LocalCecil)' != 'true'" />
<Reference Include="Mono.Cecil" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<PackageReference Include="System.IO.Compression" />
<PackageReference Include="FSharp.Core">
<ExcludeAssets>contentfiles</ExcludeAssets>
Expand Down
7 changes: 7 additions & 0 deletions AltCover.Engine/AltCover.fs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ module AltCover =
| Abstract a -> a.OutputRoot
| TypeSafe t -> t.OutputRoot.AsString()

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

interface Abstract.IPrepareOptions with
member self.InputDirectories =
self.InputDirectories |> PrepareOptions.ToSeq
Expand Down Expand Up @@ -519,6 +525,7 @@ module AltCover =
member self.Verbosity = self.Verbosity
member self.Trivia = self.Trivia
member self.OutputRoot = self.OutputRoot
member self.Portable = self.Portable

#if RUNNER
static member private ValidateArray a f key =
Expand Down
4 changes: 4 additions & 0 deletions AltCover.Engine/AltCover.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ namespace AltCoverFake.DotNet.Testing
/// Corresponds to dotnet test option `/p:AltCoverOutputRoot`
///</summary>
member OutputRoot : string with get
///<summary>
/// Corresponds to command line option `--portable`
///</summary>
member Portable : bool with get
// ```
#if RUNNER
// ```
Expand Down
3 changes: 2 additions & 1 deletion AltCover.Engine/Args.fs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ module internal Args =
("--localSource", args.LocalSource)
("--visibleBranches", args.VisibleBranches)
("--showGenerated", args.ShowGenerated)
("--trivia", args.Trivia) ]
("--trivia", args.Trivia)
("--portable", args.Portable) ]

let internal flags (args: Abstract.IPrepareOptions) =
args
Expand Down
4 changes: 2 additions & 2 deletions AltCover.Engine/Canonical.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if RUNNER
#if RUNNER || RECORDER
namespace AltCover
#else
namespace AltCoverFake.DotNet.Testing
Expand All @@ -15,7 +15,7 @@ module internal Canonical =
Uri("file://" + (Path.GetFullPath path), UriKind.Absolute)
.LocalPath

#if !FAKE && !NoCanonicalDirectories
#if !FAKE && !NoCanonicalDirectories && !RECORDER
let canonicalDirectory (path: string) =
let last = path |> Seq.last

Expand Down
83 changes: 52 additions & 31 deletions AltCover.Engine/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ module internal Main =
CoverageParameters.sourcelink.Value <- false // ddFlag
CoverageParameters.coalesceBranches.Value <- false // ddFlag
CoverageParameters.staticFilter <- None
CoverageParameters.showGenerated.Value <- false
CoverageParameters.trivia.Value <- false
CoverageParameters.showGenerated.Value <- false // ddFlag
CoverageParameters.trivia.Value <- false // ddFlag
CoverageParameters.portable.Value <- false // ddFlag

let internal validateCallContext predicate x =
if not (String.IsNullOrWhiteSpace x) then
Expand Down Expand Up @@ -324,6 +325,7 @@ module internal Main =
:: CommandLine.error))
(CommandLine.ddFlag "showGenerated" CoverageParameters.showGenerated)
(CommandLine.ddFlag "trivia" CoverageParameters.trivia)
(CommandLine.ddFlag "portable" CoverageParameters.portable)
("q", (fun _ -> CommandLine.verbosity <- CommandLine.verbosity + 1))
("verbose", (fun _ -> CommandLine.verbosity <- CommandLine.verbosity - 1))
("?|help|h", (fun x -> CommandLine.help <- x.IsNotNull))
Expand Down Expand Up @@ -367,33 +369,42 @@ module internal Main =
let outputDirectories =
CoverageParameters.outputDirectories ()

inputDirectories
|> Seq.iter (fun fromDirectory ->
if outputDirectories.Contains fromDirectory then
CommandLine.error <-
CommandLine.Format.Local("NotInPlace", fromDirectory)
:: CommandLine.error)

CommandLine.doPathOperation
(fun () ->
let found =
outputDirectories |> Seq.filter Directory.Exists

if
CoverageParameters.inplace.Value // Maybe barf if saving somewhere contaminated
&& CommandLine.error |> List.isEmpty
&& found.Any()
then
found
|> Seq.iter (fun toDirectory ->
CommandLine.error <-
CommandLine.Format.Local("SaveExists", toDirectory)
:: CommandLine.error)

if CommandLine.error |> List.isEmpty then
(Seq.iter CommandLine.ensureDirectory outputDirectories))
()
false
if
CoverageParameters.portable.Value
&& inputDirectories.Length > 1
then
CommandLine.error <-
CommandLine.Format.Local("NotPortable")
:: CommandLine.error
else

inputDirectories
|> Seq.iter (fun fromDirectory ->
if outputDirectories.Contains fromDirectory then
CommandLine.error <-
CommandLine.Format.Local("NotInPlace", fromDirectory)
:: CommandLine.error)

CommandLine.doPathOperation
(fun () ->
let found =
outputDirectories |> Seq.filter Directory.Exists

if
CoverageParameters.inplace.Value // Maybe barf if saving somewhere contaminated
&& CommandLine.error |> List.isEmpty
&& found.Any()
then
found
|> Seq.iter (fun toDirectory ->
CommandLine.error <-
CommandLine.Format.Local("SaveExists", toDirectory)
:: CommandLine.error)

if CommandLine.error |> List.isEmpty then
(Seq.iter CommandLine.ensureDirectory outputDirectories))
()
false

if CommandLine.error |> List.isEmpty |> not then
Left("UsageError", options)
Expand Down Expand Up @@ -699,6 +710,17 @@ module internal Main =
| ReportFormat.NativeJson -> NativeJson.reportGenerator ()
| _ -> Report.reportGenerator ()

let internal canonicalReportPath () =
Path.Combine(
(if CoverageParameters.inplace.Value then
CoverageParameters.inputDirectories ()
else
CoverageParameters.outputDirectories ())
|> Seq.head,
CoverageParameters.reportPath ()
)
|> Canonical.canonicalPath

[<SuppressMessage("Gendarme.Rules.BadPractice",
"GetEntryAssemblyMayReturnNullRule",
Justification = "That is the whole point of the call.")>]
Expand Down Expand Up @@ -727,8 +749,7 @@ module internal Main =
| Right(rest, fromInfo, toInfo, targetInfo) ->
CommandLine.applyVerbosity ()

let report =
CoverageParameters.reportPath ()
let report = canonicalReportPath ()

let result =
CommandLine.doPathOperation
Expand Down
6 changes: 4 additions & 2 deletions AltCover.Engine/Primitive.fs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ module Primitive =
ShowGenerated: bool
Verbosity: System.Diagnostics.TraceLevel
Trivia: bool
OutputRoot: string }
OutputRoot: string
Portable: bool }
static member Create() =
{ InputDirectories = Seq.empty
OutputDirectories = Seq.empty
Expand Down Expand Up @@ -131,7 +132,8 @@ module Primitive =
ShowGenerated = false
Verbosity = System.Diagnostics.TraceLevel.Info
Trivia = false
OutputRoot = String.Empty }
OutputRoot = String.Empty
Portable = false }

#if RUNNER
[<ExcludeFromCodeCoverage; NoComparison; NoEquality; AutoSerializable(false)>]
Expand Down
4 changes: 4 additions & 0 deletions AltCover.Engine/Primitive.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ namespace AltCoverFake.DotNet.Testing
/// Corresponds to dotnet test option `/p:AltCoverOutputRoot`
///</summary>
OutputRoot : string
///<summary>
/// Corresponds to command line option `--portable`
///</summary>
Portable : bool
}
with
///<summary>
Expand Down
7 changes: 5 additions & 2 deletions AltCover.Engine/Runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,8 +1474,11 @@ module internal Runner =
let instance = snd pair

let report =
(J.getMethod instance "get_ReportFile")
|> J.getFirstOperandAsString
Path.Combine(
Path.GetDirectoryName(recordingDirectory.Value),
(J.getMethod instance "get_ReportFile")
|> J.getFirstOperandAsString
)
|> canonicalPath

let format =
Expand Down
2 changes: 1 addition & 1 deletion AltCover.Engine/StringExtension.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module internal StringExtension =
let (==) (x: string) (y: string) =
x.Equals(y, System.StringComparison.Ordinal)

#if !FAKEAPI
#if !FAKEAPI && !RECORDER
#if !DEBUG && !NET20
[<MethodImplAttribute(MethodImplOptions.AggressiveInlining)>]
#endif
Expand Down
8 changes: 7 additions & 1 deletion AltCover.Engine/Strings.eo.resx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Vidu ankaŭ '--inplace'</value>
<value>Krei dosierujon {0}</value>
</data>
<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] [--single] [--linecover] [--branchcover] [--dropReturnCode] [--sourcelink] [--defer] [--v[isibleBranches]] [/showstatic[=VALO]] [--showGenerated] [--trivia] [-q] [--verbose] [--?|help|h] [-- ] [...]
<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] [--single] [--linecover] [--branchcover] [--dropReturnCode] [--sourcelink] [--defer] [--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] [-- ] [...]
Expand Down Expand Up @@ -465,4 +465,10 @@ Se la opcio ne ĉeestas, tiam la defaŭlta estas 'OC'.</value>
<data name="trivia" xml:space="preserve">
<value>Laŭvola: Forlasu bagatelajn sinsekvopunktojn</value>
</data>
<data name="NotPortable" xml:space="preserve">
<value>La opcio --portable ne kongruas kun pluraj eliglokoj.</value>
</data>
<data name="portable" xml:space="preserve">
<value>Laŭvola: porteblaj operacioj - priraporta raporto, kontroldosiero kaj registritaj datumoj samlokaj kun la registrilo.</value>
</data>
</root>
8 changes: 7 additions & 1 deletion AltCover.Engine/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ See also '--inplace'</value>
<value>Creating folder {0}</value>
</data>
<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] [--single] [--linecover] [--branchcover] [--dropReturnCode] [--sourcelink] [--defer] [--v[isibleBranches]] [/showstatic[=VALUE]] [--showGenerated] [--trivia] [-q] [--verbose] [--?|help|h] [-- ] [...]
<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] [--single] [--linecover] [--branchcover] [--dropReturnCode] [--sourcelink] [--defer] [--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] [-- ] [...]
or
Expand Down Expand Up @@ -469,4 +469,10 @@ If the option is not present, then the default is 'OC'.</value>
<data name="trivia" xml:space="preserve">
<value>Optional: Omit trivial sequence points</value>
</data>
<data name="NotPortable" xml:space="preserve">
<value>The --portable option is not compatible with multiple output locations.</value>
</data>
<data name="portable" xml:space="preserve">
<value>Optional: portable operations - coverage report, control file and recorded data co-located with the recorder assembly</value>
</data>
</root>
4 changes: 3 additions & 1 deletion AltCover.Engine/Tasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ type Prepare() =
member val Verbosity = "Info" with get, set
member val Trivia = false with get, set
member val OutputRoot = String.Empty with get, set
member val Portable = false with get, set

member private self.Message text =
``base``.Log.LogMessage(MessageImportance.High, text)
Expand Down Expand Up @@ -192,7 +193,8 @@ type Prepare() =
ShowGenerated = self.ShowGenerated
Verbosity = TaskHelpers.parse self.Verbosity
Trivia = self.Trivia
OutputRoot = self.OutputRoot }
OutputRoot = self.OutputRoot
Portable = self.Portable }

Command.Prepare task log = 0

Expand Down
4 changes: 4 additions & 0 deletions AltCover.Engine/Tasks.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ type Prepare =
/// Corresponds to command line option `--trivia`
///</summary>
member Trivia: bool with get, set
///<summary>
/// Corresponds to command line option `--portable`
///</summary>
member Portable: bool with get, set
end
// ```
// ## Task `AltCover.Collect`
Expand Down
Loading

0 comments on commit 9d0f1c4

Please sign in to comment.