Skip to content

Commit ea408a8

Browse files
committed
Apply P2: import qualification and code cleanup
P2 - Import Qualification & Code Cleanup: - ext/TestRunner.jl: using DocStringExtensions → import DocStringExtensions: TYPEDEF, TYPEDSIGNATURES - ext/CoveragePostprocessing.jl: using Coverage → using Coverage: Coverage - Removed dead ternary branches (ext/TestRunner.jl:447, 332) - Fixed byte-indexing path slicing → use relpath() (ext/CoveragePostprocessing.jl:347) - Fixed collision risk in cov file flattening → use normalized flat names (ext/CoveragePostprocessing.jl:221) All tests pass: 1161/1161
1 parent 80b31a5 commit ea408a8

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

ext/CoveragePostprocessing.jl

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Most functions in this module have filesystem side effects.
1010
module CoveragePostprocessing
1111

1212
using CTBase: CTBase
13-
using Coverage
13+
using Coverage: Coverage
1414

1515
# Main entry point for coverage post-processing
1616
"""
@@ -218,14 +218,8 @@ function _collect_and_move_cov_files!(source_dirs, dest_dir)
218218
# But let's stick to the plan: just recursive collection.
219219

220220
src = joinpath(root, f)
221-
dest = joinpath(dest_dir, f) # Wait, this might fail if f is just filename.
222-
223-
# The issue with joinpath(dest_dir, f) if f is just a filename is that it puts everything in root of dest_dir.
224-
# If f comes from walkdir's `files`, it is just the filename.
225-
# So `src` is correct. `dest` puts it in `coverage/cov/filename.cov`.
226-
# This matches previous behavior, just expanded to subdirs.
227-
228-
dest = joinpath(dest_dir, f)
221+
flat = replace(relpath(src, dir), r"[/\\]" => "_")
222+
dest = joinpath(dest_dir, flat)
229223
mv(src, dest; force=true)
230224
push!(moved, dest)
231225
end
@@ -347,12 +341,8 @@ function _generate_coverage_reports!(
347341

348342
# Helper to make paths relative to root_dir
349343
function relative_path(path, root)
350-
if startswith(path, root)
351-
relpath = path[(length(root) + 1):end]
352-
# Remove leading slash if present
353-
return startswith(relpath, "/") ? relpath[2:end] : relpath
354-
end
355-
return path
344+
startswith(path, root) || return path
345+
return relpath(path, root)
356346
end
357347

358348
function write_report(io)

ext/TestRunner.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ running testsets).
1010
module TestRunner
1111

1212
using CTBase: CTBase
13-
using DocStringExtensions
13+
import DocStringExtensions: TYPEDEF, TYPEDSIGNATURES
1414
using Test: Test, @testset
1515

1616
"""
@@ -327,7 +327,7 @@ julia> TestRunner._normalize_selections(
327327
```
328328
"""
329329
function _normalize_selections(selections::Vector{String}, candidates::Vector{<:TestSpec})
330-
candidate_strs = [c isa Symbol ? String(c) : String(c) for c in candidates]
330+
candidate_strs = [String(c) for c in candidates]
331331
normalized = String[]
332332
for sel in selections
333333
# Strip trailing slash(es)
@@ -442,7 +442,7 @@ julia> TestRunner._builder_to_string("utils")
442442
```
443443
"""
444444
function _builder_to_string(x)
445-
x isa Symbol ? String(x) : String(x)
445+
String(x)
446446
end
447447

448448
"""

0 commit comments

Comments
 (0)