summaryrefslogtreecommitdiff
path: root/tests/scripts/variables
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>1999-09-14 02:03:19 +0000
committerPaul Smith <psmith@gnu.org>1999-09-14 02:03:19 +0000
commit0d366b668244112846554c42045ff1d9956276ed (patch)
tree3802242fe18a5e90d889f5d1ac66fb487361888b /tests/scripts/variables
parent4121dea6a59367b4431cbe7a3c43d74fec9fd832 (diff)
downloadgunmake-0d366b668244112846554c42045ff1d9956276ed.tar.gz
* Added the test suite to the main distribution.
Diffstat (limited to 'tests/scripts/variables')
-rw-r--r--tests/scripts/variables/CURDIR18
-rw-r--r--tests/scripts/variables/MAKE33
-rw-r--r--tests/scripts/variables/MAKECMDGOALS50
-rw-r--r--tests/scripts/variables/MAKEFILES37
-rw-r--r--tests/scripts/variables/MAKELEVEL34
-rw-r--r--tests/scripts/variables/flavors68
6 files changed, 240 insertions, 0 deletions
diff --git a/tests/scripts/variables/CURDIR b/tests/scripts/variables/CURDIR
new file mode 100644
index 0000000..a4054bc
--- /dev/null
+++ b/tests/scripts/variables/CURDIR
@@ -0,0 +1,18 @@
+$description = "This tests the CURDIR varaible.";
+
+$details = "Echo CURDIR both with and without -C. Also ensure overrides work.";
+
+open(MAKEFILE,"> $makefile");
+print MAKEFILE "all: ; \@echo \$(CURDIR)\n";
+close(MAKEFILE);
+
+
+# TEST #1
+# -------
+
+&run_make_with_options($makefile,"",&get_logfile);
+$answer = "$pwd\n";
+&compare_output($answer,&get_logfile(1));
+
+
+1;
diff --git a/tests/scripts/variables/MAKE b/tests/scripts/variables/MAKE
new file mode 100644
index 0000000..7c4cf0a
--- /dev/null
+++ b/tests/scripts/variables/MAKE
@@ -0,0 +1,33 @@
+$description = "The following test creates a makefile to test MAKE \n"
+ ."(very generic)";
+
+$details = "DETAILS";
+
+open(MAKEFILE,"> $makefile");
+
+# The Contents of the MAKEFILE ...
+
+print MAKEFILE "TMP := \$(MAKE)\n";
+print MAKEFILE "MAKE := \$(subst X=\$(X),,\$(MAKE))\n\n";
+print MAKEFILE "all:\n";
+print MAKEFILE "\t\@echo \$(TMP)\n";
+print MAKEFILE "\t\$(MAKE) -f $makefile foo\n\n";
+print MAKEFILE "foo:\n";
+print MAKEFILE "\t\@echo \$(MAKE)\n";
+
+# END of Contents of MAKEFILE
+
+close(MAKEFILE);
+
+# Create the answer to what should be produced by this Makefile
+$answer = "$mkpath\n$mkpath -f $makefile foo\n"
+ . "${make_name}[1]: Entering directory `$pwd'\n"
+ . "$mkpath\n${make_name}[1]: Leaving directory `$pwd'\n";
+
+&run_make_with_options($makefile,"",&get_logfile,0);
+
+&delete("foo");
+# COMPARE RESULTS
+&compare_output($answer,&get_logfile(1));
+
+1;
diff --git a/tests/scripts/variables/MAKECMDGOALS b/tests/scripts/variables/MAKECMDGOALS
new file mode 100644
index 0000000..ec33358
--- /dev/null
+++ b/tests/scripts/variables/MAKECMDGOALS
@@ -0,0 +1,50 @@
+$description = "The following test creates a makefile to test the MAKECMDGOALS variable.";
+
+$details = "\
+We construct a makefile with various targets, all of which print out
+\$(MAKECMDGOALS), then call it different ways.";
+
+open(MAKEFILE,"> $makefile");
+print MAKEFILE "\
+.DEFAULT all:
+ \@echo \$(MAKECMDGOALS)
+";
+close(MAKEFILE);
+
+# TEST #1
+
+&run_make_with_options($makefile,
+ "",
+ &get_logfile,
+ 0);
+$answer = "\n";
+&compare_output($answer,&get_logfile(1));
+
+# TEST #2
+
+&run_make_with_options($makefile,
+ "all",
+ &get_logfile,
+ 0);
+$answer = "all\n";
+&compare_output($answer,&get_logfile(1));
+
+
+# TEST #3
+
+&run_make_with_options($makefile,
+ "foo bar baz yaz",
+ &get_logfile,
+ 0);
+$answer = "foo bar baz yaz\nfoo bar baz yaz\nfoo bar baz yaz\nfoo bar baz yaz\n";
+&compare_output($answer,&get_logfile(1));
+
+
+# This tells the test driver that the perl test script executed properly.
+1;
+
+
+
+
+
+
diff --git a/tests/scripts/variables/MAKEFILES b/tests/scripts/variables/MAKEFILES
new file mode 100644
index 0000000..d42909c
--- /dev/null
+++ b/tests/scripts/variables/MAKEFILES
@@ -0,0 +1,37 @@
+$description = "The following test creates a makefile to test ";
+
+$makefile2 = &get_tmpfile;
+
+open(MAKEFILE,"> $makefile");
+# The Contents of the MAKEFILE ...
+print MAKEFILE "MAKEFILES = work/MAKEFILES_variable.mk.2\n\n";
+print MAKEFILE "all:\n";
+print MAKEFILE "\t\@echo THIS IS THE DEFAULT RULE\n";
+# END of Contents of MAKEFILE
+close(MAKEFILE);
+
+
+open(MAKEFILE,"> $makefile2");
+print MAKEFILE "NDEF:\n";
+print MAKEFILE "\t\@echo THIS IS THE RULE FROM MAKEFILE 2\n";
+close(MAKEFILE);
+
+&run_make_with_options($makefile,"",&get_logfile);
+
+
+# Create the answer to what should be produced by this Makefile
+$answer = "THIS IS THE DEFAULT RULE\n";
+
+# COMPARE RESULTS
+
+# In this call to compare output, you should use the call &get_logfile(1)
+# to send the name of the last logfile created.
+
+&compare_output($answer,&get_logfile(1));
+
+# If you wish to stop if the compare fails, then add
+# a "|| &error ("abort")" to the
+# end of the previous line.
+
+# This tells the test driver that the perl test script executed properly.
+1;
diff --git a/tests/scripts/variables/MAKELEVEL b/tests/scripts/variables/MAKELEVEL
new file mode 100644
index 0000000..79a184e
--- /dev/null
+++ b/tests/scripts/variables/MAKELEVEL
@@ -0,0 +1,34 @@
+# -*-perl-mode-*-
+
+$description = "The following test creates a makefile to test
+makelevels in Make. It prints \$(MAKELEVEL) and then
+prints the environment variable MAKELEVEL";
+
+open(MAKEFILE,"> $makefile");
+
+# The Contents of the MAKEFILE ...
+
+print MAKEFILE <<EOF;
+SHELL = /bin/sh
+all:
+\t\@echo MAKELEVEL is \$(MAKELEVEL)
+\techo \$\$MAKELEVEL
+EOF
+
+# END of Contents of MAKEFILE
+
+close(MAKEFILE);
+
+# RUN MAKE
+
+&run_make_with_options($makefile,"",&get_logfile);
+
+# SET ANSWER
+
+$answer = "MAKELEVEL is 0\necho \$MAKELEVEL\n1\n";
+
+# COMPARE RESULTS
+
+&compare_output($answer,&get_logfile(1));
+
+1;
diff --git a/tests/scripts/variables/flavors b/tests/scripts/variables/flavors
new file mode 100644
index 0000000..7642636
--- /dev/null
+++ b/tests/scripts/variables/flavors
@@ -0,0 +1,68 @@
+# -*-perl-*-
+
+$description = "Test various flavors of make variable setting.";
+
+$details = "";
+
+open(MAKEFILE, "> $makefile");
+
+# The Contents of the MAKEFILE ...
+
+print MAKEFILE <<'EOF';
+foo = $(bar)
+bar = ${ugh}
+ugh = Hello
+
+all: multi ; @echo $(foo)
+
+multi: ; $(multi)
+
+x := foo
+y := $(x) bar
+x := later
+
+nullstring :=
+space := $(nullstring) $(nullstring)
+
+next: ; @echo $x$(space)$y
+
+define multi
+@echo hi
+@echo there
+endef
+
+ifdef BOGUS
+define
+@echo error
+endef
+endif
+
+EOF
+
+# END of Contents of MAKEFILE
+
+close(MAKEFILE);
+
+# TEST #1
+# -------
+
+&run_make_with_options($makefile, "", &get_logfile);
+$answer = "hi\nthere\nHello\n";
+&compare_output($answer, &get_logfile(1));
+
+# TEST #2
+# -------
+
+&run_make_with_options($makefile, "next", &get_logfile);
+$answer = "later foo bar\n";
+&compare_output($answer, &get_logfile(1));
+
+# TEST #3
+# -------
+
+&run_make_with_options($makefile, "BOGUS=true", &get_logfile, 512);
+$answer = "$makefile:23: *** empty variable name. Stop.\n";
+&compare_output($answer, &get_logfile(1));
+
+
+1;