summaryrefslogtreecommitdiff
path: root/tests/run_make_tests.pl
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2004-09-21 05:39:04 +0000
committerPaul Smith <psmith@gnu.org>2004-09-21 05:39:04 +0000
commit9714e501fb356adb043c77a3180a7f8c16c1484d (patch)
tree39676649d3912502fc3f4231ffafafa18b289ad8 /tests/run_make_tests.pl
parent0799ce730d2404d1cd1d03ce2f4ac07cc079c72e (diff)
downloadgunmake-9714e501fb356adb043c77a3180a7f8c16c1484d.tar.gz
Add some more unit tests for variable flavors.
Allow run_make_tests() to be invoked with an undef makefile string, in which case it re-uses the previous string.
Diffstat (limited to 'tests/run_make_tests.pl')
-rwxr-xr-xtests/run_make_tests.pl47
1 files changed, 29 insertions, 18 deletions
diff --git a/tests/run_make_tests.pl b/tests/run_make_tests.pl
index 991e780..5d49014 100755
--- a/tests/run_make_tests.pl
+++ b/tests/run_make_tests.pl
@@ -51,43 +51,54 @@ sub valid_option
# This is an "all-in-one" function. Arguments are as follows:
#
-# [0] (string): The makefile to be tested.
+# [0] (string): The makefile to be tested. undef means use the last one.
# [1] (string): Arguments to pass to make.
# [2] (string): Answer we should get back.
# [3] (integer): Exit code we expect. A missing code means 0 (success)
+$old_makefile = undef;
+
sub run_make_test
{
local ($makestring, $options, $answer, $err_code) = @_;
- if (! defined($makefile)) {
- $makefile = &get_tmpfile();
- }
+ # If the user specified a makefile string, create a new makefile to contain
+ # it. If the first value is not defined, use the last one (if there is
+ # one).
+
+ if (! defined $makestring) {
+ defined $old_makefile
+ || die "run_make_test(undef) invoked before run_make_test('...')\n";
+ $makefile = $old_makefile;
+ } else {
+ if (! defined($makefile)) {
+ $makefile = &get_tmpfile();
+ }
- # If either the makestring or the answer don't end in newlines, add one In
- # the future should we allow an option to disable this? For now if you
- # want to test handling with no newline you have to call the underlying
- # functions directly.
+ # Make sure it ends in a newline.
+ $makestring =~ /\n$/s or $makestring .= "\n";
- $makestring =~ /\n$/s or $makestring .= "\n";
- $answer =~ /\n$/s or $answer .= "\n";
+ # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to
+ # make
+ $makestring =~ s/#MAKEFILE#/$makefile/g;
+ $makestring =~ s/#MAKE#/$make_name/g;
- # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to
- # make in both $makestring and $answer.
+ # Populate the makefile!
+ open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n";
+ print MAKEFILE $makestring;
+ close(MAKEFILE) || die "Failed to write $makefile: $!\n";
+ }
- $makestring =~ s/#MAKEFILE#/$makefile/g;
- $makestring =~ s/#MAKE#/$make_name/g;
+ # Do the same processing on $answer as we did on $makestring.
+ $answer =~ /\n$/s or $answer .= "\n";
$answer =~ s/#MAKEFILE#/$makefile/g;
$answer =~ s/#MAKE#/$make_name/g;
- open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n";
- print MAKEFILE $makestring, "\n";
- close(MAKEFILE) || die "Failed to write $makefile: $!\n";
-
&run_make_with_options($makefile, $options, &get_logfile(0), $err_code);
&compare_output($answer, &get_logfile(1));
+ $old_makefile = $makefile;
$makefile = undef;
}