Skip to content

Commit

Permalink
And back together again
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Jun 13, 2024
1 parent e5694e6 commit 8d3e9f4
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 13 deletions.
14 changes: 11 additions & 3 deletions AltCover.Engine/Cobertura.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,27 @@ module internal Cobertura =

[<System.Diagnostics.CodeAnalysis.SuppressMessage("Gendarme.Rules.Performance",
"AvoidUncalledPrivateCodeRule",
Justification = "Temporary to validate")>]
Justification =
"Temporary to validate")>]
let splitPath path =
let rec facets path bits =
let npath = Path.GetDirectoryName path
let facet = if String.IsNullOrWhiteSpace npath then path else (Path.GetFileName path)

let facet =
if String.IsNullOrWhiteSpace npath then
path
else
(Path.GetFileName path)

let wfacet = facet :: bits

if String.IsNullOrWhiteSpace npath then
wfacet
else
facets npath wfacet

if String.IsNullOrWhiteSpace path then
[String.Empty]
[ String.Empty ]
else
facets path []

Expand Down
3 changes: 1 addition & 2 deletions AltCover.Tests/Expecto.fs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ module ExpectoTestManifest =
"Runner.NCoverWithOverloadsShouldGeneratePlausibleCobertura"
Tests.AltCoverRunnerTests.NCoverShouldGenerateMorePlausibleCobertura,
"Runner.NCoverShouldGenerateMorePlausibleCobertura"
Tests.AltCoverRunnerTests.PathsSplitOK,
"Runner.PathsSplitOK"
Tests.AltCoverRunnerTests.PathsSplitOK, "Runner.PathsSplitOK"
Tests.AltCoverRunnerTests.DegenerateCasesShouldNotGenerateCobertura,
"Runner.DegenerateCasesShouldNotGenerateCobertura"
Tests.AltCoverRunnerTests.NCoverShouldGeneratePlausibleCoberturaWithMissingFullName,
Expand Down
39 changes: 31 additions & 8 deletions AltCover.Tests/Runner.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6155,21 +6155,44 @@ module AltCoverRunnerTests =
let cases =
[
#if WINDOWS
("C:/Users/anon/OneDrive/Pictures/wallpaper.jpg", ["C:\\"; "Users"; "anon"; "OneDrive"; "Pictures"; "wallpaper.jpg"])
("C:/Users/anon/OneDrive/Pictures/wallpaper.jpg",
[ "C:\\"
"Users"
"anon"
"OneDrive"
"Pictures"
"wallpaper.jpg" ])
#else
("C:/Users/anon/OneDrive/Pictures/wallpaper.jpg", ["C:"; "Users"; "anon"; "OneDrive"; "Pictures"; "wallpaper.jpg"])
("C:/Users/anon/OneDrive/Pictures/wallpaper.jpg",
[ "C:"
"Users"
"anon"
"OneDrive"
"Pictures"
"wallpaper.jpg" ])
#endif
("/usr/home/anon/project/src/code.cs", [String([|Path.DirectorySeparatorChar|]); "usr"; "home"; "anon"; "project"; "src"; "code.cs"])
("partial/path/OK", ["partial"; "path"; "OK"])
(String.Empty, [String.Empty])
(null, [String.Empty])
]
("/usr/home/anon/project/src/code.cs",
[ String([| Path.DirectorySeparatorChar |])
"usr"
"home"
"anon"
"project"
"src"
"code.cs" ])
("partial/path/OK", [ "partial"; "path"; "OK" ])
(String.Empty, [ String.Empty ])
(null, [ String.Empty ]) ]

cases
|> List.iter (fun (case, expect) ->
test <@ Cobertura.I.splitPath case = expect @>

if case.IsNotNull then
test <@ case = (Path.Combine (List.toArray expect)).Replace ("\\", "/") @>)
test
<@
case = (Path.Combine(List.toArray expect))
.Replace("\\", "/")
@>)

[<Test>]
let DegenerateCasesShouldNotGenerateCobertura () =
Expand Down
4 changes: 4 additions & 0 deletions Build/targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8139,6 +8139,10 @@ module Targets =

let cobertura2Files =
xml
|> List.filter (fun (x, _) ->
Path
.GetFileName(x)
.Equals("coverage.cobertura.xml", StringComparison.Ordinal))
|> List.filter (fun x ->
let root = (snd x).Root

Expand Down

0 comments on commit 8d3e9f4

Please sign in to comment.