From 02774d67a3286d18590835959526f568f582438a Mon Sep 17 00:00:00 2001 From: Lucas Teles Date: Wed, 23 Dec 2020 12:58:12 -0300 Subject: [PATCH] changing the output format to receive a list of formats --- help/markdown/dotnet-testing-coverlet.md | 2 +- src/app/Fake.DotNet.Testing.Coverlet/Coverlet.fs | 10 +++++++--- .../Fake.DotNet.Testing.Coverlet.fs | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/help/markdown/dotnet-testing-coverlet.md b/help/markdown/dotnet-testing-coverlet.md index fca4d1cd18e..dd64b8eadc5 100644 --- a/help/markdown/dotnet-testing-coverlet.md +++ b/help/markdown/dotnet-testing-coverlet.md @@ -47,7 +47,7 @@ DotNet.test (fun p -> } |> Coverlet.withDotNetTestOptions (fun p -> { p with - OutputFormat = Coverlet.OutputFormat.OpenCover + OutputFormat = [Coverlet.OutputFormat.OpenCover] Output = "coverage.xml" Include = [ // Include all namespaces from assemblies whose name starts with MyProject diff --git a/src/app/Fake.DotNet.Testing.Coverlet/Coverlet.fs b/src/app/Fake.DotNet.Testing.Coverlet/Coverlet.fs index 9cecc0a25f7..802bccdc78a 100644 --- a/src/app/Fake.DotNet.Testing.Coverlet/Coverlet.fs +++ b/src/app/Fake.DotNet.Testing.Coverlet/Coverlet.fs @@ -27,7 +27,7 @@ type ThresholdStat = /// Coverlet MSBuild parameters. For more details see: https://github.com/tonerdo/coverlet/blob/master/Documentation/MSBuildIntegration.md type CoverletParams = { /// (Required) Format of the generated output. - OutputFormat : OutputFormat + OutputFormat : OutputFormat list /// (Required) Path to the generated output file, or directory if it ends with a `/`. Output : string /// Namespaces to include, as (AssemblyName, Namespace) pairs. Supports `*` and `?` globbing. @@ -51,7 +51,7 @@ type CoverletParams = /// The default parameters. let private defaults = - { OutputFormat = OutputFormat.Json + { OutputFormat = [OutputFormat.Json] Output = "./" Include = [] Exclude = [] @@ -70,6 +70,10 @@ let private outputFormatToString = function | OutputFormat.Cobertura -> "cobertura" | OutputFormat.TeamCity -> "teamcity" +let private outputFormatListToString = + List.map outputFormatToString + >> String.concat "," + let private namespacesToString = Seq.map (fun (asm, ns) -> "[" + asm + "]" + ns) >> String.concat "," @@ -90,7 +94,7 @@ let withMSBuildArguments (param: CoverletParams -> CoverletParams) (args: MSBuil let properties = [ yield "CollectCoverage", "true" - yield "CoverletOutputFormat", outputFormatToString param.OutputFormat + yield "CoverletOutputFormat", outputFormatListToString param.OutputFormat yield "CoverletOutput", param.Output if not (List.isEmpty param.Include) then yield "Include", namespacesToString param.Include diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.Testing.Coverlet.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.Testing.Coverlet.fs index 4036e6c104c..4215b5b67db 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.Testing.Coverlet.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.Testing.Coverlet.fs @@ -16,7 +16,7 @@ let tests = testCase "Test that full properties are converted" <| fun _ -> let props = getProps (fun p -> { - OutputFormat = Coverlet.OutputFormat.Cobertura + OutputFormat = [Coverlet.OutputFormat.Cobertura; Coverlet.OutputFormat.Json] Output = "coverage.json" Include = [ "Incl.Asm1", "Incl.Ns1" @@ -38,7 +38,7 @@ let tests = Expect.containsAll props [ "CollectCoverage", "true" "CoverletOutput", "coverage.json" - "CoverletOutputFormat", "cobertura" + "CoverletOutputFormat", "cobertura,json" "Include", "[Incl.Asm1]Incl.Ns1,[Incl.Asm2]Incl.Ns2" "Exclude", "[Excl.Asm1]Excl.Ns1,[Excl.Asm2]Excl.Ns2" "ExcludeByAttribute", "Attr1,Attr2"