Slightly Preferable to the Alternative

Auto-Running Tests on Function Recompilation

Posted on 2020-03-31

When writing code, it would be really nice for unit tests associated with a given function to be run when you re-compile that function. As far as I know, there isn't any existing code or tool that does this, so I'm going to describe a few ways that I could imagine it (easily) being done. Note that I will assume that the user has to manually specify which tests are associated with a given function - automatic inference is too tricky.

  1. entr
  2. Proxy between SLIME and SWANK
  3. Redefining or hooking slime-compile-*
  4. Macro wrapper around DEFUN
  5. Saving all function objects in a list and polling for changes

entr

Invoke entr on FASLs generated by the implementation. This assumes that an implementation will re-write the FASLs every time a function is interactively recompiled - which does not appear to be the case on SBCL, at least.