From eae757843771d4b5e95842fea9ae6149baeab5c3 Mon Sep 17 00:00:00 2001 From: rillig Date: Sat, 1 Jun 2024 11:06:17 +0000 Subject: [PATCH] tests/make: cover purging the realpath cache In purge_relative_cached_realpaths, the hash table containing the cache is modified while being iterated, which needs extra care, so add a test that covers this code in at least a single simple scenario. --- usr.bin/make/unit-tests/varname-dot-objdir.exp | 1 + usr.bin/make/unit-tests/varname-dot-objdir.mk | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/usr.bin/make/unit-tests/varname-dot-objdir.exp b/usr.bin/make/unit-tests/varname-dot-objdir.exp index 39a9383953dd..430e2c898172 100644 --- a/usr.bin/make/unit-tests/varname-dot-objdir.exp +++ b/usr.bin/make/unit-tests/varname-dot-objdir.exp @@ -1 +1,2 @@ +: purge-cache was reached. exit status 0 diff --git a/usr.bin/make/unit-tests/varname-dot-objdir.mk b/usr.bin/make/unit-tests/varname-dot-objdir.mk index e662e8ac56fa..0f53165bba41 100644 --- a/usr.bin/make/unit-tests/varname-dot-objdir.mk +++ b/usr.bin/make/unit-tests/varname-dot-objdir.mk @@ -1,8 +1,15 @@ -# $NetBSD: varname-dot-objdir.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: varname-dot-objdir.mk,v 1.3 2024/06/01 11:06:17 rillig Exp $ # # Tests for the special .OBJDIR variable. # TODO: Implementation all: - @:; + # Add an entry to the cached_realpath table, to test cleaning up + # that table in purge_relative_cached_realpaths. + # Having a ':=' assignment in the command line is construed but works + # well enough to reach the code. + @${MAKE} -f ${MAKEFILE} 'VAR:=$${:U.:tA}' purge-cache + +purge-cache: + : ${.TARGET} was reached.