2

I am using Rebar to build my erlang project and want to integrate it more tightly with Emacs. I found that if I add {cover_print_enabled, true}. to my rebar config file I get code coverage in the build output.

However there is also an option cover_export_enabled which outputs a binary file of some form. Is there an emacs plugin to parse that file and color code my code to show what code is covered by tests?

I really don't like having to switch to a browser to see code coverage.

Zachary K
  • 3,205
  • 1
  • 29
  • 36
  • Can you provide an example of output file - does it consists from binary data, or it's text data with ANSI colors? You can also display HTML in the Emacs, using the w3m or other package – Alex Ott May 09 '13 at 08:35
  • Binary, as I said in the post. Yes I could display the HTML in emacs but I really want to overlay it with my editing enviroment – Zachary K May 09 '13 at 09:55

2 Answers2

2

As far as I know, there is no such plugin.

The exported cover data file can be read as follows:

  1. Read one byte, giving the length of the next term; let's call it N.
  2. Read N bytes in Erlang binary term format. This can be decoded with binary_to_term/1.
  3. If the term from step 2 is of the form {'$size',X}, then read X bytes and decode as a term. (This happens when the binary representation of the term is longer than 255 bytes.)
  4. Continue from step 1, until end of file.

Distel has an Emacs Lisp implementation of binary_to_term called erlext-read-obj in erlext.el.

I haven't looked into what to do with the terms in the file, once decoded, but hopefully this is enough to get someone started. Read lib/tools/src/cover.erl if in doubt.

legoscia
  • 39,593
  • 22
  • 116
  • 167
0

Just added this feature to rebar.el in commit https://github.com/leoliu/rebar.el/commit/9ba8699ff6310721226b93341e62491ebfd0ee99

Leo

Leo
  • 121
  • 1
  • 3