From 0f2d1af3c55f037fdd14ee428d4937356a4ad25d Mon Sep 17 00:00:00 2001 From: Steve Gilham Date: Fri, 8 Jan 2021 15:53:21 +0000 Subject: [PATCH] No need to have these mutually exclusive any more --- AltCover.Engine/AltCover.fs | 9 ------- AltCover.Engine/Main.fs | 9 ------- AltCover.Engine/Strings.eo.resx | 6 ++--- AltCover.Engine/Strings.resx | 6 ++--- AltCover.PowerShell/Command.fs | 3 +-- Build/targets.fsx | 42 +++++++++++++++------------------ Tests/AltCover.Usage.txt | 5 ++-- Tests/Expecto.fs | 2 -- Tests/Tests3.fs | 36 ---------------------------- Tests/XTests.fs | 4 ++-- 10 files changed, 28 insertions(+), 94 deletions(-) diff --git a/AltCover.Engine/AltCover.fs b/AltCover.Engine/AltCover.fs index 1cc24fbf4..45d54053d 100644 --- a/AltCover.Engine/AltCover.fs +++ b/AltCover.Engine/AltCover.fs @@ -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 @@ -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 diff --git a/AltCover.Engine/Main.fs b/AltCover.Engine/Main.fs index f26230aeb..e1452c59a 100644 --- a/AltCover.Engine/Main.fs +++ b/AltCover.Engine/Main.fs @@ -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 @@ -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", diff --git a/AltCover.Engine/Strings.eo.resx b/AltCover.Engine/Strings.eo.resx index 8d3d3ccf2..5e7459781 100644 --- a/AltCover.Engine/Strings.eo.resx +++ b/AltCover.Engine/Strings.eo.resx @@ -230,8 +230,7 @@ Kovra Raporto: {0} 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 + Aliaj kordoj estas interpretitaj kiel metodnomoj (plene kvalifikitaj se la ĉeno enhavas ajnajn "" "karakterojn). {0} : Dosierujo {1} ne trovita @@ -358,8 +357,7 @@ Nuloj / forestantaj valoroj estas ignorataj. Se priraportada rezulto estas sub s Komandlinioj opcioj {0} kaj {1} estas reciproke ekskluzivaj. - Laŭvola: nur registru la unuan sukceson en ajna loko. - Nekongrua kun --callContext. + Laŭvola: registru la unuan trafon nur en iu ajn loko, aŭ unue trafu por ĉiu kunteksto se --callContext funkcias. Laŭvola: Ne registru branĉan kovradon. Implikas, kaj estas kongrua kun, la --reportFormat=opencover opcio. diff --git a/AltCover.Engine/Strings.resx b/AltCover.Engine/Strings.resx index 3770ce6bd..6b82917a7 100644 --- a/AltCover.Engine/Strings.resx +++ b/AltCover.Engine/Strings.resx @@ -234,8 +234,7 @@ Coverage Report: {0} 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 + Other strings are interpreted as method names (fully qualified if the string contains any "." characters). {0} : Directory {1} not found @@ -362,8 +361,7 @@ Zero/absent values are ignored. If a coverage result is below threshold, or the Command line options {0} and {1} are mutally exclusive. - Optional: only record the first hit at any location. - Incompatible with --callContext. + Optional: only record the first hit at any location, or first hit for each context if --callContext is operating. Optional: Do not record branch coverage. Implies, and is compatible with, the --reportFormat=opencover option. diff --git a/AltCover.PowerShell/Command.fs b/AltCover.PowerShell/Command.fs index bc43d3955..c4df8bb5f 100644 --- a/AltCover.PowerShell/Command.fs +++ b/AltCover.PowerShell/Command.fs @@ -372,7 +372,6 @@ type InvokeAltCoverCommand() = /// 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 /// [] @@ -419,7 +418,7 @@ type InvokeAltCoverCommand() = member val MethodPoint : SwitchParameter = SwitchParameter(false) with get, set /// - /// only record the first hit at any location. Incompatible with `-CallContext`. + /// only record the first hit at any location (or first for that context if `-CallContext` is operating). /// [] diff --git a/Build/targets.fsx b/Build/targets.fsx index 5a728085e..c385ac65a 100644 --- a/Build/targets.fsx +++ b/Build/targets.fsx @@ -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 @@ -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 @@ -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" @@ -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" @@ -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" @@ -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") @@ -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 @@ -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 @@ -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) diff --git a/Tests/AltCover.Usage.txt b/Tests/AltCover.Usage.txt index dd647ebc0..f845973ac 100644 --- a/Tests/AltCover.Usage.txt +++ b/Tests/AltCover.Usage.txt @@ -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 @@ -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. diff --git a/Tests/Expecto.fs b/Tests/Expecto.fs index 35040919e..731222486 100644 --- a/Tests/Expecto.fs +++ b/Tests/Expecto.fs @@ -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" @@ -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" diff --git a/Tests/Tests3.fs b/Tests/Tests3.fs index 590d352f4..1f149d56a 100644 --- a/Tests/Tests3.fs +++ b/Tests/Tests3.fs @@ -1411,25 +1411,6 @@ module AltCoverTests3 = CoverageParameters.theInterval <- None CoverageParameters.trackingNames.Clear() - [] - 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() - [] let ParsingNCoverFormatGivesNCover() = Main.init() @@ -1576,23 +1557,6 @@ module AltCoverTests3 = finally CoverageParameters.single <- false - [] - 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 - [] let ParsingLineCoverGivesLineCover() = Main.init() diff --git a/Tests/XTests.fs b/Tests/XTests.fs index cb8ff8ee0..1a9f0c65a 100644 --- a/Tests/XTests.fs +++ b/Tests/XTests.fs @@ -397,7 +397,7 @@ module AltCoverXTests = CallContext = [| "0" |] } let scan = (AltCover.PrepareOptions.Primitive subject).Validate() - test <@ scan.Length = 2 @> + test <@ scan.Length = 1 @> [] let TypeSafePrepareOptionsCanBeValidatedAndDetectInconsistency() = @@ -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";