summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2004-09-22 04:36:17 +0000
committerPaul Smith <psmith@gnu.org>2004-09-22 04:36:17 +0000
commit29d78ddb2842d75956fb9b2f50fa7032f6a28416 (patch)
tree18e57d8b1de21618a9f7071fa9f24879a2fc1e97
parent73e7767ffc14fad98dd2e78791a1237bcb3d6fe3 (diff)
downloadgunmake-29d78ddb2842d75956fb9b2f50fa7032f6a28416.tar.gz
Update the test template. A few fixes in run_make_test().
Rename implicit_prereq_eval to patternrules, to be the start of a suite of tests of pattern rules.
-rw-r--r--tests/ChangeLog11
-rwxr-xr-xtests/run_make_tests.pl4
-rw-r--r--tests/scripts/features/implicit_prereq_eval64
-rw-r--r--tests/scripts/features/patternrules40
-rw-r--r--tests/scripts/test_template69
5 files changed, 66 insertions, 122 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 0a7ed0c..542194e 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,8 +1,17 @@
+2004-09-22 Paul D. Smith <psmith@gnu.org>
+
+ * run_make_tests.pl (run_make_test): Don't add newlines to the
+ makestring or answer if they are completely empty.
+
+ * scripts/features/patternrules: Rename from implicit_prereq_eval.
+
+ * scripts/test_template: Rework the template.
+
2004-09-21 Boris Kolpackov <boris@kolpackov.net>
* run_make_tests.pl: Change `#!/usr/local/bin/perl' to be
`#!/usr/bin/env perl'.
-
+
* scripts/features/implicit_prereq_eval: Test implicit rule
prerequisite evaluation code.
diff --git a/tests/run_make_tests.pl b/tests/run_make_tests.pl
index a4c4330..9b9104f 100755
--- a/tests/run_make_tests.pl
+++ b/tests/run_make_tests.pl
@@ -76,7 +76,7 @@ sub run_make_test
}
# Make sure it ends in a newline.
- $makestring =~ /\n$/s or $makestring .= "\n";
+ $makestring && $makestring !~ /\n$/s and $makestring .= "\n";
# Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to
# make
@@ -91,7 +91,7 @@ sub run_make_test
# Do the same processing on $answer as we did on $makestring.
- $answer =~ /\n$/s or $answer .= "\n";
+ $answer && $answer !~ /\n$/s and $answer .= "\n";
$answer =~ s/#MAKEFILE#/$makefile/g;
$answer =~ s/#MAKE#/$make_name/g;
diff --git a/tests/scripts/features/implicit_prereq_eval b/tests/scripts/features/implicit_prereq_eval
deleted file mode 100644
index f549a79..0000000
--- a/tests/scripts/features/implicit_prereq_eval
+++ /dev/null
@@ -1,64 +0,0 @@
-$description = "Test implicit rule prerequisite evaluation code.";
-
-$details = "The makefile created by this test has a set of implicit rule
- pairs with the first rule usually not applying because its prerequisites
- cannot be made and the second rule which should succeed.";
-
-open(MAKEFILE,"> $makefile");
-
-# The contents of the Makefile ...
-
-print MAKEFILE <<EOF;
-
-.PHONY: all
-
-all: case.1 case.2 case.3
-
-a: void
-
-# 1 - existing file
-#
-%.1: void
- \@false
-
-%.1: $makefile
- \@true
-
-
-# 2 - phony
-#
-%.2: void
- \@false
-
-%.2: 2.phony
- \@true
-
-.PHONY: 2.phony
-
-
-# 3 - implicit-phony
-#
-%.3: void
- \@false
-
-%.3: 3.implicit-phony
- \@true
-
-3.implicit-phony:
-
-EOF
-
-close(MAKEFILE);
-
-&run_make_with_options($makefile,
- "",
- &get_logfile,
- 0);
-
-
-# This makefile doesn't produce anything except exit code.
-#
-&compare_output("",&get_logfile(1));
-
-# This tells the test driver that the perl test script executed properly.
-1;
diff --git a/tests/scripts/features/patternrules b/tests/scripts/features/patternrules
new file mode 100644
index 0000000..926695a
--- /dev/null
+++ b/tests/scripts/features/patternrules
@@ -0,0 +1,40 @@
+# -*-perl-*-
+
+$description = "Test pattern rules.";
+
+$details = "";
+
+# Make sure that multiple patterns where the same target can be built are
+# searched even if the first one fails to match properly.
+
+run_make_test('
+.PHONY: all
+
+all: case.1 case.2 case.3
+a: void
+
+# 1 - existing file
+%.1: void
+ @false
+%.1: #MAKEFILE#
+ @true
+
+# 2 - phony
+%.2: void
+ @false
+%.2: 2.phony
+ @true
+.PHONY: 2.phony
+
+# 3 - implicit-phony
+%.3: void
+ @false
+%.3: 3.implicit-phony
+ @true
+
+3.implicit-phony:
+', '', '');
+
+
+# This tells the test driver that the perl test script executed properly.
+1;
diff --git a/tests/scripts/test_template b/tests/scripts/test_template
index 773ced3..3fd3f95 100644
--- a/tests/scripts/test_template
+++ b/tests/scripts/test_template
@@ -1,64 +1,23 @@
-$description = "The following test creates a makefile to ...
- <FILL IN DESCRIPTION HERE> ";
+# -*-perl-*-
+$description = "<FILL IN SHORT DESCRIPTION HERE>";
$details = "<FILL IN DETAILS OF HOW YOU TEST WHAT YOU SAY YOU ARE TESTING>";
-# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
-# THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF
-# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
-# EXAMPLE: $makefile2 = &get_tmpfile;
+# Run a make test. See the documentation of run_make_test() in
+# run_make_tests.pl, but briefly the first argument is a string with the
+# contents of a makefile to be tested, the second is a string containing the
+# arguments to be passed to the make invocation, the third is a string
+# containing the expected output. The fourth is the expected exit code for
+# make. If not specified, it's assumed that the make program should succeed
+# (exit with 0).
-open(MAKEFILE,"> $makefile");
+run_make_test('Your test makefile goes here',
+ 'Arguments to pass to make go here',
+ 'Expected output from the invocation goes here');
-# The Contents of the MAKEFILE ...
+# There are various special tokens, options, etc. See the full documentation
+# in run_make_tests.pl.
-print MAKEFILE " <FILL IN THE CONTENTS OF THE MAKEFILE HERE> \n";
-
-# END of Contents of MAKEFILE
-
-close(MAKEFILE);
-
-
-# Run make. You may specify a makefile, but if you don't want to, just
-# insert "" where $make_filename is now. You may also specify specific
-# options to run make with, but you also don't have to. (Insert "" where it
-# says <FILL IN OPTIONS HERE>), The last field in this subroutine call
-# is the code which is returned from make. If you think that make should
-# execute with no errors, you may OPTIONALLY put 0; Otherwise put the
-# error code that you expect back from make for this test.
-
-# Every time you run make, you just need to say &get_logfile and that
-# subroutine will get a new logfile name for you in incrementing order
-# according to how many times you call it within ONE test. It is
-# reset to 0 at the beginning of every new test script.
-
-&run_make_with_options($makefile,
- "<FILL IN OPTIONS HERE>",
- &get_logfile,
- 0);
-
-
-# THE REST OF THIS FILE DEPENDS HIGHLY ON WHAT KIND OF TEST YOU ARE
-# CREATING, SO IT WILL VARY. BASICALLY, YOU MAY INSERT ANYTHING YOU
-# WISH AT THIS POINT TO SEE IF THE TEST WORKED OK. IF THERE ARE
-# ADDITIONAL TESTS BESIDES &compare_output, AND IT FAILES, YOU
-# MUST *** SET $test_passed = 0 !!! ***
-
-# Create the answer to what should be produced by this Makefile
-$answer = "<INSERT ANSWER HERE>";
-
-# 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. You may also use
-# the special call &get_logfile(1) which returns the same as &get_logfile(1).
-
-&compare_output($answer,&get_logfile(1));
-
-# If you wish to &error ("abort
-") 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;