Implementing `make check` or `make test`

后端 未结 4 953
生来不讨喜
生来不讨喜 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条回答
  •  萌比男神i
    2021-01-30 12:01

    Make a test runner script that takes a test name and infers the input filename, output filename and smaple data from that:

    #!/bin/sh
    set -e
    jscheme < $1.in > $1.out 2>&1
    diff -q $1.out $1.cmp
    

    Then, in your Makefile:

    TESTS := expr unrecognised
    
    .PHONY: test
    test:
        for test in $(TESTS); do bash test-runner.sh $$test || exit 1; done
    

    You could also try implementing something like automake's simple test framework.

提交回复
热议问题