summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDmitry Goncharov <dgoncharov@users.sf.net>2023-04-30 09:26:29 -0400
committerPaul Smith <psmith@gnu.org>2023-04-30 09:40:50 -0400
commit0880e5c86ab7ba92c3ba0f83bab1a230906ee657 (patch)
tree75fccb4b7d42e54162b2bcf855ddd08868c8e749 /tests
parent0e06c7588961bb04c7bb01606356941baf1cb146 (diff)
downloadmake-git-0880e5c86ab7ba92c3ba0f83bab1a230906ee657.tar.gz
[SV 64107] Disable builtins immediately on -R or -r
Disable builtin variables and rules immediately, when -R or -r is added to MAKEFLAGS inside the makefile. * src/main.c (disable_builtins): Add new function disable_builtins(). (main): Call disable_builtins(). (reset_makeflags): Call disable_builtins(). * tests/scripts/options/dash-r: Add tests. * tests/scripts/variables/MAKEFLAGS: Update tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/options/dash-r63
-rw-r--r--tests/scripts/variables/MAKEFLAGS2
2 files changed, 62 insertions, 3 deletions
diff --git a/tests/scripts/options/dash-r b/tests/scripts/options/dash-r
index 7157f715..16eda104 100644
--- a/tests/scripts/options/dash-r
+++ b/tests/scripts/options/dash-r
@@ -2,8 +2,6 @@
$description = "Test removing default rules and variables";
-$details = "DETAILS";
-
touch('xxx.c');
# Simple check
@@ -41,4 +39,65 @@ MAKEFLAGS := -R
all: hello.o
!, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.", 512);
+my @flavors = ('=', ':=', ':::=', '+=');
+
+# sv 64107.
+
+# Use $answer to test that -R in the makefile has the same effect as -R on the
+# command line.
+
+my $answer = "at parse time TEX=\nat build time TEX=\n#MAKE#: 'all' is up to date.\n";
+
+# Subtest 1.
+# First run with -R command line switch.
+
+for my $fl (@flavors) {
+run_make_test("
+\$(info at parse time TEX=\$(TEX))
+all:; \$(info at build time TEX=\$(TEX))
+", '-R', "$answer");
+}
+
+# Subtest 2.
+# Set -R in the makefile.
+# Also, test that setting -R in MAKEFLAGS takes effect immediately.
+
+for my $fl (@flavors) {
+run_make_test("
+\$(info at start time TEX=\$(TEX))
+MAKEFLAGS ${fl} -R
+\$(info at parse time TEX=\$(TEX))
+all:; \$(info at build time TEX=\$(TEX))
+", '', "at start time TEX=tex\n$answer");
+}
+
+# Same as above, but also set TEX conditionally.
+
+$answer = "at parse time TEX=hello\nat build time TEX=hello\n#MAKE#: 'all' is up to date.\n";
+
+# Subtest 3.
+# -R on the command line.
+
+for my $fl (@flavors) {
+run_make_test("
+TEX ?= hello
+\$(info at parse time TEX=\$(TEX))
+all:; \$(info at build time TEX=\$(TEX))
+", '-R', "$answer");
+}
+
+# Subtest 4.
+# -R in the makefile.
+
+for my $fl (@flavors) {
+run_make_test("
+\$(info at start time TEX=\$(TEX))
+MAKEFLAGS ${fl} -R
+TEX ?= hello
+\$(info at parse time TEX=\$(TEX))
+all:; \$(info at build time TEX=\$(TEX))
+", '', "at start time TEX=tex\n$answer");
+}
+
+
1;
diff --git a/tests/scripts/variables/MAKEFLAGS b/tests/scripts/variables/MAKEFLAGS
index fc18d650..aab4a0e1 100644
--- a/tests/scripts/variables/MAKEFLAGS
+++ b/tests/scripts/variables/MAKEFLAGS
@@ -297,7 +297,7 @@ MAKEFLAGS${fl}R
all:; \$(info \$(MAKEFLAGS))
", 'bye=moon',
"$answer
-R$answer
+rR$answer
rR$answer
#MAKE#: 'all' is up to date.\n");
}