byexample icon indicating copy to clipboard operation
byexample copied to clipboard

Autoinject code? Coverage/performance/others simplification

Open eldipa opened this issue 5 years ago • 0 comments

Describe the feature you'd like byexample allows to run arbitrary code at some points during the execution. These hooks points are described in the Concern interface.

One use case for these concerns/hooks is to enable coverage: the coverage system is initialized at the begin of the execution and at the end it generates a dump with the stats.

An example of this is the coverage.py of byexample.

Other cases could be:

  • enabling measure of performance for the whole execution or per example
  • enabling debug logs

These are the orthogonal things for what Concern was designed for.

But creating a Concern subclass, implement some of its methods in Python it may be to complex, specially for people coming from other languages.

It could be much nicer just say:

byexample -l ruby --enable-ruby-coverage <files>

But that is perhaps too much for byexample.

A tradeoff could be:

byexample -l ruby --inject "ruby:begin:<file>" --inject "ruby:end:<file>"  <files>

More cryptic, sure, but more general too: byexample could inject a ruby file at the begin and at the end of the execution.

byexample doesn't need to know about coverage/performance/debug/etc and the user doesn't need to know about Python and the Concern interface.

eldipa avatar Jul 03 '21 17:07 eldipa