Skip to content

Handle single file coverage with jacoco #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lua/coverage/languages/java.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,18 @@ M.load = function(callback)
-- obtains fine grained data
local packages = assert(jacoco.report.package, "not able to read jacoco.report.package")
assert(type(packages) == "table")
if #packages == 0 then
packages = { packages }
end

for _, pack in ipairs(packages) do
local dir = dir_prefix .. pack._attr.name

-- classes
if #pack.class == 0 then
pack.class = { pack.class }
end

for _, class in ipairs(pack.class) do
local filename = Path:new(dir .. "/" .. class._attr.sourcefilename).filename -- with .java

Expand All @@ -97,6 +105,10 @@ M.load = function(callback)

end

if #pack.sourcefile == 0 then
pack.sourcefile = { pack.sourcefile }
end

for _, src_file in ipairs(pack.sourcefile) do
local lines = src_file.line
-- So, jacoco reports in terms of instructions
Expand Down