Mon Jul 27 18:51:03 2020 UTC ()
make(1): add very basic test for archive handling

The whole code in arch.c had been uncovered by tests before.

The code coverage shows that neither the archive name nor the member
contain any $, even though archive.mk looks like it.  It could be
necessary to place the variable assignments below the dependency line,
to force late evaluation.


(rillig)
diff -r1.878 -r1.879 src/distrib/sets/lists/tests/mi
diff -r0 -r1.1 src/usr.bin/make/unit-tests/archive.exp
diff -r0 -r1.1 src/usr.bin/make/unit-tests/archive.mk

cvs diff -r1.878 -r1.879 src/distrib/sets/lists/tests/mi (expand / switch to unified diff)

--- src/distrib/sets/lists/tests/mi 2020/07/26 22:15:36 1.878
+++ src/distrib/sets/lists/tests/mi 2020/07/27 18:51:03 1.879
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.878 2020/07/26 22:15:36 rillig Exp $ 1# $NetBSD: mi,v 1.879 2020/07/27 18:51:03 rillig Exp $
2# 2#
3# Note: don't delete entries from here - mark them as "obsolete" instead. 3# Note: don't delete entries from here - mark them as "obsolete" instead.
4# 4#
5./etc/mtree/set.tests tests-sys-root 5./etc/mtree/set.tests tests-sys-root
6./usr/libdata/debug/usr/tests tests-base-debug compattestdir 6./usr/libdata/debug/usr/tests tests-base-debug compattestdir
7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf 7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf
8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf 8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf
9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf 9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf
10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf 10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf
11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf 11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf
12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete 12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete
13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete 13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete
14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete 14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete
@@ -4512,26 +4512,28 @@ @@ -4512,26 +4512,28 @@
4512./usr/tests/usr.bin/make/d_posix.mk tests-obsolete obsolete,atf 4512./usr/tests/usr.bin/make/d_posix.mk tests-obsolete obsolete,atf
4513./usr/tests/usr.bin/make/d_posix.out tests-obsolete obsolete,atf 4513./usr/tests/usr.bin/make/d_posix.out tests-obsolete obsolete,atf
4514./usr/tests/usr.bin/make/d_qequals.mk tests-obsolete obsolete,atf 4514./usr/tests/usr.bin/make/d_qequals.mk tests-obsolete obsolete,atf
4515./usr/tests/usr.bin/make/d_qequals.out tests-obsolete obsolete,atf 4515./usr/tests/usr.bin/make/d_qequals.out tests-obsolete obsolete,atf
4516./usr/tests/usr.bin/make/d_ternary.mk tests-obsolete obsolete,atf 4516./usr/tests/usr.bin/make/d_ternary.mk tests-obsolete obsolete,atf
4517./usr/tests/usr.bin/make/d_ternary.out tests-obsolete obsolete,atf 4517./usr/tests/usr.bin/make/d_ternary.out tests-obsolete obsolete,atf
4518./usr/tests/usr.bin/make/d_unmatchedvarparen.mk tests-obsolete obsolete,atf 4518./usr/tests/usr.bin/make/d_unmatchedvarparen.mk tests-obsolete obsolete,atf
4519./usr/tests/usr.bin/make/d_unmatchedvarparen.out tests-obsolete obsolete,atf 4519./usr/tests/usr.bin/make/d_unmatchedvarparen.out tests-obsolete obsolete,atf
4520./usr/tests/usr.bin/make/d_varcmd.mk tests-obsolete obsolete,atf 4520./usr/tests/usr.bin/make/d_varcmd.mk tests-obsolete obsolete,atf
4521./usr/tests/usr.bin/make/d_varcmd.out tests-obsolete obsolete,atf 4521./usr/tests/usr.bin/make/d_varcmd.out tests-obsolete obsolete,atf
4522./usr/tests/usr.bin/make/t_make tests-usr.bin-tests compattestfile,atf 4522./usr/tests/usr.bin/make/t_make tests-usr.bin-tests compattestfile,atf
4523./usr/tests/usr.bin/make/unit-tests tests-usr.bin-tests compattestfile,atf 4523./usr/tests/usr.bin/make/unit-tests tests-usr.bin-tests compattestfile,atf
4524./usr/tests/usr.bin/make/unit-tests/Makefile tests-usr.bin-tests compattestfile,atf 4524./usr/tests/usr.bin/make/unit-tests/Makefile tests-usr.bin-tests compattestfile,atf
 4525./usr/tests/usr.bin/make/unit-tests/archive.exp tests-usr.bin-tests compattestfile,atf
 4526./usr/tests/usr.bin/make/unit-tests/archive.mk tests-usr.bin-tests compattestfile,atf
