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 tests/make: migrate cond1 test to ot...
details: https://anonhg.NetBSD.org/src/rev/b9f125896748
branches: trunk
changeset: 365996:b9f125896748
user: rillig <rillig%NetBSD.org@localhost>
date: Sun May 08 06:51:27 2022 +0000
description:
tests/make: migrate cond1 test to other, more specific tests
The tests in cond1 were a mixture of "everything related to conditions",
and the test cases were heavily dependent on each other, which made them
hard to understand. Move each test case to its corresponding
special-purpose test.
diffstat:
distrib/sets/lists/tests/mi | 6 +-
usr.bin/make/unit-tests/Makefile | 3 +-
usr.bin/make/unit-tests/comment.mk | 4 +-
usr.bin/make/unit-tests/compat-error.mk | 25 +++-
usr.bin/make/unit-tests/cond-cmp-string.mk | 10 +-
usr.bin/make/unit-tests/cond-func-defined.mk | 11 +-
usr.bin/make/unit-tests/cond-token-string.exp | 4 +
usr.bin/make/unit-tests/cond-token-string.mk | 21 +++-
usr.bin/make/unit-tests/cond1.exp | 23 -----
usr.bin/make/unit-tests/cond1.mk | 114 -------------------------
usr.bin/make/unit-tests/directive-for-lines.mk | 6 +-
usr.bin/make/unit-tests/directive-for-null.mk | 4 +-
usr.bin/make/unit-tests/directive-info.mk | 4 +-
usr.bin/make/unit-tests/opt-jobs-no-action.mk | 4 +-
usr.bin/make/unit-tests/varmod-ifelse.mk | 17 +++-
usr.bin/make/unit-tests/varmod-match.mk | 18 +++-
16 files changed, 102 insertions(+), 172 deletions(-)
diffs (truncated from 470 to 300 lines):
diff -r d8c4978ebee3 -r b9f125896748 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun May 08 06:38:58 2022 +0000
+++ b/distrib/sets/lists/tests/mi Sun May 08 06:51:27 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1201 2022/04/29 22:17:50 pgoyette Exp $
+# $NetBSD: mi,v 1.1202 2022/05/08 06:51:27 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5459,8 +5459,8 @@
./usr/tests/usr.bin/make/unit-tests/cond-token-var.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond-undef-lint.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond-undef-lint.mk tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/cond1.exp tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/cond1.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/cond1.exp tests-obsolete obsolete,atf
+./usr/tests/usr.bin/make/unit-tests/cond1.mk tests-obsolete obsolete,atf
./usr/tests/usr.bin/make/unit-tests/cond2.exp obsolete-tests obsolete
./usr/tests/usr.bin/make/unit-tests/cond2.mk obsolete-tests obsolete
./usr/tests/usr.bin/make/unit-tests/counter-append.exp tests-usr.bin-tests compattestfile,atf
diff -r d8c4978ebee3 -r b9f125896748 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Sun May 08 06:38:58 2022 +0000
+++ b/usr.bin/make/unit-tests/Makefile Sun May 08 06:51:27 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.313 2022/05/07 17:49:47 rillig Exp $
+# $NetBSD: Makefile,v 1.314 2022/05/08 06:51:27 rillig Exp $
#
# Unit tests for make(1)
#
@@ -84,7 +84,6 @@
TESTS+= cond-token-string
TESTS+= cond-token-var
TESTS+= cond-undef-lint
-TESTS+= cond1
TESTS+= counter
TESTS+= counter-append
TESTS+= dep
diff -r d8c4978ebee3 -r b9f125896748 usr.bin/make/unit-tests/comment.mk
--- a/usr.bin/make/unit-tests/comment.mk Sun May 08 06:38:58 2022 +0000
+++ b/usr.bin/make/unit-tests/comment.mk Sun May 08 06:51:27 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: comment.mk,v 1.4 2022/01/23 18:00:53 rillig Exp $
+# $NetBSD: comment.mk,v 1.5 2022/05/08 06:51:27 rillig Exp $
#
# Demonstrate how comments are written in makefiles.
@@ -23,7 +23,7 @@
.endif # And after the closing directive.
VAR= # This comment makes the variable value empty.
- # ParseGetLine removes any whitespace before the
+ # ParseRawLine removes any whitespace before the
# comment.
.if ${VAR} != ""
. error
diff -r d8c4978ebee3 -r b9f125896748 usr.bin/make/unit-tests/compat-error.mk
--- a/usr.bin/make/unit-tests/compat-error.mk Sun May 08 06:38:58 2022 +0000
+++ b/usr.bin/make/unit-tests/compat-error.mk Sun May 08 06:51:27 2022 +0000
@@ -1,14 +1,21 @@
-# $NetBSD: compat-error.mk,v 1.4 2022/05/07 08:01:20 rillig Exp $
+# $NetBSD: compat-error.mk,v 1.5 2022/05/08 06:51:27 rillig Exp $
#
# Test detailed error handling in compat mode.
#
-# Until 2020-12-13, .ERROR_TARGET was success3, which was wrong.
-# Since compat.c 1.215 from 2020-12-13, it is 'fail1', which is the first
-# failed top-level target. XXX: Even better would be if .ERROR_TARGET were
-# the smallest target that caused the build to fail, even if it were a
-# sub-sub-sub-dependency of a top-level target.
+# Make several targets that alternately succeed and fail.
+#
+# The first failing top-level target is recorded in '.ERROR_TARGET'. While
+# this information may give a hint as to which target failed, it would be more
+# useful at that point to know the actual target that failed, or the complete
+# chain from root cause to top-level target.
#
-# XXX: As of 2020-12-13, .ERROR_CMD is empty, which is wrong.
+# Historic bugs
+# Before compat.c 1.215 from 2020-12-13, '.ERROR_TARGET' was 'success3',
+# which was obviously wrong.
+#
+# Bugs
+# As of 2020-12-13, '.ERROR_CMD' is empty, which does not provide any
+# insight into the command that actually failed.
#
# See also:
# Compat_MakeAll
@@ -20,10 +27,10 @@
# 2020: LstNode_SetNull(cmdNode);
#
# The commit that skipped NULL commands for .ERROR_CMD:
-# CVS: 2016.08.11.19.53.??
+# CVS: 2016.08.11.19.53.17
# Git: 58b23478b7353d46457089e726b07a49197388e4
-.MAKEFLAGS: success1 fail1 success2 fail2 success3
+.MAKEFLAGS: -k success1 fail1 success2 fail2 success3
success1 success2 success3:
: Making ${.TARGET} out of nothing.
diff -r d8c4978ebee3 -r b9f125896748 usr.bin/make/unit-tests/cond-cmp-string.mk
--- a/usr.bin/make/unit-tests/cond-cmp-string.mk Sun May 08 06:38:58 2022 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-string.mk Sun May 08 06:51:27 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-string.mk,v 1.15 2021/12/11 09:53:53 rillig Exp $
+# $NetBSD: cond-cmp-string.mk,v 1.16 2022/05/08 06:51:27 rillig Exp $
#
# Tests for string comparisons in .if conditions.
@@ -136,3 +136,11 @@
.else
. error
.endif
+
+# Two variables with different values compare unequal.
+VAR1= value1
+VAR2= value2
+.if ${VAR1} != ${VAR2}
+.else
+. error
+.endif
diff -r d8c4978ebee3 -r b9f125896748 usr.bin/make/unit-tests/cond-func-defined.mk
--- a/usr.bin/make/unit-tests/cond-func-defined.mk Sun May 08 06:38:58 2022 +0000
+++ b/usr.bin/make/unit-tests/cond-func-defined.mk Sun May 08 06:51:27 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func-defined.mk,v 1.8 2021/12/12 08:55:28 rillig Exp $
+# $NetBSD: cond-func-defined.mk,v 1.9 2022/05/08 06:51:27 rillig Exp $
#
# Tests for the defined() function in .if conditions.
@@ -48,5 +48,10 @@
. endif
.endfor
-all:
- @:;
+# Neither of the conditions is true. Before July 2020, the right-hand
+# condition was evaluated even though it was irrelevant.
+.if defined(UNDEF) && ${UNDEF:Mx} != ""
+. error
+.endif
+
+all: .PHONY
diff -r d8c4978ebee3 -r b9f125896748 usr.bin/make/unit-tests/cond-token-string.exp
--- a/usr.bin/make/unit-tests/cond-token-string.exp Sun May 08 06:38:58 2022 +0000
+++ b/usr.bin/make/unit-tests/cond-token-string.exp Sun May 08 06:51:27 2022 +0000
@@ -13,6 +13,10 @@
make: "cond-token-string.mk" line 68: A nonempty variable expression evaluates to true.
CondParser_Eval: "${:U}"
make: "cond-token-string.mk" line 76: An empty variable evaluates to false.
+CondParser_Eval: ("${VALUE}")
+make: "cond-token-string.mk" line 84: Missing argument for ".error"
+CondParser_Eval: "quoted" == quoted
+Comparing "quoted" == "quoted"
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
diff -r d8c4978ebee3 -r b9f125896748 usr.bin/make/unit-tests/cond-token-string.mk
--- a/usr.bin/make/unit-tests/cond-token-string.mk Sun May 08 06:38:58 2022 +0000
+++ b/usr.bin/make/unit-tests/cond-token-string.mk Sun May 08 06:51:27 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-string.mk,v 1.4 2021/01/21 00:38:28 rillig Exp $
+# $NetBSD: cond-token-string.mk,v 1.5 2022/05/08 06:51:27 rillig Exp $
#
# Tests for quoted string literals in .if conditions.
#
@@ -76,7 +76,22 @@
. info An empty variable evaluates to false.
.endif
+# A non-empty string evaluates to true, no matter if it's a literal string or
+# if it contains variable expressions.
+VAR= value
+.if ("${VALUE}")
+.else
+. error
+.endif
+
+# In the conditions in .if directives, the left-hand side of a comparison must
+# be enclosed in quotes. The right-hand side does not need to be enclosed in
+# quotes.
+.if "quoted" == quoted
+.else
+. error
+.endif
+
.MAKEFLAGS: -d0
-all:
- @:;
+all: .PHONY
diff -r d8c4978ebee3 -r b9f125896748 usr.bin/make/unit-tests/cond1.exp
--- a/usr.bin/make/unit-tests/cond1.exp Sun May 08 06:38:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-make: "cond1.mk" line 80: warning: extra else
-make: "cond1.mk" line 90: warning: extra else
-2 is prime
-A='other' B='unknown' C='clever' o='no,no'
-Passed:
- var
- ("var")
- (var != var)
- var != var
- !((var != var) && defined(name))
- var == quoted
-
-1 is not prime
-2 is prime
-3 is prime
-4 is not prime
-5 is prime
-
-make: String comparison operator must be either == or !=
-make: Bad conditional expression '"0" > 0' in '"0" > 0?OK:No'
-
-OK
-exit status 0
diff -r d8c4978ebee3 -r b9f125896748 usr.bin/make/unit-tests/cond1.mk
--- a/usr.bin/make/unit-tests/cond1.mk Sun May 08 06:38:58 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-# $NetBSD: cond1.mk,v 1.3 2020/11/15 14:58:14 rillig Exp $
-
-# TODO: Convert these tests into tutorial form.
-# TODO: Split these tests by topic.
-# TODO: Use better variable names and expression values that actually express
-# the intended behavior. uname(1) has nothing to do with conditions.
-
-# hard code these!
-TEST_UNAME_S= NetBSD
-TEST_UNAME_M= sparc
-TEST_MACHINE= i386
-
-.if ${TEST_UNAME_S}
-Ok=var,
-.endif
-.if ("${TEST_UNAME_S}")
-Ok+=(\"var\"),
-.endif
-.if (${TEST_UNAME_M} != ${TEST_MACHINE})
-Ok+=(var != var),
-.endif
-.if ${TEST_UNAME_M} != ${TEST_MACHINE}
-Ok+= var != var,
-.endif
-.if !((${TEST_UNAME_M} != ${TEST_MACHINE}) && defined(X))
-Ok+= !((var != var) && defined(name)),
-.endif
-# from bsd.obj.mk
-MKOBJ?=no
-.if ${MKOBJ} == "no"
-o= no
-Ok+= var == "quoted",
-.else
-.if defined(notMAKEOBJDIRPREFIX) || defined(norMAKEOBJDIR)
-.if defined(notMAKEOBJDIRPREFIX)
-o=${MAKEOBJDIRPREFIX}${__curdir}
-.else
-o= ${MAKEOBJDIR}
-.endif
-.endif
-o= o
-.endif
-
-# repeat the above to check we get the same result
-.if ${MKOBJ} == "no"
-o2= no
-.else
-.if defined(notMAKEOBJDIRPREFIX) || defined(norMAKEOBJDIR)
-.if defined(notMAKEOBJDIRPREFIX)
-o2=${MAKEOBJDIRPREFIX}${__curdir}
-.else
-o2= ${MAKEOBJDIR}
-.endif
-.endif
-o2= o
-.endif
-
-PRIMES=2 3 5 7 11
-NUMBERS=1 2 3 4 5
-
-n=2
-.if ${PRIMES:M$n} == ""
-X=not
-.else
-X=
-.endif
-
-.if ${MACHINE_ARCH} == no-such
-A=one
-.else
-.if ${MACHINE_ARCH} == not-this
-.if ${MACHINE_ARCH} == something-else
-A=unlikely
-.else
-A=no
-.endif
-.endif
-A=other
Home |
Main Index |
Thread Index |
Old Index