-
-
Notifications
You must be signed in to change notification settings - Fork 66
Description
The Bisect "library" was originally included in the installation only so that instrumented programs could be linked with the runtime. It's an internal interface. However, it has made Bisect somewhat "hackable" (ocveralls, bisect-summary). That's a good thing :)
To avoid problems like in #108, and more that are on the way, I think we should try to design a good replacement interface. "Good" means both easy to use, and abstract enough to withstand serious changes in Bisect_ppx.
Proposal
The interface I can suggest now is something quite similar to @lindig's proposal. This would replace Bisect.Common:
(* module Bisect.Coverage *)
type location
(* Abstract, see below. *)
val location_to_offset : location -> int
val location_to_line : location -> int
type point =
{location : location;
hits : int}
type file =
{points : point array;
line_count : int;
source_code : string option}
type t = (string, file) Hashtbl.t
val read : ?source_code_directory:string -> ~out_files:string list -> coverageAt a file system level, there would be only .out files. They would be self-contained. They would include everything now in .out files, .cmp files (#102), and the source code (#103). So, a tool would only need to find a collection of them, and pass their names to read. This should make both programmatic use and use of bisect-ppx-report easier – especially in contexts where there isn't access to the build directories.
Details
-
Lines are included in locations, so that it's not necessary to walk over the source to convert offsets to lines. Also, the source may be missing.
-
Type
locationis abstract, because we might need to switch to location ranges to address a potential future problem:There may be some challenges, when an expression has the same location as some relevant subexpression.
I'd also like the freedom to decide between using
Location.t, and thus depending oncompiler-libs, or not. -
A digest can be easily computed from
source_code. We can include the digest, so that ocveralls can work even if the source is missing, but I'm wondering if it's not better for ocveralls to simply fail in that case. @lindig, what was your reason for including the digest? -
line_countis there for the same reason as lines in locations, so that you can know how many lines to report as unvisited without scanning the source, especially if it is missing. -
The source can be missing if we provide the
-no-source-codeoption:We could offer a preprocessor flag such as -no-source-code for users worried about accidentally leaking intellectual property in an instrumented binary.
I'm not really sure if it's even necessary to provide it. It would simplify the interface if we knew we don't have to worry about this.However, if someone does use-no-source-code, the?source_code_directoryoption toreadwould be a fallback to look for source files in the file system. -
If we proceed with this, Bisect_ppx's library will become incompatible with Bisect's. That will complicate ocveralls, if it wants to be compatible with both. @sagotch, what do you think?
Work
-
.cmp(Eliminate .cmp files #102). -
Sources (Suggestion: inline source into instrumented files #103). Abandoned. See Problem using with Esy/Reason/Dune #187 (comment). - Provide the new interface.
- Hide (what's left of)
Bisect.Commonor discourage its use, e.g. by renaming it toInternal.Bisect.Commonwas renamed toBisect_commonas part of BuckleScript build, NPM packaging, Js_of_ocaml support #206. This isn't quite hiding, but it's enough to disrupt any current users. - Avoid use of
Marshalfor.outfiles (see documentation for file format #114). Done as part of BuckleScript build, NPM packaging, Js_of_ocaml support #206, see 923f088.