4525./usr/tests/usr.bin/make/unit-tests/comment.exp tests-usr.bin-tests compattestfile,atf 4527./usr/tests/usr.bin/make/unit-tests/comment.exp tests-usr.bin-tests compattestfile,atf
4526./usr/tests/usr.bin/make/unit-tests/comment.mk tests-usr.bin-tests compattestfile,atf 4528./usr/tests/usr.bin/make/unit-tests/comment.mk tests-usr.bin-tests compattestfile,atf
4527./usr/tests/usr.bin/make/unit-tests/cond-late.exp tests-usr.bin-tests compattestfile,atf 4529./usr/tests/usr.bin/make/unit-tests/cond-late.exp tests-usr.bin-tests compattestfile,atf
4528./usr/tests/usr.bin/make/unit-tests/cond-late.mk tests-usr.bin-tests compattestfile,atf 4530./usr/tests/usr.bin/make/unit-tests/cond-late.mk tests-usr.bin-tests compattestfile,atf
4529./usr/tests/usr.bin/make/unit-tests/cond-short.exp tests-usr.bin-tests compattestfile,atf 4531./usr/tests/usr.bin/make/unit-tests/cond-short.exp tests-usr.bin-tests compattestfile,atf
4530./usr/tests/usr.bin/make/unit-tests/cond-short.mk tests-usr.bin-tests compattestfile,atf 4532./usr/tests/usr.bin/make/unit-tests/cond-short.mk tests-usr.bin-tests compattestfile,atf
4531./usr/tests/usr.bin/make/unit-tests/cond1.exp tests-usr.bin-tests compattestfile,atf 4533./usr/tests/usr.bin/make/unit-tests/cond1.exp tests-usr.bin-tests compattestfile,atf
4532./usr/tests/usr.bin/make/unit-tests/cond1.mk tests-usr.bin-tests compattestfile,atf 4534./usr/tests/usr.bin/make/unit-tests/cond1.mk tests-usr.bin-tests compattestfile,atf
4533./usr/tests/usr.bin/make/unit-tests/cond2.exp tests-usr.bin-tests compattestfile,atf 4535./usr/tests/usr.bin/make/unit-tests/cond2.exp tests-usr.bin-tests compattestfile,atf
4534./usr/tests/usr.bin/make/unit-tests/cond2.mk tests-usr.bin-tests compattestfile,atf 4536./usr/tests/usr.bin/make/unit-tests/cond2.mk tests-usr.bin-tests compattestfile,atf
4535./usr/tests/usr.bin/make/unit-tests/dollar.exp tests-usr.bin-tests compattestfile,atf 4537./usr/tests/usr.bin/make/unit-tests/dollar.exp tests-usr.bin-tests compattestfile,atf
4536./usr/tests/usr.bin/make/unit-tests/dollar.mk tests-usr.bin-tests compattestfile,atf 4538./usr/tests/usr.bin/make/unit-tests/dollar.mk tests-usr.bin-tests compattestfile,atf
4537./usr/tests/usr.bin/make/unit-tests/doterror.exp tests-usr.bin-tests compattestfile,atf 4539./usr/tests/usr.bin/make/unit-tests/doterror.exp tests-usr.bin-tests compattestfile,atf

File Added: src/usr.bin/make/unit-tests/archive.exp
ar cru libprog.a archive.mk modmisc.mk varmisc.mk
ranlib libprog.a
ar t libprog.a
archive.mk
modmisc.mk
varmisc.mk
depend-on-existing-member
`depend-on-nonexistent-member' is up to date.
rm libprog.a
exit status 0

File Added: src/usr.bin/make/unit-tests/archive.mk
# $NetBSD: archive.mk,v 1.1 2020/07/27 18:51:03 rillig Exp $
#
# Very basic demonstration of handling archives, based on the description
# in PSD.doc/tutorial.ms.

ARCHIVE=	libprog.${EXT.a}
FILES=		archive.${EXT.mk} modmisc.${EXT.mk} varmisc.mk

EXT.a=		a
EXT.mk=		mk

MAKE_CMD=	${.MAKE} -f ${MAKEFILE}
RUN?=		@set -eu;

all:
	${RUN} ${MAKE_CMD} create-archive
	${RUN} ${MAKE_CMD} list-archive
	${RUN} ${MAKE_CMD} depend-on-existing-member
	${RUN} ${MAKE_CMD} depend-on-nonexistent-member
	${RUN} ${MAKE_CMD} remove-archive

create-archive: ${ARCHIVE}
${ARCHIVE}: ${ARCHIVE}(${FILES})
	ar cru ${.TARGET} ${.OODATE}
	ranlib ${.TARGET}

list-archive: ${ARCHIVE}
	ar t ${.ALLSRC}

depend-on-existing-member: ${ARCHIVE}(archive.mk)
	${RUN} echo $@

depend-on-nonexistent-member: ${ARCHIVE}(nonexistent.mk)
	${RUN} echo $@

remove-archive: ${ARCHIVE}
	rm ${ARCHIVE}