questions about SML/NJ test coverage tool

Joe Wells <[email protected]> Wed, 05 Aug 2009 17:45:52 +0100
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
I'm using SML/NJ version 110.54.

As a plugin for the TDP (tracing/debugging/profiling) framework,
SML/NJ comes with a test coverage tool.

Is there any documentation for this anywhere?  I had to figure things
out by reading the (largely uncommented) source code.

Here's roughly how you use it (at the top-level interactive REPL):

  CM.make "$smlnj-tdp/plugins.cm";
  fun uninstall_coverage () =
    let val pRef = SMLofNJ.Internals.TDP.active_plugins
    in pRef := (List.filter (fn p => not ((#name p) = "coverage")) (!pRef))
    end;
  SMLofNJ.Internals.TDP.mode := true;
  Coverage.install ();
  use "foo.sml"; (* COMPILE CODE TO BE INSTRUMENTED HERE *)
  foo (); (* RUN INSTRUMENTED CODE HERE *)
  SMLofNJ.Internals.TDP.mode := false;
  uninstall_coverage (); (* or else all further interactive input will pollute the table *)
  val kinds = let open Coverage in [(functions, "entry point"), (non_tail_calls, "non-tail call"), (tail_calls, "tail call")] end;
  (* list the 999999 most frequently executed spots for each type of spot: *)
  List.app (fn (k,d) => (print (d^":\n"); Coverage.hot_spots [k] 999999)) kinds; (* 999999 should be largest number *)

The output looks like this:

  entry point:
    1 foo.sml:3.5-3.16: g[2]
    1 foo.sml:2.5-2.37: f[2]
    0 foo.sml:4.5-4.16: foo[2]
    0 foo.sml:1.5-1.14: e[2]
  non-tail call:
    1 stdIn:9.41-9.62: it
    1 stdIn:7.3-7.20: it
    0 stdIn:8.3-8.7: it
  tail call:
    1 foo.sml:4.12-4.16: foo[2]
    1 foo.sml:3.12-3.16: g[2]
    0 foo.sml:2.33-2.37: f[2]

The format of each line is: execution count, file name, starting
position (line and column (lowest column is 1)), ending position
(actually position after end), function name, and some mystery value
in square brackets.

Does anyone know what the mystery value in each output line is?

Has anyone written code to take this output and highlight the source
code accordingly (ideally in Emacs)?

Has anyone written a better TDP test coverage plugin that improves in
any interesting way on the one that comes with SML/NJ?  Are there
*any* TDP plugins other than those that come with SML/NJ?

Thanks for any answers!

-- 
Joe


-- 
Heriot-Watt University is a Scottish charity
registered under charity number SC000278.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july