title: Implementing `make check` or `make test`
body: <p>How can I implement a simple regression test framework with Make?  (I’m using GNU Make, if that matters.)</p>
  
  <p>My current makefile looks something like this (edited for simplicity):</p>
  
  <pre><code>OBJS = jscheme.o utility.o model.o read.o eval.o print.o
  
  %.o : %.c jscheme.h
      gcc -c -o $@ $&lt;
  
  jscheme : $(OBJS)
      gcc -o $@ $(OBJS)
  
  .PHONY : clean
  
  clean :
      -rm -f jscheme $(OBJS)
  </code></pre>
  
  <p>I’d like to have a set of regression tests, <em>e.g.</em>, <code>expr.in</code> testing a “good” expression &amp; <code>unrecognized.in</code> testing a “bad” one, with <code>expr.cmp</code> &amp; <code>unrecognized.cmp</code> being the expected output for each.  Manual testing would look like this:</p>
  
  <pre><code>$ jscheme &lt; expr.in &gt; expr.out 2&gt;&amp;1
  $ jscheme &lt; unrecognized.in &gt; unrecognized.out 2&gt;&amp;1
  $ diff -q expr.out expr.cmp # identical
  $ diff -q unrecognized.out unrecognized.cmp
  Files unrecognized.out and unrecognized.cmp differ
  </code></pre>
  
  <p>I thought to add a set of rules to the makefile looking something like this:</p>
  
  <pre><code>TESTS = expr.test unrecognized.test
  
  .PHONY test $(TESTS)
  
  test : $(TESTS)
  
  %.test : jscheme %.in %.cmp
      jscheme &lt; [something.in] &gt; [something.out] 2&gt;&amp;1
      diff -q [something.out] [something.cmp]
  </code></pre>
  
  <p>My questions:<br>
  • What do I put in the [something] placeholders?<br>
  • Is there a way to replace the message from <code>diff</code> with a message saying, “Test <code>expr</code> failed”?</p>