From 0d366b668244112846554c42045ff1d9956276ed Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Tue, 14 Sep 1999 02:03:19 +0000 Subject: * Added the test suite to the main distribution. --- tests/scripts/variables/CURDIR | 18 ++++++++++ tests/scripts/variables/MAKE | 33 +++++++++++++++++ tests/scripts/variables/MAKECMDGOALS | 50 ++++++++++++++++++++++++++ tests/scripts/variables/MAKEFILES | 37 ++++++++++++++++++++ tests/scripts/variables/MAKELEVEL | 34 ++++++++++++++++++ tests/scripts/variables/flavors | 68 ++++++++++++++++++++++++++++++++++++ 6 files changed, 240 insertions(+) create mode 100644 tests/scripts/variables/CURDIR create mode 100644 tests/scripts/variables/MAKE create mode 100644 tests/scripts/variables/MAKECMDGOALS create mode 100644 tests/scripts/variables/MAKEFILES create mode 100644 tests/scripts/variables/MAKELEVEL create mode 100644 tests/scripts/variables/flavors (limited to 'tests/scripts/variables') 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 < $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; -- cgit v1.2.3