[BACK]Return to Makefile CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / make / unit-tests

Annotation of src/usr.bin/make/unit-tests/Makefile, Revision 1.33

1.33    ! sjg         1: # $NetBSD: Makefile,v 1.32 2011/04/07 01:40:02 joerg Exp $
1.1       sjg         2: #
                      3: # Unit tests for make(1)
                      4: # The main targets are:
                      5: #
                      6: # all: run all the tests
                      7: # test:        run 'all', capture output and compare to expected results
                      8: # accept: move generated output to expected results
                      9: #
                     10: # Adding a test case.
1.11      sjg        11: # Each feature should get its own set of tests in its own suitably
                     12: # named makefile which should be added to SUBFILES to hook it in.
1.1       sjg        13: #
                     14:
                     15: .MAIN: all
                     16:
1.7       sjg        17: UNIT_TESTS:= ${.PARSEDIR}
                     18:
1.11      sjg        19: # Simple sub-makefiles - we run them as a black box
                     20: # keep the list sorted.
                     21: SUBFILES= \
1.16      rpaulo     22:        comment \
1.12      sjg        23:        cond1 \
1.26      sjg        24:        error \
1.21      sjg        25:        export \
                     26:        export-all \
1.26      sjg        27:        doterror \
1.19      apb        28:        dotwait \
1.24      sjg        29:        forsubst \
1.32      joerg      30:        hash \
1.31      sjg        31:        misc \
1.20      sjg        32:        moderrs \
1.11      sjg        33:        modmatch \
1.18      sjg        34:        modmisc \
1.15      sjg        35:        modorder \
1.11      sjg        36:        modts \
                     37:        modword \
1.33    ! sjg        38:        phony-end \
1.13      sjg        39:        posix \
1.22      sjg        40:        qequals \
1.31      sjg        41:        sysv \
1.11      sjg        42:        ternary \
1.25      sjg        43:        unexport \
                     44:        unexport-env \
1.11      sjg        45:        varcmd
                     46:
                     47: all: ${SUBFILES}
                     48:
1.26      sjg        49: flags.doterror=
                     50:
1.11      sjg        51: # the tests are actually done with sub-makes.
                     52: .PHONY: ${SUBFILES}
1.19      apb        53: .PRECIOUS: ${SUBFILES}
1.11      sjg        54: ${SUBFILES}:
1.26      sjg        55:        -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
1.9       sjg        56:
1.1       sjg        57: clean:
                     58:        rm -f *.out *.fail *.core
                     59:
1.27      sjg        60: .-include <bsd.obj.mk>
1.1       sjg        61:
1.15      sjg        62: TEST_MAKE?= ${.MAKE}
1.27      sjg        63: TOOL_SED?= sed
1.1       sjg        64:
1.28      sjg        65: # ensure consistent results from sort(1)
1.30      sjg        66: LC_ALL= C
1.28      sjg        67: LANG= C
1.29      sjg        68: .export LANG LC_ALL
1.28      sjg        69:
1.11      sjg        70: # The driver.
1.12      sjg        71: # We always pretend .MAKE was called 'make'
                     72: # and strip ${.CURDIR}/ from the output
1.13      sjg        73: # and replace anything after 'stopped in' with unit-tests
1.12      sjg        74: # so the results can be compared.
1.1       sjg        75: test:
                     76:        @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
1.6       sjg        77:        @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
1.23      apb        78:        ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \
1.13      sjg        79:        -e '/stopped/s, /.*, unit-tests,' \
1.17      apb        80:        -e 's,${.CURDIR:C/\./\\\./g}/,,g' \
                     81:        -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
1.1       sjg        82:        tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
1.7       sjg        83:        diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
1.1       sjg        84:
                     85: accept:
                     86:        mv test.out ${.CURDIR}/test.exp
                     87:

CVSweb <webmaster@jp.NetBSD.org>