Implementing `make check` or `make test`

后端 未结 4 915
生来不讨喜
生来不讨喜 2021-01-30 11:35

How can I implement a simple regression test framework with Make? (I’m using GNU Make, if that matters.)

My current makefile looks something like this (edited for simpl

4条回答
  •  时光取名叫无心
    2021-01-30 12:05

    I'll address just your question about diff. You can do:

    diff file1 file2 > /dev/null || echo Test blah blah failed >&2
    

    although you might want to use cmp instead of diff.

    On another note, you might find it helpful to go ahead and take the plunge and use automake. Your Makefile.am (in its entirety) will look like:

    bin_PROGRAMS = jscheme
    jscheme_SOURCES = jscheme.c utility.c model.c read.c eval.c print.c jscheme.h
    TESTS = test-script
    

    and you will get a whole lot of really nice targets for free, including a pretty full-featured test framework.

提交回复
热议问题