Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add very basic test for arc...



details:   https://anonhg.NetBSD.org/src/rev/0c67e37fd0ee
branches:  trunk
changeset: 1012327:0c67e37fd0ee
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jul 27 18:51:03 2020 +0000

description:
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.

diffstat:

 distrib/sets/lists/tests/mi         |   4 +++-
 usr.bin/make/unit-tests/Makefile    |   3 ++-
 usr.bin/make/unit-tests/archive.exp |  10 ++++++++++
 usr.bin/make/unit-tests/archive.mk  |  37 +++++++++++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+), 2 deletions(-)

diffs (90 lines):

diff -r 181e8a728346 -r 0c67e37fd0ee distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Mon Jul 27 18:38:10 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Mon Jul 27 18:51:03 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.878 2020/07/26 22:15:36 rillig Exp $
+# $NetBSD: mi,v 1.879 2020/07/27 18:51:03 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4522,6 +4522,8 @@
 ./usr/tests/usr.bin/make/t_make                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/Makefile   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/archive.exp        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/archive.mk tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/comment.exp        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/comment.mk tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond-late.exp      tests-usr.bin-tests     compattestfile,atf
diff -r 181e8a728346 -r 0c67e37fd0ee usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Mon Jul 27 18:38:10 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Mon Jul 27 18:51:03 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.66 2020/07/26 22:15:36 rillig Exp $
+# $NetBSD: Makefile,v 1.67 2020/07/27 18:51:56 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -30,6 +30,7 @@
 
 # Each test is in a sub-makefile.
 # Keep the list sorted.
+TESTS+=                archive
 TESTS+=                comment
 TESTS+=                cond-late
 TESTS+=                cond-short
diff -r 181e8a728346 -r 0c67e37fd0ee usr.bin/make/unit-tests/archive.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/archive.exp       Mon Jul 27 18:51:03 2020 +0000
@@ -0,0 +1,10 @@
+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
diff -r 181e8a728346 -r 0c67e37fd0ee usr.bin/make/unit-tests/archive.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/archive.mk        Mon Jul 27 18:51:03 2020 +0000
@@ -0,0 +1,37 @@
+# $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}



Home | Main Index | Thread Index | Old Index