Skip to content

Commit

Permalink
No need to have these mutually exclusive any more
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Jan 8, 2021
1 parent 179a0f4 commit 0f2d1af
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 94 deletions.
9 changes: 0 additions & 9 deletions AltCover.Engine/AltCover.fs
Expand Up @@ -453,14 +453,6 @@ module AltCover =
then f key x |> ignore

member private self.Consistent() =
if self.SingleVisit && self.CallContext.Any() then
CommandLine.error <-
String.Format
(System.Globalization.CultureInfo.CurrentCulture,
CommandLine.resources.GetString "Incompatible", "--single", "--callContext")
:: CommandLine.error

member private self.Consistent'() =
if self.LineCover && self.BranchCover then
CommandLine.error <-
String.Format
Expand Down Expand Up @@ -508,7 +500,6 @@ module AltCover =
|> Seq.iter
(fun a -> PrepareOptions.ValidateArraySimple a CommandLine.validateRegexes)
self.Consistent()
self.Consistent'()
validateContext self.CallContext
CommandLine.error |> List.toArray
finally
Expand Down
9 changes: 0 additions & 9 deletions AltCover.Engine/Main.fs
Expand Up @@ -189,11 +189,6 @@ module internal Main =
(CommandLine.ddFlag "l|localSource" CoverageParameters.local)
("c|callContext=",
(fun x ->
if CoverageParameters.single then
CommandLine.error <-
CommandLine.Format.Local("Incompatible",
"--single", "--callContext") :: CommandLine.error
else
let (ok, selection) = validateCallContext (Option.isSome CoverageParameters.theInterval) x
if ok then
match selection with
Expand All @@ -219,10 +214,6 @@ module internal Main =
CommandLine.error <-
CommandLine.Format.Local("MultiplesNotAllowed", "--single")
:: CommandLine.error
else if Option.isSome CoverageParameters.theInterval || CoverageParameters.trackingNames.Any() then
CommandLine.error <-
CommandLine.Format.Local("Incompatible",
"--single", "--callContext") :: CommandLine.error
else
CoverageParameters.single <- true))
("linecover",
Expand Down
6 changes: 2 additions & 4 deletions AltCover.Engine/Strings.eo.resx
Expand Up @@ -230,8 +230,7 @@ Kovra Raporto: {0}
<value>Laŭvola, multobla: Rilatado aŭ tempoj de vizitoj en tikoj aŭ nomitaj metodvokoj kondukantaj al la vizitoj.
Ununura cifero 0-7 donas la nombron de dekuma lokoj de sekundoj por raporti; ĉio alia kompatas la sistemon horloĝon disponebla per DateTime.UtcNow
Kordo en krampoj [] estas interpretita kiel atributo tipo nomon (la malantaŭa parto "Attribute" estas nedeviga), do [Test] aŭ [TestAttribute] kongruas; se la nomo enhavas unu aŭ pli ".", tiam ĝi estos egalita kontraŭ la plena nomo de la atributa tipo.
Aliaj kordoj estas interpretitaj kiel metodnomoj (plene kvalifikitaj se la ĉeno enhavas ajnajn "" "karakterojn).
Nekongrua kun --single</value>
Aliaj kordoj estas interpretitaj kiel metodnomoj (plene kvalifikitaj se la ĉeno enhavas ajnajn "" "karakterojn).</value>
</data>
<data name="DirectoryNotFound" xml:space="preserve">
<value>{0} : Dosierujo {1} ne trovita</value>
Expand Down Expand Up @@ -358,8 +357,7 @@ Nuloj / forestantaj valoroj estas ignorataj. Se priraportada rezulto estas sub s
<value>Komandlinioj opcioj {0} kaj {1} estas reciproke ekskluzivaj.</value>
</data>
<data name="single" xml:space="preserve">
<value>Laŭvola: nur registru la unuan sukceson en ajna loko.
Nekongrua kun --callContext.</value>
<value>Laŭvola: registru la unuan trafon nur en iu ajn loko, aŭ unue trafu por ĉiu kunteksto se --callContext funkcias.</value>
</data>
<data name="linecover" xml:space="preserve">
<value>Laŭvola: Ne registru branĉan kovradon. Implikas, kaj estas kongrua kun, la --reportFormat=opencover opcio.
Expand Down
6 changes: 2 additions & 4 deletions AltCover.Engine/Strings.resx
Expand Up @@ -234,8 +234,7 @@ Coverage Report: {0}
<value>Optional, multiple: Tracking either times of visits in ticks or designated method calls leading to the visits.
A single digit 0-7 gives the number of decimal places of seconds to report; everything else is at the mercy of the system clock information available through DateTime.UtcNow
A string in brackets "[]" is interpreted as an attribute type name (the trailing "Attribute" is optional), so [Test] or [TestAttribute] will match; if the name contains one or more ".", then it will be matched against the full name of the attribute type.
Other strings are interpreted as method names (fully qualified if the string contains any "." characters).
Incompatible with --single</value>
Other strings are interpreted as method names (fully qualified if the string contains any "." characters).</value>
</data>
<data name="DirectoryNotFound" xml:space="preserve">
<value>{0} : Directory {1} not found</value>
Expand Down Expand Up @@ -362,8 +361,7 @@ Zero/absent values are ignored. If a coverage result is below threshold, or the
<value>Command line options {0} and {1} are mutally exclusive.</value>
</data>
<data name="single" xml:space="preserve">
<value>Optional: only record the first hit at any location.
Incompatible with --callContext.</value>
<value>Optional: only record the first hit at any location, or first hit for each context if --callContext is operating.</value>
</data>
<data name="linecover" xml:space="preserve">
<value>Optional: Do not record branch coverage. Implies, and is compatible with, the --reportFormat=opencover option.
Expand Down
3 changes: 1 addition & 2 deletions AltCover.PowerShell/Command.fs
Expand Up @@ -372,7 +372,6 @@ type InvokeAltCoverCommand() =
/// <para type="description">A single digit 0-7 gives the number of decimal places of seconds to report; everything else is at the mercy of the system clock information available through DateTime.UtcNow</para>
/// <para type="description">A string in brackets "[]" is interpreted as an attribute type name (the trailing "Attribute" is optional), so [Test] or [TestAttribute] will match; if the name contains one or more ".", then it will be matched against the full name of the attribute type.</para>
/// <para type="description">Other strings are interpreted as method names (fully qualified if the string contains any "." characters).</para>
/// <para type="description">Incompatible with -Single</para>
/// </summary>
[<Parameter(ParameterSetName = "Instrument", Mandatory = false,
ValueFromPipeline = false, ValueFromPipelineByPropertyName = false)>]
Expand Down Expand Up @@ -419,7 +418,7 @@ type InvokeAltCoverCommand() =
member val MethodPoint : SwitchParameter = SwitchParameter(false) with get, set

/// <summary>
/// <para type="description">only record the first hit at any location. Incompatible with `-CallContext`.</para>
/// <para type="description">only record the first hit at any location (or first for that context if `-CallContext` is operating).</para>
/// </summary>
[<Parameter(ParameterSetName = "Instrument", Mandatory = false,
ValueFromPipeline = false, ValueFromPipelineByPropertyName = false)>]
Expand Down
42 changes: 19 additions & 23 deletions Build/targets.fsx
Expand Up @@ -856,18 +856,18 @@ _Target "UncoveredUnitTest" ignore

let NUnitRetry f spec =
let rec doNUnitRetry depth f spec =
try
try
if File.Exists spec
then File.Delete spec
NUnit3.run (f >> (fun p -> {p with ResultSpecs = [ spec ]}))
with x ->
printfn "%A" x
if depth > 2
then
then
printfn "Recursion limited"
reraise ()
if File.Exists spec
then
if File.Exists spec
then
let xml =
"./Build/NuGet.csproj"
|> Path.getFullName
Expand All @@ -877,10 +877,10 @@ let NUnitRetry f spec =
let failcount = summary.Attribute(XName.Get "failed").Value
if failcount = "0"
then doNUnitRetry (depth + 1) f spec
else
else
printfn "Actual failures found %A" failcount
reraise()
else
else
printfn "Report not found"
reraise()
doNUnitRetry 0 f spec
Expand Down Expand Up @@ -957,7 +957,7 @@ _Target "UnitTestDotNet" (fun _ ->
_Target "BuildForCoverlet" (fun _ ->
msbuildDebug MSBuildPath "./Recorder.Tests/AltCover.Recorder.Tests.fsproj"
msbuildDebug MSBuildPath "./Recorder2.Tests/AltCover.Recorder2.Tests.fsproj"

[
Path.getFullName "./AltCover.Expecto.Tests/AltCover.Expecto.Tests.fsproj"
Path.getFullName "./AltCover.Api.Tests/AltCover.Api.Tests.fsproj"
Expand All @@ -973,7 +973,7 @@ _Target "BuildForCoverlet" (fun _ ->
_Target "UnitTestDotNetWithCoverlet" (fun _ ->
Directory.ensure "./_Reports"
try
let l =
let l =
[
Path.getFullName "./AltCover.Expecto.Tests/AltCover.Expecto.Tests.fsproj"
Path.getFullName "./AltCover.Api.Tests/AltCover.Api.Tests.fsproj"
Expand Down Expand Up @@ -1179,9 +1179,6 @@ _Target "UnitTestWithAltCover" (fun _ ->
WorkingDir = "." }) "./_Reports/UnitTestWithAltCoverReport.xml"
with x ->
printfn "%A" x
"./_Reports/UnitTestWithAltCoverReport.xml"
|> File.ReadAllText
|> printfn "%s"
reraise()

printfn "Instrument the net20 Recorder tests"
Expand Down Expand Up @@ -1220,7 +1217,7 @@ _Target "UnitTestWithAltCover" (fun _ ->
[ ReportGenerator.ReportType.Html; ReportGenerator.ReportType.XmlSummary ]
TargetDir = "_Reports/_UnitTestWithAltCover" }) [ altReport; RecorderReport ]

uncovered @"_Reports/_UnitTestWithAltCover/Summary.xml"
uncovered @"_Reports/_UnitTestWithAltCover/Summary.xml"
|> List.map fst
|> printfn "%A uncovered lines")

Expand Down Expand Up @@ -1338,21 +1335,20 @@ _Target "UnitTestWithAltCoverRunner" (fun _ ->
ToolType = frameworkAltcover
WorkingDirectory = "." }


let nUnitRetry2 () =
let rec doNUnitRetry2 depth =
try
try
if File.Exists nunitReport
then File.Delete nunitReport
AltCoverCommand.run command
with x ->
printfn "%A" x
if depth > 2
then
then
printfn "Recursion limited"
reraise ()
if File.Exists nunitReport
then
if File.Exists nunitReport
then
let xml =
"./Build/NuGet.csproj"
|> Path.getFullName
Expand All @@ -1361,11 +1357,11 @@ _Target "UnitTestWithAltCoverRunner" (fun _ ->
|> Seq.head
let failcount = summary.Attribute(XName.Get "failed").Value
if failcount = "0"
then doNUnitRetry2 (depth + 1)
else
then doNUnitRetry2 (depth + 1)
else
printfn "Actual failures %A" failcount
reraise()
else
else
printfn "Report not found"
reraise()
doNUnitRetry2 0
Expand Down Expand Up @@ -1591,9 +1587,9 @@ _Target "UnitTestWithAltCoverCoreRunner" (fun _ ->
<| Primitive.CollectOptions.Create()

if proj.Contains("Recorder")
then doMSBuild
(withDebug >> fun p -> { p with Verbosity = Some MSBuildVerbosity.Minimal})
MSBuildPath newproj
then doMSBuild
(withDebug >> fun p -> { p with Verbosity = Some MSBuildVerbosity.Minimal})
MSBuildPath newproj

DotNet.test (fun to' ->
{ to'.WithCommon(withWorkingDirectoryVM testdir)
Expand Down
5 changes: 2 additions & 3 deletions Tests/AltCover.Usage.txt
Expand Up @@ -69,7 +69,6 @@
Other strings are interpreted as method
names (fully qualified if the string contains
any "." characters).
Incompatible with --single
--reportFormat=VALUE Optional: Generate the report in the specified
format (NCover or the default OpenCover)
--inplace Optional: Instrument the inputDirectory, rather
Expand All @@ -81,8 +80,8 @@
visited or not. Overrides the --linecover and --
branchcover options.
--single Optional: only record the first hit at any
location.
Incompatible with --callContext.
location, or first hit for each context if --
callContext is operating.
--linecover Optional: Do not record branch coverage. Implies,
and is compatible with, the --reportFormat=
opencover option.
Expand Down
2 changes: 0 additions & 2 deletions Tests/Expecto.fs
Expand Up @@ -390,7 +390,6 @@ module ExpectoTestManifest =
Tests.AltCoverTests3.ParsingBadTimeGivesNoOp, "Tests3.ParsingBadTimeGivesNoOp"
Tests.AltCoverTests3.ParsingNonTimeGivesFailure, "Tests3.ParsingNonTimeGivesFailure"
Tests.AltCoverTests3.ParsingNoTimeGivesFailure, "Tests3.ParsingNoTimeGivesFailure"
Tests.AltCoverTests3.ParsingAfterSingleGivesFailure, "Tests3.ParsingAfterSingleGivesFailure"
Tests.AltCoverTests3.ParsingNCoverFormatGivesNCover, "Tests3.ParsingNCoverFormatGivesNCover"
Tests.AltCoverTests3.ParsingOpenCoverFormatGivesOpenCover, "Tests3.ParsingOpenCoverFormatGivesOpenCover"
Tests.AltCoverTests3.ParsingMultipleReportFormatGivesFailure, "Tests3.ParsingMultipleReportFormatGivesFailure"
Expand All @@ -400,7 +399,6 @@ module ExpectoTestManifest =
Tests.AltCoverTests3.ParsingMultipleSaveGivesFailure, "Tests3.ParsingMultipleSaveGivesFailure"
Tests.AltCoverTests3.ParsingSingleGivesSingle, "Tests3.ParsingSingleGivesSingle"
Tests.AltCoverTests3.ParsingMultipleSingleGivesFailure, "Tests3.ParsingMultipleSingleGivesFailure"
Tests.AltCoverTests3.ParsingSingleAfterContextGivesFailure, "Tests3.ParsingSingleAfterContextGivesFailure"
Tests.AltCoverTests3.ParsingLineCoverGivesLineCover, "Tests3.ParsingLineCoverGivesLineCover"
Tests.AltCoverTests3.OpenCoverIsCompatibleWithLineCover, "Tests3.OpenCoverIsCompatibleWithLineCover"
Tests.AltCoverTests3.LineCoverIsCompatibleWithOpenCover, "Tests3.LineCoverIsCompatibleWithOpenCover"
Expand Down
36 changes: 0 additions & 36 deletions Tests/Tests3.fs
Expand Up @@ -1411,25 +1411,6 @@ module AltCoverTests3 =
CoverageParameters.theInterval <- None
CoverageParameters.trackingNames.Clear()

[<Test>]
let ParsingAfterSingleGivesFailure() =
Main.init()
try
CoverageParameters.single <- true
CoverageParameters.theInterval <- None
CoverageParameters.trackingNames.Clear()
let options = Main.I.declareOptions()
let input = [| "-c"; "3"; "/c"; "x"; "--callContext"; "Hello, World!" |]
let parse = CommandLine.parseCommandLine input options
match parse with
| Left(x, y) ->
Assert.That(y, Is.SameAs options)
Assert.That(x, Is.EqualTo "UsageError")
finally
CoverageParameters.single <- false
CoverageParameters.theInterval <- None
CoverageParameters.trackingNames.Clear()

[<Test>]
let ParsingNCoverFormatGivesNCover() =
Main.init()
Expand Down Expand Up @@ -1576,23 +1557,6 @@ module AltCoverTests3 =
finally
CoverageParameters.single <- false

[<Test>]
let ParsingSingleAfterContextGivesFailure() =
Main.init()
try
CoverageParameters.single <- false
CoverageParameters.theInterval <- Some 0
let options = Main.I.declareOptions()
let input = [| "--single" |]
let parse = CommandLine.parseCommandLine input options
match parse with
| Left(x, y) ->
Assert.That(y, Is.SameAs options)
Assert.That(x, Is.EqualTo "UsageError")
finally
CoverageParameters.single <- false
CoverageParameters.theInterval <- None

[<Test>]
let ParsingLineCoverGivesLineCover() =
Main.init()
Expand Down
4 changes: 2 additions & 2 deletions Tests/XTests.fs
Expand Up @@ -397,7 +397,7 @@ module AltCoverXTests =
CallContext = [| "0" |] }

let scan = (AltCover.PrepareOptions.Primitive subject).Validate()
test <@ scan.Length = 2 @>
test <@ scan.Length = 1 @>

[<Test>]
let TypeSafePrepareOptionsCanBeValidatedAndDetectInconsistency() =
Expand All @@ -412,7 +412,7 @@ module AltCoverXTests =
|> AltCover.PrepareOptions.TypeSafe

let scan = subject.Validate()
test <@ scan.Length = 2 @>
test <@ scan.Length = 1 @>
let rendered = subject |> Args.prepare
test
<@ rendered = [ "-c"; "0"; "--reportFormat"; "OpenCover"; "--inplace"; "--save"; "--single";
Expand Down

0 comments on commit 0f2d1af

Please sign in to comment.