Skip to content

Commit

Permalink
travis: use OutputJsonCoverage
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin authored and alex-konovalov committed Dec 23, 2016
1 parent a7446f0 commit 3cd078a
Showing 1 changed file with 1 addition and 46 deletions.
47 changes: 1 addition & 46 deletions etc/cover2json.g
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,5 @@ if LoadPackage("profiling") <> true then
FORCE_QUIT_GAP(1);
fi;

# CoverToJson is only here temporarily until its functionality has been
# published as part of the profiling package.
if not IsBound(CoverToJson) then
CoverToJson := function(data, outfile)
local outstream, lineinfo, prev, file, lines;

outfile := USER_HOME_EXPAND(outfile);
outstream := IO_File(outfile, "w");

if not(IsRecord(data)) then
data := ReadLineByLineProfile(data);
fi;

lineinfo := function(lineno, stat)
if stat[1] > 0 then
if stat[2] > 0 then
return STRINGIFY("\"", lineno, "\": \"1\"");
else
return STRINGIFY("\"", lineno, "\": \"0\"");
fi;
fi;
return "";
end;

IO_Write(outstream, "{ \"coverage\": {\n");
prev := false;

for file in data.line_info do
if file[1] <> "stream" then
if prev then
IO_Write(outstream, ",\n");
fi;
IO_Write(outstream, Concatenation("\"", file[1], "\": {\n" ));
lines := List([1..Length(file[2])], n -> lineinfo(n, file[2][n]));
lines := Filtered(lines, l -> Length(l) > 0);
IO_Write(outstream, JoinStringsWithSeparator(lines, ",\n"));
IO_Write(outstream, "}\n");
prev := true;
fi;
od;
IO_Write(outstream, "} }");
IO_Close(outstream);
end;
fi;

CoverToJson("coverage", "coverage.json");
OutputJsonCoverage("coverage", "coverage.json");
QUIT_GAP(0);

0 comments on commit 3cd078a

Please sign in to comment.