Changeset 3140 for trunk/src/kmk/tests


Ignore:
Timestamp:
Mar 14, 2018, 10:28:10 PM (7 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

Location:
trunk/src/kmk
Files:
1 deleted
61 edited
23 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

  • trunk/src/kmk/tests/NEWS

    r2591 r3140  
    7373    Also, some tests and stuff still haven't made it in because I
    7474    haven't had time to write the test scripts for them.  But they,
    75     too, will get in eventually.  Contributions of scripts (ie, tests
     75    too, will get in eventually.  Contributions of scripts (i.e., tests
    7676    that I can just drop in) are particularly welcome and will be
    7777    incorporated immediately.
     
    164164
    165165-------------------------------------------------------------------------------
    166 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    167 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
     166Copyright (C) 1992-2016 Free Software Foundation, Inc.
    168167This file is part of GNU Make.
    169168
  • trunk/src/kmk/tests/README

    r2591 r3140  
    88
    99 -----------------------------------------------------------------------------
    10  Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    11  2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
     10 Copyright (C) 1992-2016 Free Software Foundation, Inc.
    1211 This file is part of GNU Make.
    1312
     
    4039
    4140By default, the test engine picks up the first executable called "make"
    42 that it finds in your path.  You may use the -make_path option (ie,
     41that it finds in your path.  You may use the -make_path option (i.e.,
    4342"perl run_make_tests -make_path /usr/local/src/make-3.78/make") if
    4443you want to run a particular copy.  This now works correctly with
     
    6059make to be setgid sys or kmem for this; if you don't want to install
    6160make just to test it, make it setgid to kmem or whatever group /dev/kmem
    62 is (ie, "chgrp kmem make;chmod g+s make" as root).  In any case, the
     61is (i.e., "chgrp kmem make;chmod g+s make" as root).  In any case, the
    6362options/dash-l test should no longer *fail* because make can't read
    6463/dev/kmem.
  • trunk/src/kmk/tests/mkshadow

    r2591 r3140  
    44# Typically you'd put the shadow in /tmp or another local disk
    55#
    6 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    7 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    8 # Foundation, Inc.
     6# Copyright (C) 1992-2016 Free Software Foundation, Inc.
    97# This file is part of GNU Make.
    108#
     
    2927
    3028if [ ! -d "$dest" ]; then
    31   echo "Destination directory \`$dest' must exist!"
     29  echo "Destination directory '$dest' must exist!"
    3230  exit 1
    3331fi
     
    5654rm -rf work
    5755
    58 echo "Shadow test suite created in \`$dest/$name'."
     56echo "Shadow test suite created in '$dest/$name'."
    5957exit 0
  • trunk/src/kmk/tests/run_make_tests.pl

    r2591 r3140  
    1212#                        (and others)
    1313
    14 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    15 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    16 # Foundation, Inc.
     14# Copyright (C) 1992-2016 Free Software Foundation, Inc.
    1715# This file is part of GNU Make.
    1816#
     
    3028# this program.  If not, see <http://www.gnu.org/licenses/>.
    3129
     30%FEATURES = ();
    3231
    3332$valgrind = 0;              # invoke make with valgrind
    3433$valgrind_args = '';
    35 $memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full';
     34$memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full --suppressions=guile.supp';
    3635$massif_args = '--num-callers=15 --tool=massif --alloc-fn=xmalloc --alloc-fn=xcalloc --alloc-fn=xrealloc --alloc-fn=xstrdup --alloc-fn=xstrndup';
    3736$pure_log = undef;
    3837
     38# The location of the GNU make source directory
     39$srcdir = '';
     40
    3941$command_string = '';
    4042
    4143$all_tests = 0;
    4244
     45# rmdir broken in some Perls on VMS.
     46if ($^O eq 'VMS')
     47{
     48  require VMS::Filespec;
     49  VMS::Filespec->import();
     50
     51  sub vms_rmdir {
     52    my $vms_file = vmspath($_[0]);
     53    $vms_file = fileify($vms_file);
     54    my $ret = unlink(vmsify($vms_file));
     55    return $ret
     56  };
     57
     58  *CORE::GLOBAL::rmdir = \&vms_rmdir;
     59}
     60
    4361require "test_driver.pl";
     62require "config-flags.pm";
    4463
    4564# Some target systems might not have the POSIX module...
     
    6180   }
    6281
     82   if ($option =~ /^-srcdir$/i) {
     83       $srcdir = shift @argv;
     84       if (! -f "$srcdir/gnumake.h") {
     85           print "$option $srcdir: Not a valid GNU make source directory.\n";
     86           exit 0;
     87       }
     88       return 1;
     89   }
     90
    6391   if ($option =~ /^-all([-_]?tests)?$/i) {
    6492       $all_tests = 1;
     
    99127$old_makefile = undef;
    100128
     129sub subst_make_string
     130{
     131    local $_ = shift;
     132    $makefile and s/#MAKEFILE#/$makefile/g;
     133    s/#MAKEPATH#/$mkpath/g;
     134    s/#MAKE#/$make_name/g;
     135    s/#PERL#/$perl_name/g;
     136    s/#PWD#/$pwd/g;
     137    return $_;
     138}
     139
    101140sub run_make_test
    102141{
    103142  local ($makestring, $options, $answer, $err_code, $timeout) = @_;
     143  my @call = caller;
    104144
    105145  # If the user specified a makefile string, create a new makefile to contain
     
    116156    }
    117157
    118     # Make sure it ends in a newline.
     158    # Make sure it ends in a newline and substitute any special tokens.
    119159    $makestring && $makestring !~ /\n$/s and $makestring .= "\n";
    120 
    121     # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to
    122     # make
    123     $makestring =~ s/#MAKEFILE#/$makefile/g;
    124     $makestring =~ s/#MAKEPATH#/$mkpath/g;
    125     $makestring =~ s/#MAKE#/$make_name/g;
    126     $makestring =~ s/#PERL#/$perl_name/g;
    127     $makestring =~ s/#PWD#/$pwd/g;
     160    $makestring = subst_make_string($makestring);
    128161
    129162    # Populate the makefile!
     
    134167
    135168  # Do the same processing on $answer as we did on $makestring.
    136 
    137   $answer && $answer !~ /\n$/s and $answer .= "\n";
    138   $answer =~ s/#MAKEFILE#/$makefile/g;
    139   $answer =~ s/#MAKEPATH#/$mkpath/g;
    140   $answer =~ s/#MAKE#/$make_name/g;
    141   $answer =~ s/#PERL#/$perl_name/g;
    142   $answer =~ s/#PWD#/$pwd/g;
     169  if (defined $answer) {
     170      $answer && $answer !~ /\n$/s and $answer .= "\n";
     171      $answer = subst_make_string($answer);
     172  }
    143173
    144174  run_make_with_options($makefile, $options, &get_logfile(0),
    145                         $err_code, $timeout);
     175                        $err_code, $timeout, @call);
    146176  &compare_output($answer, &get_logfile(1));
    147177
     
    152182# The old-fashioned way...
    153183sub run_make_with_options {
    154   local ($filename,$options,$logname,$expected_code,$timeout) = @_;
     184  my ($filename,$options,$logname,$expected_code,$timeout,@call) = @_;
     185  @call = caller unless @call;
    155186  local($code);
    156187  local($command) = $make_path;
     
    166197
    167198  if ($options) {
     199    if ($^O eq 'VMS') {
     200      # Try to make sure arguments are properly quoted.
     201      # This does not handle all cases.
     202
     203      # VMS uses double quotes instead of single quotes.
     204      $options =~ s/\'/\"/g;
     205
     206      # If the leading quote is inside non-whitespace, then the
     207      # quote must be doubled, because it will be enclosed in another
     208      # set of quotes.
     209      $options =~ s/(\S)(\".*\")/$1\"$2\"/g;
     210
     211      # Options must be quoted to preserve case if not already quoted.
     212      $options =~ s/(\S+)/\"$1\"/g;
     213
     214      # Special fixup for embedded quotes.
     215      $options =~ s/(\"\".+)\"(\s+)\"(.+\"\")/$1$2$3/g;
     216
     217      $options =~ s/(\A)(?:\"\")(.+)(?:\"\")/$1\"$2\"/g;
     218
     219      # Special fixup for misc/general4 test.
     220      $options =~ s/""\@echo" "cc""/\@echo cc"/;
     221      $options =~ s/"\@echo link"""/\@echo link"/;
     222
     223      # Remove shell escapes expected to be removed by bash
     224      if ($options !~ /path=pre/) {
     225        $options =~ s/\\//g;
     226      }
     227
     228      # special fixup for options/eval
     229      $options =~ s/"--eval=\$\(info" "eval/"--eval=\$\(info eval/;
     230
     231      print ("Options fixup = -$options-\n") if $debug;
     232    }
    168233    $command .= " $options";
    169234  }
    170235
    171   $command_string = "$command\n";
     236  $command_string = "";
     237  if (@call) {
     238      $command_string = "#$call[1]:$call[2]\n";
     239  }
     240  $command_string .= "$command\n";
    172241
    173242  if ($valgrind) {
     
    184253
    185254      $code = &run_command_with_output($logname,$command);
    186 
    187255      $test_timeout = $old_timeout;
    188256  }
     
    229297{
    230298   &print_standard_usage ("run_make_tests",
    231                           "[-make_path make_pathname] [-memcheck] [-massif]",);
     299                          "[-make MAKE_PATHNAME] [-srcdir SRCDIR] [-memcheck] [-massif]",);
    232300}
    233301
     
    235303{
    236304   &print_standard_help (
    237         "-make_path",
     305        "-make",
    238306        "\tYou may specify the pathname of the copy of make to run.",
     307        "-srcdir",
     308        "\tSpecify the make source directory.",
    239309        "-valgrind",
    240310        "-memcheck",
     
    296366     $port_type = 'OS/2';
    297367   }
     368
     369   # VMS has a GNV Unix mode or a DCL mode.
     370   # The SHELL environment variable should not be defined in VMS-DCL mode.
     371   elsif ($osname eq 'VMS' && !defined $ENV{"SHELL"}) {
     372     $port_type = 'VMS-DCL';
     373   }
    298374   # Everything else, right now, is UNIX.  Note that we should integrate
    299375   # the VOS support into this as well and get rid of $vos; we'll do
     
    314390   # Find the full pathname of Make.  For DOS systems this is more
    315391   # complicated, so we ask make itself.
    316    my $mk = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
    317    chop $mk;
    318    $mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE):\n
     392   if ($osname eq 'VMS') {
     393     $port_type = 'VMS-DCL' unless defined $ENV{"SHELL"};
     394     # On VMS pre-setup make to be found with simply 'make'.
     395     $make_path = 'make';
     396   } else {
     397     my $mk = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
     398     chop $mk;
     399     $mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE):\n
    319400'echo \"all:;\@echo \\\$(MAKE)\" | $make_path -f-' failed!\n";
    320    $make_path = $mk;
    321    print "Make\t= `$make_path'\n" if $debug;
    322 
    323    $string = `$make_path -v -f /dev/null 2> /dev/null`;
     401     $make_path = $mk;
     402   }
     403   print "Make\t= '$make_path'\n" if $debug;
     404
     405   my $redir2 = '2> /dev/null';
     406   $redir2 = '' if os_name eq 'VMS';
     407   $string = `$make_path -v -f /dev/null $redir2`;
    324408
    325409   $string =~ /^(GNU Make [^,\n]*)/;
    326410   $testee_version = "$1\n";
    327411
    328    $string = `sh -c "$make_path -f /dev/null 2>&1"`;
     412   my $redir = '2>&1';
     413   $redir = '' if os_name eq 'VMS';
     414   $string = `sh -c "$make_path -f /dev/null $redir"`;
    329415   if ($string =~ /(.*): \*\*\* No targets\.  Stop\./) {
    330416     $make_name = $1;
    331417   }
    332418   else {
    333      if ($make_path =~ /$pathsep([^\n$pathsep]*)$/) {
    334        $make_name = $1;
    335      }
    336      else {
    337        $make_name = $make_path;
    338      }
     419     $make_path =~ /^(?:.*$pathsep)?(.+)$/;
     420     $make_name = $1;
    339421   }
    340422
     
    350432   {
    351433      $mkpath = $make_path;
     434   }
     435
     436   # If srcdir wasn't provided on the command line, see if the
     437   # location of the make program gives us a clue.  Don't fail if not;
     438   # we'll assume it's been installed into /usr/include or wherever.
     439   if (! $srcdir) {
     440       $make_path =~ /^(.*$pathsep)?/;
     441       my $d = $1 || '../';
     442       -f "${d}gnumake.h" and $srcdir = $d;
     443   }
     444
     445   # Not with the make program, so see if we can get it out of the makefile
     446   if (! $srcdir && open(MF, "< ../Makefile")) {
     447       local $/ = undef;
     448       $_ = <MF>;
     449       close(MF);
     450       /^abs_srcdir\s*=\s*(.*?)\s*$/m;
     451       -f "$1/gnumake.h" and $srcdir = $1;
    352452   }
    353453
     
    361461   }
    362462
    363    $string = `sh -c "$make_path -j 2 -f /dev/null 2>&1"`;
     463   $string = `sh -c "$make_path -j 2 -f /dev/null $redir"`;
    364464   if ($string =~ /not supported/) {
    365465     $parallel_jobs = 0;
     
    369469   }
    370470
     471   %FEATURES = map { $_ => 1 } split /\s+/, `sh -c "echo '\\\$(info \\\$(.FEATURES))' | $make_path -f- 2>/dev/null"`;
     472
    371473   # Set up for valgrind, if requested.
     474
     475   $make_command = $make_path;
    372476
    373477   if ($valgrind) {
  • trunk/src/kmk/tests/scripts/features/conditionals

    r969 r3140  
    142142              'success');
    143143
     144# SV 47960 : ensure variable assignments in non-taken legs don't cause problems
     145run_make_test('
     146ifneq ($(FOO),yes)
     147target:
     148else
     149BAR = bar
     150target:
     151endif
     152        @echo one
     153',
     154              '', "one\n");
     155
    144156
    145157# This tells the test driver that the perl test script executed properly.
    1461581;
     159
     160### Local Variables:
     161### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     162### End:
  • trunk/src/kmk/tests/scripts/features/default_names

    r1937 r3140  
    1111close(MAKEFILE);
    1212
    13 # DOS/WIN32 platforms preserve case, but Makefile is the same file as makefile.
    14 # Just test what we can here (avoid Makefile versus makefile test).
    15 # bird: made this generic, darwin is also defaulting to case insensitive fs.
     13# Create another makefile called "makefile"
     14open(MAKEFILE,"> makefile");
     15print MAKEFILE "SECOND: ; \@echo It chose makefile\n";
     16close(MAKEFILE);
    1617
    17 if ($port_type eq 'UNIX' && !$case_insensitive_fs) {
    18   # Create another makefile called "makefile"
    19   open(MAKEFILE,"> makefile");
    20   print MAKEFILE "SECOND: ; \@echo It chose makefile\n";
    21   close(MAKEFILE);
     18# DOS/WIN32/MacOSX platforms are case-insensitive / case-preserving, so
     19# Makefile is the same file as makefile.  Just test what we can here.
     20
     21my $case_sensitive = 0;
     22if (! -f 'Makefile') {
     23    # Create another makefile called "Makefile"
     24    $case_sensitive = 1;
     25    open(MAKEFILE,"> Makefile");
     26    print MAKEFILE "THIRD: ; \@echo It chose Makefile\n";
     27    close(MAKEFILE);
    2228}
    2329
    24 # Create another makefile called "Makefile"
    25 open(MAKEFILE,"> Makefile");
    26 print MAKEFILE "THIRD: ; \@echo It chose Makefile\n";
    27 close(MAKEFILE);
     30run_make_with_options("","",&get_logfile);
     31compare_output("It chose GNUmakefile\n",&get_logfile(1));
     32unlink($makefile);
    2833
     34run_make_with_options("","",&get_logfile);
     35compare_output("It chose makefile\n",&get_logfile(1));
     36unlink("makefile");
    2937
    30 &run_make_with_options("","",&get_logfile);
    31 &compare_output("It chose GNUmakefile\n",&get_logfile(1));
    32 unlink $makefile;
    33 
    34 if ($port_type eq 'UNIX' && !$case_insensitive_fs) {
    35   &run_make_with_options("","",&get_logfile);
    36   &compare_output("It chose makefile\n",&get_logfile(1));
    37   unlink "makefile";
     38if ($case_sensitive) {
     39    run_make_with_options("","",&get_logfile);
     40    compare_output("It chose Makefile\n",&get_logfile(1));
     41    unlink("Makefile");
    3842}
    3943
    40 &run_make_with_options("","",&get_logfile);
    41 &compare_output("It chose Makefile\n",&get_logfile(1));
    42 unlink "Makefile";
     441;
  • trunk/src/kmk/tests/scripts/features/double_colon

    r969 r3140  
    152152unlink('result','one','two');
    153153
     154# TEST 10: SV 33399 : check for proper backslash handling
     155
     156run_make_test('
     157a\ xb :: ; @echo one
     158a\ xb :: ; @echo two
     159',
     160              '', "one\ntwo\n");
     161
     162# Test 11: SV 44742 : All double-colon rules should be run in parallel build.
     163
     164run_make_test('result :: 01
     165        @echo update
     166        @touch $@
     167result :: 02
     168        @echo update
     169        @touch $@
     170result :: 03
     171        @echo update
     172        @touch $@
     173result :: 04
     174        @echo update
     175        @touch $@
     176result :: 05
     177        @echo update
     178        @touch $@
     17901 02 03 04 05:
     180        @touch 01 02 03 04 05
     181',
     182              '-j10 result', "update\nupdate\nupdate\nupdate\nupdate\n");
     183
     184unlink('result', '01', '02', '03', '04', '05');
     185
     186# Test 12: SV 44742 : Double-colon rules with parallelism
     187
     188run_make_test('
     189root: all
     190        echo root
     191all::
     192        echo all_one
     193all:: 3
     194        echo all_two
     195%:
     196        sleep $*
     197',
     198              '-rs -j2 1 2 root', "all_one\nall_two\nroot\n");
     199
     200# SV 47995 : Parallel double-colon rules with FORCE
     201
     202run_make_test('
     203all:: ; @echo one
     204
     205all:: joe ; @echo four
     206
     207joe: FORCE ; touch joe-is-forced
     208
     209FORCE:
     210',
     211              '-j5', "one\ntouch joe-is-forced\nfour\n");
     212
     213unlink('joe-is-forced');
     214
    154215# This tells the test driver that the perl test script executed properly.
    1552161;
     217
     218### Local Variables:
     219### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     220### End:
  • trunk/src/kmk/tests/scripts/features/errors

    r969 r3140  
    3131              ."\t-$rm_command cleanit\n"
    3232              ."\t$rm_command foo\n"
    33               ."clean2: \n"
     33              ."clean2: \n"
    3434              ."\t$rm_command cleanit\n"
    3535              ."\t$rm_command foo\n";
     
    4343unlink("cleanit");
    4444$cleanit_error = `sh -c "$rm_command cleanit 2>&1"`;
     45chomp $cleanit_error;
    4546$delete_error_code = $? >> 8;
    4647
     
    4849# -------
    4950
    50 $answer = "$rm_command cleanit\n"
    51          . $cleanit_error
    52          ."$make_name: [clean] Error $delete_error_code (ignored)\n"
    53          ."$rm_command foo\n";
     51$answer = "$rm_command cleanit
     52$cleanit_error
     53$make_name: [$makefile:2: clean] Error $delete_error_code (ignored)
     54$rm_command foo\n";
    5455
    5556&run_make_with_options($makefile,"",&get_logfile);
     
    7576# -------
    7677
    77 $answer = "$rm_command cleanit\n"
    78          . $cleanit_error
    79          ."$make_name: [clean2] Error $delete_error_code (ignored)\n"
    80          ."$rm_command foo\n";
     78$answer = "$rm_command cleanit
     79$cleanit_error
     80$make_name: [$makefile:5: clean2] Error $delete_error_code (ignored)
     81$rm_command foo\n";
    8182
    8283&run_make_with_options($makefile,"clean2 -i",&get_logfile);
     
    9091}
    9192
     93# Test that error line offset works
     94
     95run_make_test(q!
     96all:
     97        @echo hi
     98        @echo there
     99        @exit 1
     100!,
     101              '', "hi\nthere\n#MAKE#: *** [#MAKEFILE#:5: all] Error 1", 512);
     102
    921031;
     104
     105### Local Variables:
     106### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     107### End:
  • trunk/src/kmk/tests/scripts/features/escape

    r1938 r3140  
    33
    44$details = "\
    5 Make sure that escaping of `:' works in target names.
     5Make sure that escaping of ':' works in target names.
    66Make sure escaping of whitespace works in target names.
    7 Make sure that escaping of '#' works.";
    8 
    9 
    10 close(MAKEFILE);
     7Make sure that escaping of '#' works.
     8Make sure that backslash before non-special characters are kept.";
    119
    1210
     
    2725run_make_test(undef,
    2826              'path=pre:',
    29               "#MAKEFILE#:2: *** target pattern contains no `%' (target `foo').  Stop.",
     27              "#MAKEFILE#:2: *** target pattern contains no '%' (target 'foo').  Stop.",
    3028              512);
    3129
     
    4038run_make_test(undef,
    4139              "'path=pre\\\\:'",
    42               "#MAKEFILE#:2: *** target pattern contains no `%' (target `foo').  Stop.",
     40              "#MAKEFILE#:2: *** target pattern contains no '%'  (target 'foo').  Stop.",
    4341              512);
    4442
     
    5553              'foo#bar.ext = (foo#bar.ext)');
    5654
     55# Test escaped colons in prerequisites
     56# Quoting of backslashes in q!! is kind of messy.
     57# Solaris sh does not properly handle backslashes even in '' so just
     58# check the output make prints, not what the shell interprets.
     59run_make_test(q!
     60foo: foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar
     61foo foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar: ; : '$@'
     62!,
     63              '', ": 'foo:bar'\n: 'foo\\:bar'\n: 'foo\\\\:bar'\n: 'foo'\n");
     64
     65# Test backslash before non-special chars: should be kept as-is
     66
     67run_make_test(q!
     68all: ..\foo
     69.DEFAULT: ; : '$@'
     70!,
     71              '', ": '..\\foo'\n");
     72
    5773# This tells the test driver that the perl test script executed properly.
    58741;
  • trunk/src/kmk/tests/scripts/features/include

    r2591 r3140  
    11#                                     -*-mode: perl; rm-trailing-spaces: nil-*-
    22
    3 $description = "Test various forms of the GNU make `include' command.";
     3$description = "Test various forms of the GNU make 'include' command.";
    44
    55$details = "\
     
    6161',
    6262   '',
    63    "#MAKE#: *** No rule to make target `foo.mk', needed by `error'.  Stop.\n",
     63   "#MAKE#: *** No rule to make target 'foo.mk', needed by 'error'.  Stop.\n",
    6464   512
    6565  );
     
    129129',
    130130'',
    131 "#MAKE#: *** No rule to make target `baz', needed by `bar'.  Stop.\n",
     131"#MAKE#: *** No rule to make target 'baz', needed by 'bar'.  Stop.\n",
    132132512);
    133133
     
    145145',
    146146'',
    147 "#MAKE#: *** No rule to make target `end', needed by `baz'.  Stop.\n",
     147"#MAKE#: *** No rule to make target 'end', needed by 'baz'.  Stop.\n",
    148148512);
    149149
     
    163163'',
    164164"#MAKEFILE#:2: bar: No such file or directory
    165 #MAKE#: *** No rule to make target `end', needed by `baz'.  Stop.\n",
     165#MAKE#: *** No rule to make target 'end', needed by 'baz'.  Stop.\n",
    166166512);
     167
     168# Test include of make-able file doesn't show an error (Savannah #102)
     169run_make_test(q!
     170.PHONY: default
     171default:; @echo DONE
     172
     173inc1:; echo > $@
     174include inc1
     175include inc2
     176inc2:; echo > $@
     177!,
     178              '', "echo > inc2\necho > inc1\nDONE\n");
     179
     180rmfiles('inc1', 'inc2');
     181
     182# Test include of non-make-able file does show an error (Savannah #102)
     183run_make_test(q!
     184.PHONY: default
     185default:; @echo DONE
     186
     187inc1:; echo > $@
     188include inc1
     189include inc2
     190!,
     191              '', "#MAKEFILE#:7: inc2: No such file or directory\n#MAKE#: *** No rule to make target 'inc2'.  Stop.\n", 512);
     192
     193rmfiles('inc1');
     194
     195# Include same file multiple times
     196
     197run_make_test(q!
     198default:; @echo DEFAULT
     199include inc1
     200inc1:; echo > $@
     201include inc1
     202!,
     203              '', "echo > inc1\nDEFAULT\n");
     204
     205rmfiles('inc1');
     206
     207# Included file has a prerequisite that fails to build
     208
     209run_make_test(q!
     210default:; @echo DEFAULT
     211include inc1
     212inc1: foo; echo > $@
     213foo:; exit 1
     214!,
     215              '', "exit 1\n#MAKEFILE#:3: inc1: No such file or directory\n#MAKE#: *** [#MAKEFILE#:5: foo] Error 1\n", 512);
     216
     217rmfiles('inc1');
     218
     219# Included file has a prerequisite we don't know how to build
     220
     221run_make_test(q!
     222default:; @echo DEFAULT
     223include inc1
     224inc1: foo; echo > $@
     225!,
     226              '', "#MAKEFILE#:3: inc1: No such file or directory\n#MAKE#: *** No rule to make target 'foo', needed by 'inc1'.  Stop.\n", 512);
     227
     228rmfiles('inc1');
     229
     230# include a directory
    167231
    168232if ($all_tests) {
     
    173237foo: ; @echo foo = bar > $@
    174238!,
    175                   '', "#MAKE#: `foo' is up to date.\n");
     239                  '', "#MAKE#: 'foo' is up to date.\n");
    176240    rmfiles('foo');
    177241}
  • trunk/src/kmk/tests/scripts/features/mult_rules

    r969 r3140  
    4848
    4949# Create the answer to what should be produced by this Makefile
    50 $answer = "$make_name: *** No rule to make target `extra.h', needed by `foo.o'.  Stop.\n";
     50$answer = "$make_name: *** No rule to make target 'extra.h', needed by 'foo.o'.  Stop.\n";
    5151
    5252&compare_output($answer,&get_logfile(1));
  • trunk/src/kmk/tests/scripts/features/parallelism

    r2591 r3140  
    42422.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@",
    4343              "-j4",
    44               "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n");
     44              "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n", 0, 7);
    4545
    4646rmfiles(qw(1.inc 2.inc));
     
    61612.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@",
    6262              "-j4",
    63               "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n");
     63              "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n", 0, 7);
    6464
    6565rmfiles(qw(1.inc 2.inc));
     
    9292
    9393fail.1 fail.2 fail.3:
    94         \@sleep \$(patsubst fail.%,%,\$\@)
     94        \@$sleep_command \$(patsubst fail.%,%,\$\@)
    9595        \@echo Fail
    9696        \@exit 1
    9797
    9898ok:
    99         \@sleep 4
     99        \@$sleep_command 4
    100100        \@echo Ok done",
    101               '-rR -j5', (!$is_kmk) ? 'Fail
    102 #MAKE#: *** [fail.1] Error 1
     101              '-rR -j5', (!$is_kmk) ? "Fail
     102#MAKE#: *** [#MAKEFILE#:8: fail.1] Error 1
    103103#MAKE#: *** Waiting for unfinished jobs....
    104104Fail
    105 #MAKE#: *** [fail.2] Error 1
    106 Fail
    107 #MAKE#: *** [fail.3] Error 1
    108 Ok done' : 'Fail
     105#MAKE#: *** [#MAKEFILE#:8: fail.2] Error 1
     106Fail
     107#MAKE#: *** [#MAKEFILE#:8: fail.3] Error 1
     108Ok done" : 'Fail
    109109#MAKE#: *** [fail.1] Error 1
    110110The failing command:
     
    155155rmfiles('target');
    156156
    157 # TEST #10: Don't put --jobserver-fds into a re-exec'd MAKEFLAGS.
    158 # We can't test this directly because there's no way a makefile can
    159 # show the value of MAKEFLAGS we were re-exec'd with.  We can intuit it
    160 # by looking for "disabling jobserver mode" warnings; we should only
    161 # get one from the original invocation and none from the re-exec.
    162 # See Savannah bug #18124
     157# TEST #11: Make sure -jN from MAKEFLAGS is processed even when we re-exec
     158# See Savannah bug #33873
     159
     160$extraENV{MAKEFLAGS} = '-j4';
    163161
    164162run_make_test(q!
     163things = thing1 thing2
     164all: $(things)
     165thing1:; @sleep 1; echo '$@ start'; sleep 2; echo '$@ end'
     166thing2:; @echo '$@ start'; sleep 2; echo '$@ end'
    165167-include inc.mk
    166 recur:
    167 #       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
    168         @rm -f inc.mk
    169         @$(MAKE) -j2 -f #MAKEFILE# all
    170 all:
    171 #       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
    172         @echo $@
    173 inc.mk:
    174 #       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
    175         @echo 'FOO = bar' > $@
     168inc.mk: ; @touch $@
    176169!,
    177               '--no-print-directory -j2', "#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.\nall\n");
    178 
     170              '', "thing2 start\nthing1 start\nthing2 end\nthing1 end\n");
     171
     172delete $extraENV{MAKEFLAGS};
    179173rmfiles('inc.mk');
    180174
    181 if ($all_tests) {
    182     # Implicit files aren't properly recreated during parallel builds
    183     # Savannah bug #26864
    184 
    185     # The first run works fine
    186     run_make_test(q!
    187 %.bar: %.x foo.y ; cat $^ > $@
    188 %.x: ; touch $@
    189 foo.y: foo.y.in ; cp $< $@
    190 foo.y.in: ; touch $@
     175# Ensure intermediate/secondary files are not pruned incorrectly.
     176# See Savannah bug #30653
     177
     178utouch(-15, 'file2');
     179utouch(-10, 'file4');
     180utouch(-5,  'file1');
     181
     182run_make_test(q!
     183.INTERMEDIATE: file3
     184file4: file3 ; @mv -f $< $@
     185file3: file2 ; touch $@
     186file2: file1 ; @touch $@
    191187!,
    192                   '-j2 main.bar',
    193                   "touch foo.y.in
    194 touch main.x
    195 cp foo.y.in foo.y
    196 cat main.x foo.y > main.bar
    197 rm main.x");
    198 
    199     # Now we touch the .in file and make sure it still works
    200     touch('foo.y.in');
    201 
    202     run_make_test(undef, '-j2 main.bar', "cp foo.y.in foo.y
    203 touch main.x
    204 cat main.x foo.y > main.bar
    205 rm main.x");
    206 
    207     # Clean up
    208     rmfiles(qw(foo.y foo.y.in main.bar));
    209 }
    210 
    211 if ($all_tests) {
    212     # Jobserver FD handling is messed up in some way.
    213     # Savannah bug #28189
    214     # It doesn't look like that bug anymore but this is the code it runs
    215 
    216     run_make_test(q!
    217 ifdef EXTRA
    218 vpath %.dst /
    219 xxx.dst: ; true
    220 yyy.dst: ; true
    221 endif
    222 
    223 M := $(MAKE)
    224 xx: ; $M --no-print-directory -j2 -f $(MAKEFILE_LIST) xxx.dst yyy.dst EXTRA=1
    225 !,
    226                   '-j2',
    227                   '#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.
    228 true
    229 true
    230 ');
    231 }
     188              '--no-print-directory -j2', "touch file3");
     189
     190rmfiles('file1', 'file2', 'file3', 'file4');
    232191
    233192# Make sure that all jobserver FDs are closed if we need to re-exec the
     
    267226
    2682271;
     228
     229### Local Variables:
     230### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     231### End:
  • trunk/src/kmk/tests/scripts/features/patspecific_vars

    r2591 r3140  
    8282b%: pattern := good $$t
    8383
    84 global := orginal $$t
     84global := original $$t
    8585
    8686
     
    104104endif
    105105
    106 %z: ; @echo \'pattrn: $a;\'
     106%z: ; @echo \'pattern: $a;\'
    107107
    108108
     
    110110',
    111111'-j1',
    112 'normal: global: orginal $t pattern:  inherit: ;
    113 pattrn: global: orginal $t pattern:  inherit: ;');
     112'normal: global: original $t pattern:  inherit: ;
     113pattern: global: original $t pattern:  inherit: ;');
    114114
    115115
     
    119119'-j1 rec=1',
    120120'normal: global: new $t pattern: good $t inherit: good $t;
    121 pattrn: global: new $t pattern: good $t inherit: good $t;');
     121pattern: global: new $t pattern: good $t inherit: good $t;');
    122122
    123123# TEST #8: override in pattern-specific variables
  • trunk/src/kmk/tests/scripts/features/patternrules

    r2591 r3140  
    112112"dir=$dir",
    113113(!$is_kmk) ?
    114 "#MAKE#: *** [$dir/foo.bar] Error 1" :
     114"#MAKE#: *** [#MAKEFILE#:6: $dir/foo.bar] Error 1":
    115115"#MAKE#: *** [$dir/foo.bar] Error 1" . '
    116116The failing command:
     
    208208!,
    209209              'foo.tex',
    210               "#MAKE#: *** No rule to make target `foo.tex'.  Stop.", 512);
     210              "#MAKE#: *** No rule to make target 'foo.tex'.  Stop.", 512);
    211211
    212212unlink(@f);
     
    227227# This tells the test driver that the perl test script executed properly.
    2282281;
     229
     230### Local Variables:
     231### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     232### End:
  • trunk/src/kmk/tests/scripts/features/recursion

    r2591 r3140  
    1919              ('CFLAGS=-O -w' . ($parallel_jobs ? ' -j 2' : '')),
    2020              ($vos
    21                ? "#MAKE#: Entering directory `#PWD#'
     21               ? "#MAKE#: Entering directory '#PWD#'
    2222make 'CFLAGS=-O' -f #MAKEFILE# foo
    2323make CFLAGS=-O
     
    2727MAKELEVEL = 0
    2828THE END
    29 #MAKE#: Leaving directory `#PWD#'"
    30                : "#MAKE#: Entering directory `#PWD#'
     29#MAKE#: Leaving directory '#PWD#'"
     30               : "#MAKE#: Entering directory '#PWD#'
    3131#MAKEPATH# -f #MAKEFILE# foo
    32 #MAKE#[1]: Entering directory `#PWD#'
     32#MAKE#[1]: Entering directory '#PWD#'
    3333#MAKEPATH#
    3434MAKELEVEL = 1
    3535#MAKEPATH# -f #MAKEFILE# last
    36 #MAKE#[2]: Entering directory `#PWD#'
     36#MAKE#[2]: Entering directory '#PWD#'
    3737#MAKEPATH#
    3838MAKELEVEL = 2
    3939THE END
    40 #MAKE#[2]: Leaving directory `#PWD#'
    41 #MAKE#[1]: Leaving directory `#PWD#'
    42 #MAKE#: Leaving directory `#PWD#'"));
     40#MAKE#[2]: Leaving directory '#PWD#'
     41#MAKE#[1]: Leaving directory '#PWD#'
     42#MAKE#: Leaving directory '#PWD#'"));
    4343
    4444
  • trunk/src/kmk/tests/scripts/features/reinvoke

    r969 r3140  
    5858# including: this and the previous one test different parts of the code.
    5959
    60 run_make_test(undef, "F=b", "[ -f b ] || echo >> b\nhello\n")
     60run_make_test(undef, 'F=b', "[ -f b ] || echo >> b\nhello\n")
    6161
    6262&rmfiles('a','b','c');
    6363
     64# Ensure command line variables are preserved properly across re-exec
     65# Tests for Savannah bug #30723
     66
     67run_make_test('
     68ifdef RECURSE
     69-include foo30723
     70endif
     71recurse: ; @$(MAKE) -f $(MAKEFILE_LIST) RECURSE=1 test
     72test: ; @echo F.O=$(F.O)
     73foo30723: ; @touch $@
     74',
     75              '--no-print-directory F.O=bar', "F.O=bar\n");
     76
     77unlink('foo30723');
     78
    6479# This tells the test driver that the perl test script executed properly.
    65801;
  • trunk/src/kmk/tests/scripts/features/se_explicit

    r2591 r3140  
    88# bird: Modified this test to use ${PRE} instead of $(PRE) as it failes
    99#       when make is built with NO_ARCHIVES defined.
     10
     11# If we don't support archives then the prerequisite is different
     12my $prereq = exists $FEATURES{'archives'} ? '$' : '$(PRE)';
    1013
    1114run_make_test(q!
     
    2124!,
    2225              '',
    23               "\${PRE}\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz");
     26              "$prereq\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz");
    2427
    2528run_make_test(undef, 'SE=1', "three\nfour\nbariz\nfoo\$bar : baraz bariz");
     
    118121all : $$(eval $$(info test))
    119122!,
    120             '', "test\n#MAKE#: Nothing to be done for `all'.\n");
     123            '', "test\n#MAKE#: Nothing to be done for 'all'.\n");
    121124
    122125# TEST #5: (NEGATIVE) catch eval in a prereq list trying to create new
     
    155158
    156159
    157 # This tells the test driver that the perl test script executed properly.
     160# Allow patsubst shorthand in second expansion context.
     161# Requires the colon to be quoted.  Savannah bug #16545
     162run_make_test(q!
     163.PHONY: foo.bar
     164.SECONDEXPANSION:
     165foo: $$(@\\:%=%.bar); @echo '$^'
     166!,
     167              '', "foo.bar\n");
     168
    1581691;
  • trunk/src/kmk/tests/scripts/features/se_implicit

    r2591 r3140  
    223223              '', "\n");
    224224
     225# Test #10: Test second expansion with second expansion prerequisites
     226# Ensures pattern_search() recurses with SE prereqs.
     227touch('a');
     228run_make_test(q!
     229.SECONDEXPANSION:
     230sim_base_rgg := just_a_name
     231sim_base_src := a
     232sim_base_f := a a a
     233sim_%.f: $${sim_$$*_f}
     234        echo $@
     235sim_%.src: $${sim_$$*_src}
     236        echo $@
     237sim_%: \
     238        $$(if $$(sim_$$*_src),sim_%.src) \
     239        $$(if $$(sim_$$*_f),sim_%.f) \
     240        $$(if $$(sim_$$*_rgg),$$(sim_$$*_rgg).s)
     241        echo $@
     242!,
     243              '-s sim_base', "#MAKE#: *** No rule to make target 'sim_base'.  Stop.", 512);
     244
     245unlink('a');
     246
     247# Ensure that order-only tokens embedded in second expansions are parsed
     248run_make_test(q!
     249.SECONDEXPANSION:
     250PREREQS=p1|p2
     251P2=p2
     252all : foo bar
     253f%o: $$(PREREQS) ; @echo '$@' from '$^' and '$|'
     254b%r: p1|$$(P2)   ; @echo '$@' from '$^' and '$|'
     255p% : ; : $@
     256!,
     257              "", ": p1\n: p2\nfoo from p1 and p2\nbar from p1 and p2\n");
     258
    225259# This tells the test driver that the perl test script executed properly.
    2262601;
  • trunk/src/kmk/tests/scripts/features/targetvars

    r2591 r3140  
    238238run_make_test(undef, 'FOO=C', "C f1\n");
    239239
     240# TEST #19: Conditional variables with command-line settings
     241
     242run_make_test('
     243a: FOO ?= f1
     244a: ; @echo "$(FOO)"
     245',
     246              '', "f1\n");
     247
     248run_make_test(undef, 'FOO=C', "C\n");
     249
    240250# TEST #20: Check for continuation after semicolons
    241251
    242252run_make_test(q!
    243 a: A = 'hello; \
     253a: A = 'hello;\
    244254world'
    245255a: ; @echo $(A)
  • trunk/src/kmk/tests/scripts/features/varnesting

    r969 r3140  
    1 $description = "The following test creates a makefile to ...";
     1#                                                                    -*-perl-*-
     2$description = "Test recursive variables";
    23
    34$details = "";
    45
    5 open(MAKEFILE,"> $makefile");
     6run_make_test('
     7x = variable1
     8variable2 := Hello
     9y = $(subst 1,2,$(x))
     10z = y
     11a := $($($(z)))
     12all:
     13        @echo $(a)
     14',
     15              '', "Hello\n");
    616
    7 # The Contents of the MAKEFILE ...
     17# This tests resetting the value of a variable while expanding it.
     18# You may only see problems with this if you're using valgrind or
     19# some other memory checker that poisons freed memory.
     20# See Savannah patch #7534
    821
    9 print MAKEFILE "x = variable1\n"
    10               ."variable2 := Hello\n"
    11               ."y = \$(subst 1,2,\$(x))\n"
    12               ."z = y\n"
    13               ."a := \$(\$(\$(z)))\n"
    14               ."all: \n"
    15               ."\t\@echo \$(a)\n";
    16 
    17 # END of Contents of MAKEFILE
    18 
    19 close(MAKEFILE);
    20 
    21 &run_make_with_options($makefile,"",&get_logfile);
    22 
    23 # Create the answer to what should be produced by this Makefile
    24 $answer = "Hello\n";
    25 
    26 &compare_output($answer,&get_logfile(1));
     22run_make_test('
     23VARIABLE = $(eval VARIABLE := echo hi)$(VARIABLE)
     24wololo:
     25        @$(VARIABLE)
     26',
     27              '', "hi\n");
    2728
    28291;
  • trunk/src/kmk/tests/scripts/features/vpath

    r2591 r3140  
    7676vpath-d/fail.te:
    7777!,
    78               '', "#MAKE#: Nothing to be done for `default'.\n");
     78              '', "#MAKE#: Nothing to be done for 'default'.\n");
    7979
    8080rmdir('vpath-d');
  • trunk/src/kmk/tests/scripts/features/vpath3

    r2591 r3140  
    1 #                                                                     -*-perl-*-
     1#                                                                    -*-perl-*-
    22
    33$description = "Test the interaction of the -lfoo feature and vpath";
    44$details = "";
    55
    6 open(MAKEFILE,"> $makefile");
     6my @dirs_to_make = qw(a1 b1 a2 b2 b3);
     7for my $d (@dirs_to_make) {
     8    mkdir($d, 0777);
     9}
    710
    8 # The Contents of the MAKEFILE ...
    9 
    10 print MAKEFILE "vpath %.a a1\n";
    11 print MAKEFILE "vpath %.so b1\n";
    12 print MAKEFILE "vpath % a2 b2\n";
    13 print MAKEFILE "vpath % b3\n";
    14 print MAKEFILE "all: -l1 -l2 -l3; \@echo \$^\n";
    15 
    16 # END of Contents of MAKEFILE
    17 
    18 close(MAKEFILE);
    19 
    20 mkdir("a1", 0777);
    21 mkdir("b1", 0777);
    22 mkdir("a2", 0777);
    23 mkdir("b2", 0777);
    24 mkdir("b3", 0777);
    25 
    26 @files_to_touch = ("a1${pathsep}lib1.a",
    27                    "b1${pathsep}lib1.so",
    28                    "a2${pathsep}lib2.a",
    29                    "b2${pathsep}lib2.so",
    30                    "lib3.a",
    31                    "b3${pathsep}lib3.so");
    32 
     11my @files_to_touch = ("a1${pathsep}lib1.a",
     12                      "a1${pathsep}libc.a",
     13                      "b1${pathsep}lib1.so",
     14                      "a2${pathsep}lib2.a",
     15                      "b2${pathsep}lib2.so",
     16                      "lib3.a",
     17                      "b3${pathsep}lib3.so");
    3318&touch(@files_to_touch);
    3419
    35 &run_make_with_options($makefile,"",&get_logfile);
     20my $answer = "a1${pathsep}lib1.a a1${pathsep}libc.a " .
     21             "a2${pathsep}lib2.a lib3.a\n";
     22if ($port_type eq 'VMS-DCL') {
     23    $answer =~ s/ /,/g;
     24}
    3625
    37 # Create the answer to what should be produced by this Makefile
    38 $answer = "a1${pathsep}lib1.a a2${pathsep}lib2.a lib3.a\n";
     26run_make_test('
     27vpath %.h b3
     28vpath %.a a1
     29vpath %.so b1
     30vpath % a2 b2
     31vpath % b3
     32all: -l1 -lc -l2 -l3; @echo $^
     33',
     34              '', $answer);
    3935
    40 if (&compare_output($answer,&get_logfile(1)))
    41 {
    42   unlink @files_to_touch;
    43   rmdir("a1");
    44   rmdir("b1");
    45   rmdir("a2");
    46   rmdir("b2");
    47   rmdir("b3");
     36unlink(@files_to_touch);
     37for my $d (@dirs_to_make) {
     38    rmdir($d);
    4839}
    4940
  • trunk/src/kmk/tests/scripts/features/vpathgpath

    r969 r3140  
    5858push(@touchedfiles, "bar.c");
    5959
    60 $answer = "$make_name: Nothing to be done for `general'.\n";
     60$answer = "$make_name: Nothing to be done for 'general'.\n";
    6161
    6262&compare_output($answer,&get_logfile(1));
  • trunk/src/kmk/tests/scripts/features/vpathplus

    r969 r3140  
    8787$answer = "not creating notarget.c from notarget.d
    8888cat notarget.c > notarget.b 2>/dev/null || exit 1
    89 $make_name: *** [notarget.b] Error 1
     89$make_name: *** [$makefile:16: notarget.b] Error 1
    9090";
    9191
     
    127127
    1281281;
     129
     130### Local Variables:
     131### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     132### End:
  • trunk/src/kmk/tests/scripts/functions/call

    r969 r3140  
    55results.\n";
    66
    7 open(MAKEFILE, "> $makefile");
    8 
    9 # The Contents of the MAKEFILE ...
    10 
    11 print MAKEFILE <<'EOMAKE';
     7run_make_test(q!
    128# Simple, just reverse two things
    139#
    1410reverse = $2 $1
    1511
    16 # A complex `map' function, using recursive `call'.
     12# A complex 'map' function, using recursive 'call'.
    1713#
    1814map = $(foreach a,$2,$(call $1,$a))
     
    3935DEP_baz = quux blarp
    4036rest = $(wordlist 2,$(words ${1}),${1})
    41 tclose = $(if $1,$(firstword $1) \
     37tclose = $(if $1,$(firstword $1)\
    4238                $(call tclose,$(sort ${DEP_$(firstword $1)} $(call rest,$1))))
    4339
     
    4945        echo '$(call my-if,a,b,c)'; \
    5046        echo '$(call two,bar,baz)'; \
    51         echo '$(call tclose,foo)'
     47        echo '$(call tclose,foo)';
     48!,
     49              "", "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n");
    5250
    53 
    54 
    55 EOMAKE
    56 
    57 # These won't work until/unless PR/1527 is resolved.
    58 #        echo '$(call my-foreach,a,x y z,$(a)$(a))'; \
    59 #        echo '$(call my-if,,$(warning don't print this),ok)'
     51# These won't work because call expands all its arguments first, before
     52# passing them on, then marks them as resolved/simple, so they're not
     53# expanded again by the function.
    6054#
    61 # $answer = "xx yy zz\nok\n";
    62 
    63 # END of Contents of MAKEFILE
    64 
    65 close(MAKEFILE);
    66 
    67 &run_make_with_options($makefile, "", &get_logfile);
    68 $answer = "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n";
    69 &compare_output($answer, &get_logfile(1));
    70 
     55#        echo '$(call my-foreach,a,x y z,$$(a)$$(a))'; \
     56#        echo '$(call my-if,,$$(info don't print this),$$(info do print this))'
     57#
     58# $answer = "xx yy zz\ndo print this\n";
    7159
    7260# TEST eclipsing of arguments when invoking sub-calls
    7361
    74 $makefile2 = &get_tmpfile;
    75 
    76 open(MAKEFILE,"> $makefile2");
    77 
    78 print MAKEFILE <<'EOF';
    79 
     62run_make_test(q!
    8063all = $1 $2 $3 $4 $5 $6 $7 $8 $9
    8164
     
    8972        @echo $(call level2,1,2,3,4,5,6,7,8)
    9073        @echo $(call level3,1,2,3,4,5,6,7,8)
    91 EOF
     74!,
     75              "", "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n");
    9276
    93 close(MAKEFILE);
     77# Ensure that variables are defined in global scope even in a $(call ...)
    9478
    95 &run_make_with_options($makefile2, "", &get_logfile);
    96 $answer = "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n";
    97 &compare_output($answer,&get_logfile(1));
     79delete $ENV{X123};
     80
     81run_make_test('
     82tst = $(eval export X123)
     83$(call tst)
     84all: ; @echo "$${X123-not set}"
     85',
     86              '', "\n");
    9887
    99881;
     89
     90### Local Variables:
     91### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     92### End:
  • trunk/src/kmk/tests/scripts/functions/error

    r969 r3140  
    5555
    5656&run_make_with_options($makefile, "ERROR4=definitely", &get_logfile, 512);
    57 $answer = "Some stuff\n$makefile:16: *** error is definitely.  Stop.\n";
     57$answer = "Some stuff\n$makefile:17: *** error is definitely.  Stop.\n";
    5858&compare_output($answer,&get_logfile(1));
    5959
     
    67671;
    6868
    69 
    70 
    71 
    72 
    73 
     69### Local Variables:
     70### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     71### End:
  • trunk/src/kmk/tests/scripts/functions/filter-out

    r969 r3140  
    11#                                                                    -*-perl-*-
    22
    3 $description = "Test the filter-out function.";
     3$description = "Test the filter and filter-out functions.";
    44
    55$details = "The makefile created in this test has two variables.  The
     
    1212functions is the same single .elc name.\n";
    1313
    14 open(MAKEFILE,"> $makefile");
     14# Basic test -- filter
     15run_make_test(q!
     16files1 := $(filter %.o, foo.elc bar.o lose.o)
     17files2 := $(filter %.o foo.i, foo.i bar.i lose.i foo.elc bar.o lose.o)
     18all: ; @echo '$(files1) $(files2)'
     19!,
     20              '', "bar.o lose.o foo.i bar.o lose.o\n");
    1521
    16 print MAKEFILE <<'EOF';
     22# Basic test -- filter-out
     23run_make_test(q!
    1724files1 := $(filter-out %.o, foo.elc bar.o lose.o)
    1825files2 := $(filter-out foo.i bar.i lose.i %.o, foo.i bar.i lose.i foo.elc bar.o lose.o)
    19 all: ; @echo $(files1) $(files2)
    20 EOF
     26all: ; @echo '$(files1) $(files2)'
     27!,
     28              '', "foo.elc foo.elc\n");
    2129
    22 close(MAKEFILE);
     30# Escaped patterns
     31run_make_test(q!all:;@echo '$(filter foo\%bar,foo%bar fooXbar)'!,
     32              '', "foo%bar\n");
    2333
    24 &run_make_with_options($makefile, "", &get_logfile, 0);
    25 $answer = "foo.elc foo.elc\n";
    26 &compare_output($answer,&get_logfile(1));
     34run_make_test(q!all:;@echo '$(filter foo\%\%\\\\\%\%bar,foo%%\\%%bar fooX\\Ybar)'!,
     35              '', "foo%%\\%%bar\n");
     36
     37run_make_test(q!
     38X = $(filter foo\\\\\%bar,foo\%bar foo\Xbar)
     39all:;@echo '$(X)'!,
     40              '', "foo\\%bar\n");
    2741
    28421;
  • trunk/src/kmk/tests/scripts/functions/foreach

    r2175 r3140  
    11#                                                                    -*-perl-*-
    2 # $Id: foreach,v 1.5 2006/03/10 02:20:46 psmith Exp $
     2# $Id$
    33
    44$description = "Test the foreach function.";
     
    5656              'FOREACH');
    5757
     58# Allow variable names with trailing space
     59run_make_test(q!
     60$(foreach \
     61  a \
     62, b c d \
     63, $(info $a))
     64all:;@:
     65!,
     66              "", "b\nc\nd\n");
    5867
    59 # TEST 2: Check some error conditions.
     68# Allow empty variable names.  We still expand the body.
     69
     70run_make_test('
     71x = $(foreach ,1 2 3,a)
     72y := $x
     73
     74all: ; @echo $y',
     75              '', "a a a\n");
     76
     77# Check some error conditions.
    6078
    6179run_make_test('
     
    6583all: ; @echo $y',
    6684              '',
    67               "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'.  Stop.",
     85              "#MAKEFILE#:2: *** insufficient number of arguments (1) to function 'foreach'.  Stop.",
    6886              512);
    6987
    7088run_make_test('
    71 x = $(foreach )
     89x = $(foreach x,y)
    7290y := $x
    7391
    7492all: ; @echo $y',
    7593              '',
    76               "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'.  Stop.",
     94              "#MAKEFILE#:2: *** insufficient number of arguments (2) to function 'foreach'.  Stop.",
    7795              512);
    7896
  • trunk/src/kmk/tests/scripts/functions/shell

    r2591 r3140  
    55$details = '';
    66
     7# Test standard shell
     8run_make_test('.PHONY: all
     9OUT := $(shell echo hi)
     10all: ; @echo $(OUT)
     11              ','','hi');
    712
    813# Test shells inside rules.
    914run_make_test('.PHONY: all
    1015all: ; @echo $(shell echo hi)
    11 ','','hi');
     16              ','','hi');
     17
     18# Verify .SHELLSTATUS
     19run_make_test('.PHONY: all
     20PRE := $(.SHELLSTATUS)
     21$(shell exit 0)
     22OK := $(.SHELLSTATUS)
     23$(shell exit 1)
     24BAD := $(.SHELLSTATUS)
     25all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD)
     26              ','','PRE= OK=0 BAD=1');
    1227
    1328
     
    2843.PHONY: all
    2944all: ; @echo $$HI
    30 ','','hi');
     45    ','','hi');
     46
     47# Test shell errors in recipes including offset
     48run_make_test('
     49all:
     50        @echo hi
     51        $(shell ./basdfdfsed there)
     52        @echo there
     53',
     54              '', "#MAKE#: ./basdfdfsed: Command not found\nhi\nthere\n");
    3155
    32561;
     57
     58### Local Variables:
     59### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     60### End:
  • trunk/src/kmk/tests/scripts/functions/sort

    r969 r3140  
    1 $description = "The following test creates a makefile to verify\n"
    2               ."the ability of make to sort lists of object. Sort\n"
    3               ."will also remove any duplicate entries. This will also\n"
    4               ."be tested.";
     1#                                                                    -*-perl-*-
    52
    6 $details = "The make file is built with a list of object in a random order\n"
    7           ."and includes some duplicates. Make should sort all of the elements\n"
    8           ."remove all duplicates\n";
     3$description = "The following test creates a makefile to verify
     4the ability of make to sort lists of object. Sort
     5will also remove any duplicate entries. This will also
     6be tested.";
    97
    10 open(MAKEFILE,"> $makefile");
     8$details = "The make file is built with a list of object in a random order
     9and includes some duplicates. Make should sort all of the elements
     10remove all duplicates\n";
    1111
    12 # The Contents of the MAKEFILE ...
    13 
    14 print MAKEFILE "foo := moon_light days \n"
    15               ."foo1:= jazz\n"
    16               ."bar := captured \n"
    17               ."bar2 = boy end, has rise A midnight \n"
    18               ."bar3:= \$(foo)\n"
    19               ."s1  := _by\n"
    20               ."s2  := _and_a\n"
    21               ."t1  := \$(addsuffix \$(s1), \$(bar) )\n"
    22               ."t2  := \$(addsuffix \$(s2), \$(foo1) )\n"
    23               ."t3  := \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \n"
    24               ."t4  := \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \n"
    25               ."t5  := \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \n"
    26               ."t6  := \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \n"
    27               ."t7  := \$(t6) \$(t6) \$(t6) \n"
    28               ."p1  := \$(addprefix \$(foo1), \$(s2) )\n"
    29               ."blank:= \n"
    30               ."all:\n"
    31               ."\t\@echo \$(sort \$(bar2) \$(foo)  \$(addsuffix \$(s1), \$(bar) ) \$(t2) \$(bar2) \$(bar3))\n"
    32               ."\t\@echo \$(sort \$(blank) \$(foo) \$(bar2) \$(t1) \$(p1) )\n"
    33               ."\t\@echo \$(sort \$(foo) \$(bar2) \$(t1) \$(t4) \$(t5) \$(t7) \$(t6) )\n";
     12run_make_test('
     13foo := moon_light days
     14foo1:= jazz
     15bar := captured
     16bar2 = boy end, has rise A midnight
     17bar3:= $(foo)
     18s1  := _by
     19s2  := _and_a
     20t1  := $(addsuffix $(s1), $(bar) )
     21t2  := $(addsuffix $(s2), $(foo1) )
     22t3  := $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2)
     23t4  := $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3)
     24t5  := $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4)
     25t6  := $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5)
     26t7  := $(t6) $(t6) $(t6)
     27p1  := $(addprefix $(foo1), $(s2) )
     28blank:=
     29all:
     30        @echo $(sort $(bar2) $(foo)  $(addsuffix $(s1), $(bar) ) $(t2) $(bar2) $(bar3))
     31        @echo $(sort $(blank) $(foo) $(bar2) $(t1) $(p1) )
     32        @echo $(sort $(foo) $(bar2) $(t1) $(t4) $(t5) $(t7) $(t6) )
     33',
     34              '', 'A boy captured_by days end, has jazz_and_a midnight moon_light rise
     35A boy captured_by days end, has jazz_and_a midnight moon_light rise
     36A boy captured_by days end, has jazz_and_a midnight moon_light rise
     37');
    3438
    3539
    36 # END of Contents of MAKEFILE
     40# Test with non-space/tab whitespace.  Note that you can't see the
     41# original bug except using valgrind.
    3742
    38 close(MAKEFILE);
    39 
    40 &run_make_with_options($makefile,"",&get_logfile);
    41 
    42 # Create the answer to what should be produced by this Makefile
    43 $answer = "A boy captured_by days end, has jazz_and_a midnight moon_light rise\n"
    44          ."A boy captured_by days end, has jazz_and_a midnight moon_light rise\n"
    45          ."A boy captured_by days end, has jazz_and_a midnight moon_light rise\n";
    46 
    47 &compare_output($answer,&get_logfile(1));
     43run_make_test("FOO = a b\tc\rd\fe \f \f \f \f \ff
     44all: ; \@echo \$(words \$(sort \$(FOO)))\n",
     45              '', "6\n");
    4846
    49471;
    5048
    51 
    52 
    53 
    54 
    55 
     49### Local Variables:
     50### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     51### End:
  • trunk/src/kmk/tests/scripts/functions/warning

    r969 r3140  
    5353
    5454&run_make_with_options($makefile, "WARNING4=definitely", &get_logfile, 0);
    55 $answer = "Some stuff\n$makefile:14: warning is definitely\nhi\nthere\n";
     55$answer = "Some stuff\n$makefile:15: warning is definitely\nhi\nthere\n";
    5656&compare_output($answer,&get_logfile(1));
     57
     58# Test linenumber offset
     59
     60run_make_test(q!
     61all: one two
     62        $(warning in $@ line 3)
     63        @true
     64        $(warning in $@ line 5)
     65
     66one two:
     67        $(warning in $@ line 8)
     68        @true
     69        $(warning in $@ line 10)
     70!,
     71              '', "#MAKEFILE#:8: in one line 8
     72#MAKEFILE#:10: in one line 10
     73#MAKEFILE#:8: in two line 8
     74#MAKEFILE#:10: in two line 10
     75#MAKEFILE#:3: in all line 3
     76#MAKEFILE#:5: in all line 5\n");
    5777
    5878# This tells the test driver that the perl test script executed properly.
    59791;
    6080
    61 
    62 
    63 
    64 
    65 
     81### Local Variables:
     82### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     83### End:
  • trunk/src/kmk/tests/scripts/functions/wildcard

    r2591 r3140  
    8989              '', "\n");
    9090
     91# TEST #5: wildcard used to verify file existence
     92
     93touch('xxx.yyy');
     94
     95run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
     96              '', "file=xxx.yyy\n");
     97
     98unlink('xxx.yyy');
     99
     100run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
     101              '', "file=\n");
     102
    911031;
  • trunk/src/kmk/tests/scripts/functions/word

    r969 r3140  
    5757wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO))',
    5858              'word-e1',
    59               "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''.  Stop.",
     59              "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''.  Stop.",
    6060              512);
    6161
    6262run_make_test(undef,
    6363              'word-e2',
    64               "#MAKEFILE#:4: *** non-numeric first argument to `word' function: 'abc '.  Stop.",
     64              "#MAKEFILE#:4: *** non-numeric first argument to 'word' function: 'abc '.  Stop.",
    6565              512);
    6666
    6767run_make_test(undef,
    6868              'word-e3',
    69               "#MAKEFILE#:5: *** non-numeric first argument to `word' function: '1a'.  Stop.",
     69              "#MAKEFILE#:5: *** non-numeric first argument to 'word' function: '1a'.  Stop.",
    7070              512);
    7171
    7272run_make_test(undef,
    7373              'wordlist-e1',
    74               "#MAKEFILE#:7: *** non-numeric first argument to `wordlist' function: ''.  Stop.",
     74              "#MAKEFILE#:7: *** non-numeric first argument to 'wordlist' function: ''.  Stop.",
    7575              512);
    7676
    7777run_make_test(undef,
    7878              'wordlist-e2',
    79               "#MAKEFILE#:8: *** non-numeric first argument to `wordlist' function: 'abc '.  Stop.",
     79              "#MAKEFILE#:8: *** non-numeric first argument to 'wordlist' function: 'abc '.  Stop.",
    8080              512);
    8181
    8282run_make_test(undef,
    8383              'wordlist-e3',
    84               "#MAKEFILE#:9: *** non-numeric second argument to `wordlist' function: ' 12a '.  Stop.",
     84              "#MAKEFILE#:9: *** non-numeric second argument to 'wordlist' function: ' 12a '.  Stop.",
    8585              512);
    8686
     
    9595wordlist-e: ; @echo $(WL)',
    9696              'word-e x=',
    97               "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''.  Stop.",
     97              "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''.  Stop.",
    9898              512);
    9999
    100100run_make_test(undef,
    101101              'word-e x=abc',
    102               "#MAKEFILE#:3: *** non-numeric first argument to `word' function: 'abc'.  Stop.",
     102              "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: 'abc'.  Stop.",
    103103              512);
    104104
    105105run_make_test(undef,
    106106              'word-e x=0',
    107               "#MAKEFILE#:3: *** first argument to `word' function must be greater than 0.  Stop.",
     107              "#MAKEFILE#:3: *** first argument to 'word' function must be greater than 0.  Stop.",
    108108              512);
    109109
    110110run_make_test(undef,
    111111              'wordlist-e s= e=',
    112               "#MAKEFILE#:4: *** non-numeric first argument to `wordlist' function: ''.  Stop.",
     112              "#MAKEFILE#:4: *** non-numeric first argument to 'wordlist' function: ''.  Stop.",
    113113              512);
    114114
    115115run_make_test(undef,
    116116              'wordlist-e s=abc e=',
    117               "#MAKEFILE#:4: *** non-numeric first argument to `wordlist' function: 'abc'.  Stop.",
     117              "#MAKEFILE#:4: *** non-numeric first argument to 'wordlist' function: 'abc'.  Stop.",
    118118              512);
    119119
    120120run_make_test(undef,
    121121              'wordlist-e s=4 e=12a',
    122               "#MAKEFILE#:4: *** non-numeric second argument to `wordlist' function: '12a'.  Stop.",
     122              "#MAKEFILE#:4: *** non-numeric second argument to 'wordlist' function: '12a'.  Stop.",
    123123              512);
    124124
    125125run_make_test(undef,
    126126              'wordlist-e s=0 e=12',
    127               "#MAKEFILE#:4: *** invalid first argument to `wordlist' function: `0'.  Stop.",
     127              "#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: '0'.  Stop.",
    128128              512);
    129129
  • trunk/src/kmk/tests/scripts/misc/general3

    r969 r3140  
    2727
    2828\$(STR) \$(TAB)",
    29               '', "#MAKE#: Nothing to be done for `all'.");
     29              '', "#MAKE#: Nothing to be done for 'all'.");
    3030
    3131# TEST 2
     
    311311foo     bar');
    312312
     313run_make_test('x:;@-exit 1', '', "#MAKE#: [#MAKEFILE#:1: x] Error 1 (ignored)\n");
     314
    3133151;
  • trunk/src/kmk/tests/scripts/options/dash-B

    r2591 r3140  
    2323              '', 'cp bar.x foo');
    2424
    25 run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");
     25run_make_test(undef, '', "#MAKE#: Nothing to be done for 'all'.");
    2626run_make_test(undef, '-B', 'cp bar.x foo');
    2727
     
    2929
    3030utouch(1000, 'foo');
    31 run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");
     31run_make_test(undef, '', "#MAKE#: Nothing to be done for 'all'.");
    3232run_make_test(undef, '-B', 'cp bar.x foo');
    3333
     
    4646',
    4747              '-B', 'MAKE_RESTARTS=
    48 #MAKEFILE#:4: foo.x: No such file or directory
    4948MAKE_RESTARTS=1');
    5049
     
    6463',
    6564              '-B', 'MAKE_RESTARTS=
    66 #MAKEFILE#:4: foo.x: No such file or directory
    6765MAKE_RESTARTS=1
    6866blah.x
     
    8482
    85831;
     84
     85### Local Variables:
     86### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     87### End:
  • trunk/src/kmk/tests/scripts/options/dash-C

    r969 r3140  
    3535
    3636# Create the answer to what should be produced by this Makefile
    37 $answer = "$make_name: Entering directory `$wpath'\n"
     37$answer = "$make_name: Entering directory '$wpath'\n"
    3838        . "$delete_command EXAMPLE\n"
    39         . "$make_name: Leaving directory `$wpath'\n";
     39        . "$make_name: Leaving directory '$wpath'\n";
    4040
    4141&compare_output($answer,&get_logfile(1));
     
    6363
    6464# Create the answer to what should be produced by this Makefile
    65 $answer = "$make_name: Entering directory `$wpath'\n"
     65$answer = "$make_name: Entering directory '$wpath'\n"
    6666        . "$delete_command EXAMPLEslash\n"
    67         . "$make_name: Leaving directory `$wpath'\n";
     67        . "$make_name: Leaving directory '$wpath'\n";
    6868
    6969&compare_output($answer,&get_logfile(1));
  • trunk/src/kmk/tests/scripts/options/dash-I

    r969 r3140  
    5252
    5353$answer = "$mkpath ANOTHER -f $makefile
    54 ${make_name}[1]: Entering directory `$pwd'
     54${make_name}[1]: Entering directory '$pwd'
    5555This is another included makefile
    56 ${make_name}[1]: Leaving directory `$pwd'\n";
     56${make_name}[1]: Leaving directory '$pwd'\n";
    5757
    5858&run_make_with_options($makefile,"-I $workdir recurse",&get_logfile);
  • trunk/src/kmk/tests/scripts/options/dash-W

    r969 r3140  
    1313# Run it again: nothing should happen
    1414
    15 run_make_test(undef, '', "#MAKE#: `a.x' is up to date.");
     15run_make_test(undef, '', "#MAKE#: 'a.x' is up to date.");
    1616
    1717# Now run it with -W b.x: should rebuild a.x
     
    2222
    2323utouch(1000, 'a.x');
    24 run_make_test(undef, '', "#MAKE#: `a.x' is up to date.");
     24run_make_test(undef, '', "#MAKE#: 'a.x' is up to date.");
    2525run_make_test(undef, '-W b.x', 'echo >> a.x');
    2626
     
    4343baz.x: bar.x ; @echo "touch $@"
    4444',
    45               '', '#MAKEFILE#:3: foo.x: No such file or directory
    46 echo >> bar.x
     45              '', 'echo >> bar.x
    4746touch foo.x
    4847restarts=1
     
    8786
    88871;
     88
     89### Local Variables:
     90### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     91### End:
  • trunk/src/kmk/tests/scripts/options/dash-k

    r1964 r3140  
    4343               "$workdir${pathsep}commands.c","$workdir${pathsep}display.c",
    4444               "$workdir${pathsep}buffer.h",
    45                "$workdir${pathsep}command.c");
     45               "$workdir${pathsep}command.c");
    4646
    4747&touch(@files_to_touch);
     
    5858# Create the answer to what should be produced by this Makefile
    5959$answer = "cc -c main.c
    60 $make_name: *** No rule to make target `kbd.c', needed by `kbd.o'.
     60$make_name: *** No rule to make target 'kbd.c', needed by 'kbd.o'.
    6161cc -c commands.c
    6262cc -c display.c
    63 $make_name: Target `edit' not remade because of errors.\n";
     63$make_name: Target 'edit' not remade because of errors.\n";
    6464
    6565# COMPARE RESULTS
     
    9393
    9494$answer = "exit 1
    95 $make_name: *** [foo.o] Error 1
    96 $make_name: Target `all' not remade because of errors.\n";
     95$make_name: *** [$makefile2:9: foo.o] Error 1
     96$make_name: Target 'all' not remade because of errors.\n";
    9797
    9898&compare_output($answer, &get_logfile(1));
     
    107107              '-k',
    108108              "#MAKEFILE#:2: ifile: No such file or directory
    109 #MAKE#: *** No rule to make target `no-such-file', needed by `ifile'.
    110 #MAKE#: Failed to remake makefile `ifile'.
     109#MAKE#: *** No rule to make target 'no-such-file', needed by 'ifile'.
     110#MAKE#: Failed to remake makefile 'ifile'.
    111111hi\n",
    112112              512);
  • trunk/src/kmk/tests/scripts/options/dash-n

    r969 r3140  
    44$details = "Try various uses of -n and ensure they all give the correct results.\n";
    55
    6 open(MAKEFILE, "> $makefile");
     6touch('orig');
    77
    8 # The Contents of the MAKEFILE ...
    9 
    10 print MAKEFILE <<'EOMAKE';
    11 
     8run_make_test(q!
    129final: intermediate ; echo >> $@
    1310intermediate: orig ; echo >> $@
    14 
    15 EOMAKE
    16 
    17 close(MAKEFILE);
    18 
    19 &touch('orig');
    20 
    21 # TEST 0
    22 
    23 &run_make_with_options($makefile, "", &get_logfile);
    24 $answer = "echo >> intermediate\necho >> final\n";
    25 &compare_output($answer, &get_logfile(1));
     11!,
     12              '', "echo >> intermediate\necho >> final\n");
    2613
    2714# TEST 1
    2815
    29 &run_make_with_options($makefile, "-Worig -n", &get_logfile);
    30 $answer = "echo >> intermediate\necho >> final\n";
    31 &compare_output($answer, &get_logfile(1));
     16run_make_test(undef, '-Worig -n', "echo >> intermediate\necho >> final\n");
    3217
    33 unlink('orig', 'intermediate', 'final');
     18rmfiles(qw(orig intermediate final));
    3419
    3520# We consider the actual updated timestamp of targets with all
    36 # recursive commands, even with -n.
     21# recursive commands, even with -n.  Switching this to the new model
     22# is non-trivial because we use a trick below to change the log content
     23# before we compare it ...
    3724
    3825$makefile2 = &get_tmpfile;
     
    5744
    5845&run_make_with_options($makefile2, "", &get_logfile);
    59 $answer = "$make_name: `a' is up to date.\n";
     46$answer = "$make_name: 'a' is up to date.\n";
    6047&compare_output($answer, &get_logfile(1));
    6148
     
    6350
    6451&run_make_with_options($makefile2, "-n", &get_logfile);
    65 $answer = "$make_name: `a' is up to date.\n";
     52$answer = "$make_name: 'a' is up to date.\n";
    6653&compare_output($answer, &get_logfile(1));
    6754
    68 unlink('a', 'b', 'c');
     55# TEST 4
     56
     57unlink(qw(a b));
     58
     59&run_make_with_options($makefile2, "-t -n", &get_logfile);
     60
     61open(DASH_N_LOG, ">>" . &get_logfile(1));
     62print DASH_N_LOG "a exists but should not!\n" if -e 'a';
     63print DASH_N_LOG "b exists but should not!\n" if -e 'b';
     64close(DASH_N_LOG);
     65
     66&compare_output("touch b\ntouch a\n", &get_logfile(1));
     67
     68# CLEANUP
     69
     70unlink(qw(a b c));
     71
     72# Ensure -n continues to be included with recursive/re-execed make
     73# See Savannah bug #38051
     74
     75$topmake = &get_tmpfile;
     76$submake = &get_tmpfile;
     77
     78open(MAKEFILE, "> $topmake");
     79print MAKEFILE <<"EOF";
     80foo: ; \@\$(MAKE) -f "$submake" bar
     81EOF
     82close(MAKEFILE);
     83
     84
     85# The bar target should print what would happen, but not actually run
     86open(MAKEFILE, "> $submake");
     87print MAKEFILE <<'EOF';
     88inc: ; touch $@
     89-include inc
     90bar: ; @echo $(strip $(MAKEFLAGS))
     91EOF
     92close(MAKEFILE);
     93
     94&run_make_with_options($topmake, '-n --no-print-directory', &get_logfile);
     95$answer = "$make_command -f \"$submake\" bar\ntouch inc\necho n --no-print-directory\n";
     96&compare_output($answer, &get_logfile(1));
     97
     98unlink('inc');
    6999
    701001;
  • trunk/src/kmk/tests/scripts/options/dash-q

    r969 r3140  
    66# TEST 0
    77
    8 run_make_test('
     8run_make_test(qq!
    99one:
    1010two: ;
    1111three: ; :
    12 four: ; $(.XY)
    13 five: ; \
    14  $(.XY)
    15 six: ; \
    16  $(.XY)
    17         $(.XY)
    18 seven: ; \
    19  $(.XY)
    20         : foo
    21         $(.XY)
    22 ',
     12four: ; \$(.XY)
     13five: ; \\
     14 \$(.XY)
     15six: ; \\
     16 \$(.XY)
     17\t\$(.XY)
     18seven: ; \\
     19 \$(.XY)
     20\t: foo
     21\t\$(.XY)
     22!,
    2323              '-q one', '');
    2424
     
    5555              '-q', '', 256);
    5656
     57# TEST 7 : Savannah bug # 42249
     58# Make sure we exit with 1 even for prerequisite updates
     59run_make_test('
     60build-stamp: ; echo $@
     61build-arch: build-stamp
     62build-x: build-arch
     63build-y: build-x
     64',
     65              '-q build-y', '', 256);
     66
     67# TEST 8
     68# Make sure we exit with 2 on error even with -q
     69run_make_test('
     70build-stamp: ; echo $@
     71build-arch: build-stamp-2
     72build-x: build-arch
     73build-y: build-x
     74',
     75              '-q build-y', "#MAKE#: *** No rule to make target 'build-stamp-2', needed by 'build-arch'.  Stop.\n", 512);
     76
     77# TEST 9 : Savannah bug # 47151
     78# Make sure we exit with 1 when invoking a recursive make
     79run_make_test('
     80foo: bar ; echo foo
     81bar: ; @$(MAKE) -f #MAKEFILE# baz
     82baz: ; echo baz
     83',
     84              '-q foo', '', 256);
     85
    57861;
  • trunk/src/kmk/tests/scripts/options/eval

    r2591 r3140  
    1717              "eval\neval\nall\nrecurse");
    1818
     19# Make sure that --eval is handled correctly during restarting
     20run_make_test(q!
     21all: ; @echo $@
     22-include gen.mk
     23gen.mk: ; @echo > $@
     24!,
     25              '--eval=\$\(info\ eval\)', "eval\neval\nall");
     26
     27unlink('gen.mk');
     28
    19291;
  • trunk/src/kmk/tests/scripts/options/symlinks

    r2591 r3140  
    2727  # With -L, it should update targ
    2828  run_make_test('targ: sym ; @echo make $@ from $<', '',
    29                 "#MAKE#: `targ' is up to date.");
     29                "#MAKE#: 'targ' is up to date.");
    3030  run_make_test(undef, '-L', "make targ from sym");
    3131
     
    3737  # Now update targ; in all cases targ should be up to date.
    3838  &touch('targ');
    39   run_make_test(undef, '', "#MAKE#: `targ' is up to date.");
    40   run_make_test(undef, '-L', "#MAKE#: `targ' is up to date.");
     39  run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
     40  run_make_test(undef, '-L', "#MAKE#: 'targ' is up to date.");
    4141
    4242  # Add in a new link between sym and dep.  Be sure it's newer than targ.
     
    4747  # Without -L, nothing should happen
    4848  # With -L, it should update targ
    49   run_make_test(undef, '', "#MAKE#: `targ' is up to date.");
     49  run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
    5050  run_make_test(undef, '-L', "make targ from sym");
    5151
     
    5757  symlink("../$dirname/dep", 'sym');
    5858  run_make_test('targ: sym ; @echo make $@ from $<', '',
    59                 "#MAKE#: *** No rule to make target `sym', needed by `targ'.  Stop.", 512);
     59                "#MAKE#: *** No rule to make target 'sym', needed by 'targ'.  Stop.", 512);
    6060
    6161  run_make_test('targ: sym ; @echo make $@ from $<', '-L',
  • trunk/src/kmk/tests/scripts/options/warn-undefined-variables

    r969 r3140  
    1919# With --warn-undefined-variables, it should warn me
    2020run_make_test(undef, '--warn-undefined-variables',
    21               "#MAKEFILE#:7: warning: undefined variable `UNDEFINED'
    22 #MAKEFILE#:9: warning: undefined variable `UNDEFINED'
     21              "#MAKEFILE#:7: warning: undefined variable 'UNDEFINED'
     22#MAKEFILE#:9: warning: undefined variable 'UNDEFINED'
    2323ref");
    2424
  • trunk/src/kmk/tests/scripts/targets/DEFAULT

    r969 r3140  
    3636
    3737# Create the answer to what should be produced by this Makefile
    38 $answer = "${make_name}[1]: Entering directory `$pwd'\n"
     38$answer = "${make_name}[1]: Entering directory '$pwd'\n"
    3939        . "Executing rule BAR\n"
    40         . "${make_name}[1]: Leaving directory `$pwd'\n";
     40        . "${make_name}[1]: Leaving directory '$pwd'\n";
    4141
    4242# COMPARE RESULTS
  • trunk/src/kmk/tests/scripts/targets/INTERMEDIATE

    r1994 r3140  
    4343
    4444&run_make_with_options($makefile,'foo.d',&get_logfile);
    45 $answer = "$make_name: `foo.d' is up to date.\n";
     45$answer = "$make_name: 'foo.d' is up to date.\n";
    4646&compare_output($answer, &get_logfile(1));
    4747
     
    6666
    6767&run_make_with_options($makefile,'foo.c',&get_logfile);
    68 $answer = "$make_name: `foo.c' is up to date.\n";
     68$answer = "$make_name: 'foo.c' is up to date.\n";
    6969&compare_output($answer, &get_logfile(1));
    7070
  • trunk/src/kmk/tests/scripts/targets/ONESHELL

    r2591 r3140  
    55$details = "";
    66
     7# Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
     8# separate arguments.
     9my $t = `/bin/sh -e -c true 2>/dev/null`;
     10my $multi_ok = $? == 0;
    711
    812# Simple
     
    1721[ 0"$a" -eq "$$" ] || echo fail
    1822');
     23
     24# Simple but use multi-word SHELLFLAGS
     25
     26if ($multi_ok) {
     27    run_make_test(q!
     28.ONESHELL:
     29.SHELLFLAGS = -e -c
     30all:
     31        a=$$$$
     32        [ 0"$$a" -eq "$$$$" ] || echo fail
     33!,
     34              '', 'a=$$
     35[ 0"$a" -eq "$$" ] || echo fail
     36');
     37}
    1938
    2039# Again, but this time with inner prefix chars
  • trunk/src/kmk/tests/scripts/targets/POSIX

    r2591 r3140  
    11#                                                                    -*-perl-*-
    22
    3 $description = "Test the behaviour of the .PHONY target.";
     3$description = "Test the behaviour of the .POSIX target.";
    44
    55$details = "";
     
    1818all: ; \@$script
    1919!,
    20               '', "#MAKE#: *** [all] Error $err\n", 512);
     20              '', "#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);
    2121
    2222# User settings must override .POSIX
     
    3030              '', $out);
    3131
     32# Test the default value of various POSIX-specific variables
     33my %POSIX = (AR => 'ar', ARFLAGS => '-rv',
     34             YACC => 'yacc', YFLAGS => '',
     35             LEX => 'lex', LFLAGS => '',
     36             LDFLAGS => '',
     37             CC => 'c99', CFLAGS => '-O',
     38             FC => 'fort77', FFLAGS => '-O 1',
     39             GET => 'get', GFLAGS => '',
     40             SCCSFLAGS => '', SCCSGETFLAGS => '-s');
     41my $make = join('', map { "\t\@echo '$_=\$($_)'\n" } sort keys %POSIX);
     42my $r = join('', map { "$_=$POSIX{$_}\n"} sort keys %POSIX);
     43run_make_test(qq!
     44.POSIX:
     45all:
     46$make
     47!,
     48              '', $r);
     49
     50# Make sure that local settings take precedence
     51%extraENV = map { $_ => "xx-$_" } keys %POSIX;
     52$r = join('', map { "$_=xx-$_\n"} sort keys %POSIX);
     53run_make_test(undef, '', $r);
     54
    3255# This tells the test driver that the perl test script executed properly.
    33561;
  • trunk/src/kmk/tests/scripts/targets/SECONDARY

    r1994 r3140  
    4545
    4646&run_make_with_options($makefile,'foo.d',&get_logfile);
    47 $answer = "$make_name: `foo.d' is up to date.\n";
     47$answer = "$make_name: 'foo.d' is up to date.\n";
    4848&compare_output($answer, &get_logfile(1));
    4949
     
    6868
    6969&run_make_with_options($makefile,'foo.c',&get_logfile);
    70 $answer = "$make_name: `foo.c' is up to date.\n";
     70$answer = "$make_name: 'foo.c' is up to date.\n";
    7171&compare_output($answer, &get_logfile(1));
    7272
     
    104104
    105105&run_make_with_options($makefile2, '', &get_logfile);
    106 $answer = "$make_name: `final' is up to date.\n";
     106$answer = "$make_name: 'final' is up to date.\n";
    107107&compare_output($answer, &get_logfile(1));
    108108
     
    130130%.c : %.b ; cp $< $@
    131131%.b : %.a ; cp $< $@
    132 all : 1.c 2.c', '-rR -j',
     132all : 1.c 2.c
     1332.a: 1.c', '-rR -j',
    133134'cp 1.a 1.b
     135cp 1.b 1.c
    134136cp 2.a 2.b
    135 cp 1.b 1.c
    136137cp 2.b 2.c
    137138rm 1.b 2.b');
  • trunk/src/kmk/tests/scripts/variables/DEFAULT_GOAL

    r2591 r3140  
    4343',
    4444'',
    45 '#MAKE#: *** No rule to make target `foo\'.  Stop.',
     45"#MAKE#: *** No rule to make target 'foo'.  Stop.",
    4646512);
    4747
  • trunk/src/kmk/tests/scripts/variables/LIBPATTERNS

    r2591 r3140  
    2121all: -lfoo ; @echo "build $@ from $<"
    2222',
    23               '', "#MAKE#: .LIBPATTERNS element `mtest_foo.a' is not a pattern
     23              '', "#MAKE#: .LIBPATTERNS element 'mtest_foo.a' is not a pattern
    2424build all from mtest_foo.a\n");
    2525
  • trunk/src/kmk/tests/scripts/variables/MAKE

    r2591 r3140  
    1717              '',
    1818              "#MAKEPATH#\n#MAKEPATH# -f #MAKEFILE# foo\n"
    19               . "#MAKE#[1]: Entering directory `#PWD#'\n"
    20               . "#MAKEPATH#\n#MAKE#[1]: Leaving directory `#PWD#'\n");
     19              . "#MAKE#[1]: Entering directory '#PWD#'\n"
     20              . "#MAKEPATH#\n#MAKE#[1]: Leaving directory '#PWD#'\n");
    2121
    2222rmfiles("foo");
  • trunk/src/kmk/tests/scripts/variables/MAKEFLAGS

    r2591 r3140  
    1 #                                                                    -*-perl-*-
     1#                                                                    -*-perl-*-
    22
    33$description = "Test proper behavior of MAKEFLAGS";
     
    99all: ; @echo $(MAKEFLAGS)
    1010!,
    11               '-e -r -R', 'Rre');
     11              '-e -r -R', 'erR');
    1212
    1313# Long arguments mean everything is prefixed with "-"
     
    1515all: ; @echo $(MAKEFLAGS)
    1616!,
    17               '--no-print-directory -e -r -R', '--no-print-directory -Rre');
     17              '--no-print-directory -e -r -R --trace', "#MAKEFILE#:2: target 'all' does not exist
     18echo erR --trace --no-print-directory
     19erR --trace --no-print-directory");
    1820
    1921
    20 if ($all_tests) {
    21     # Recursive invocations of make should accumulate MAKEFLAGS values.
    22     # Savannah bug #2216
    23     run_make_test(q!
     22# Recursive invocations of make should accumulate MAKEFLAGS values.
     23# Savannah bug #2216
     24run_make_test(q!
    2425MSG = Fails
    2526all:
     
    2728        @MSG=Works $(MAKE) -e -f #MAKEFILE# jump
    2829jump:
    29         @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
     30        @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
    3031        @$(MAKE) -f #MAKEFILE# print
    3132print:
    32         @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
    33         @echo $(MSG)
     33        @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
    3434.PHONY: all jump print
    3535!,
    3636                  '--no-print-directory',
    3737                  'all: MAKEFLAGS= --no-print-directory
    38 jump: MAKEFLAGS= --no-print-directory -e
    39 print: MAKEFLAGS= --no-print-directory -e
    40 Works');
    41 }
     38jump Works: MAKEFLAGS=e --no-print-directory
     39print Works: MAKEFLAGS=e --no-print-directory');
    4240
    43411;
     42
     43### Local Variables:
     44### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     45### End:
  • trunk/src/kmk/tests/scripts/variables/MAKE_RESTARTS

    r969 r3140  
    1212',
    1313              '', 'MAKE_RESTARTS=
    14 #MAKEFILE#:4: foo.x: No such file or directory
    1514MAKE_RESTARTS=1');
    1615
     
    2726',
    2827              '', 'MAKE_RESTARTS=
    29 #MAKEFILE#:4: foo.x: No such file or directory
    3028MAKE_RESTARTS=1
    31 foo.x:1: bar.x: No such file or directory
    3229MAKE_RESTARTS=2');
    3330
     
    4845',
    4946              '', "MAKE_RESTARTS=
    50 #MAKEFILE#:8: foo.x: No such file or directory
    5147MAKE_RESTARTS=1
    52 foo.x:1: bar.x: No such file or directory
    5348MAKE_RESTARTS=2
    5449recurse MAKE_RESTARTS=
     50#MAKE#[1]: Entering directory '#PWD#'
    5551MAKE_RESTARTS=
    56 #MAKE#[1]: Entering directory `#PWD#'
    5752all MAKE_RESTARTS=
    58 #MAKE#[1]: Leaving directory `#PWD#'");
     53#MAKE#[1]: Leaving directory '#PWD#'");
    5954
    6055rmfiles('foo.x', 'bar.x');
    6156
    62571;
     58
     59### Local Variables:
     60### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     61### End:
  • trunk/src/kmk/tests/scripts/variables/SHELL

    r2591 r3140  
    7272              '', $out);
    7373
     74# Do it again but add spaces to SHELLFLAGS
     75
     76# Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
     77# separate arguments.
     78my $t = `/bin/sh -e -c true 2>/dev/null`;
     79my $multi_ok = $? == 0;
     80
     81if ($multi_ok) {
     82    $flags = '-x -c';
     83    run_make_test(qq!
     84.SHELLFLAGS = $flags
     85all: ; \@$script
     86!,
     87              '', $out);
     88}
     89
    7490# We can't just use "false" because on different systems it provides a
    7591# different exit code--once again Solaris: false exits with 255 not 1
     
    8399all: ; \@$script
    84100!,
    85               '', "$out#MAKE#: *** [all] Error $err\n", 512);
     101              '', "$out#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);
    86102
    871031;
  • trunk/src/kmk/tests/scripts/variables/define

    r2591 r3140  
    3131endef
    3232
     33define posix ::=
     34@echo $(FOO)
     35endef
     36
    3337append = @echo a
    3438
     
    5054all: ; $(multi)
    5155        $(simple)
     56        $(posix)
    5257        $(append)
    5358        $(cond)
    5459',
    55               '', "echo hi\nhi\nthere\nfoo\na\nb\nfirst\n");
     60              '', "echo hi\nhi\nthere\nfoo\nfoo\na\nb\nfirst\n");
     61
     62# TEST 1a: Various new-style define/endef, with no spaces
     63
     64run_make_test('
     65FOO = foo
     66
     67define multi=
     68echo hi
     69@echo $(FOO)
     70endef # this is the end
     71
     72define simple:=
     73@echo $(FOO)
     74endef
     75
     76define posix::=
     77@echo $(FOO)
     78endef
     79
     80append = @echo a
     81
     82define append+=
     83
     84@echo b
     85endef
     86
     87define cond?= # this is a conditional
     88@echo first
     89endef
     90
     91define cond?=
     92@echo second
     93endef
     94
     95FOO = there
     96
     97all: ; $(multi)
     98        $(simple)
     99        $(posix)
     100        $(append)
     101        $(cond)
     102',
     103              '', "echo hi\nhi\nthere\nfoo\nfoo\na\nb\nfirst\n");
    56104
    57105# TEST 2: define in true section of conditional (containing conditional)
     
    113161all: ; @echo ok
    114162',
    115               '', "#MAKEFILE#:3: extraneous text after `define' directive\nok\n");
     163              '', "#MAKEFILE#:3: extraneous text after 'define' directive\nok\n");
    116164
    117165# TEST 7: NEGATIVE: extra text after endef
     
    124172all: ; @echo ok
    125173',
    126               '', "#MAKEFILE#:5: extraneous text after `endef' directive\nok\n");
     174              '', "#MAKEFILE#:5: extraneous text after 'endef' directive\nok\n");
    127175
    128176# TEST 8: NEGATIVE: missing endef
     
    135183endef$(NAME)
    136184',
    137               '', "#MAKEFILE#:4: *** missing `endef', unterminated `define'.  Stop.\n", 512);
     185              '', "#MAKEFILE#:4: *** missing 'endef', unterminated 'define'.  Stop.\n", 512);
    138186
    139187# -------------------------
  • trunk/src/kmk/tests/scripts/variables/flavors

    r2591 r3140  
    7474              '', "Hello\n");
    7575
     76# TEST 6: Simple using POSIX syntax
     77run_make_test('
     78bar = Goodbye
     79foo ::= $(bar)
     80bar = ${ugh}
     81ugh = Hello
     82all: ; @echo $(foo)
     83',
     84              '', "Goodbye\n");
     85
     86# TEST 7: POSIX syntax no spaces
     87run_make_test('
     88bar = Goodbye
     89foo::=$(bar)
     90bar = ${ugh}
     91ugh = Hello
     92all: ; @echo $(foo)
     93',
     94              '', "Goodbye\n");
     95
    76961;
  • trunk/src/kmk/tests/scripts/variables/private

    r2591 r3140  
    7676               '', "b=a\na=a\n");
    7777
     78# 9: make sure private suppresses inheritance
     79run_make_test(q!
     80DEFS = FOO
     81all: bar1
     82bar1: private DEFS += 1
     83bar3: private DEFS += 3
     84bar1: bar2
     85bar2: bar3
     86bar1 bar2 bar3: ; @echo '$@: $(DEFS)'
     87!,
     88              '', "bar3: FOO 3\nbar2: FOO\nbar1: FOO 1\n");
     89
     90# 10: Test append with pattern-specific variables and private
     91
     92run_make_test(q!
     93IA = global
     94PA = global
     95PS = global
     96S = global
     97PS = global
     98SV = global
     99b%: IA += b%
     100b%: private PA += b%
     101b%: private PS = b%
     102bar: all
     103bar: IA += bar
     104bar: private PA += bar
     105bar: private PS = bar
     106a%: IA += a%
     107a%: private PA += a%
     108a%: private PS = a%
     109all: IA += all
     110all: private PA += all
     111all: private PS = all
     112
     113bar all: ; @echo '$@: IA=$(IA)'; echo '$@: PA=$(PA)'; echo '$@: PS=$(PS)'
     114!,
     115              '', "all: IA=global b% bar a% all
     116all: PA=global a% all
     117all: PS=all
     118bar: IA=global b% bar
     119bar: PA=global b% bar
     120bar: PS=bar\n");
     121
    781221;
  • trunk/src/kmk/tests/scripts/variables/special

    r2000 r3140  
    1515BAR := bar
    1616
    17 all:
    18         @echo X1 = $(X1)
    19         @echo X2 = $(X2)
    20         @echo LAST = $(sort $(filter FOO BAR,$(.VARIABLES)))
     17all: ; @echo X1 = $(X1); echo X2 = $(X2); echo LAST = $(sort $(filter FOO BAR,$(.VARIABLES)))
    2118',
    2219               '', "X1 =\nX2 = FOO\nLAST = BAR FOO\n");
    2320
     21# SV 45728: Test that undefining a variable is reflected properly
    2422
     23&run_make_test('
     24FOO := foo
     25BAR := bar
     26$(info one: $(sort $(filter FOO BAR BAZ,$(.VARIABLES))))
     27undefine BAR
     28BAZ := baz
     29$(info two: $(sort $(filter FOO BAR BAZ,$(.VARIABLES))))
     30all:;@:
     31',
     32               '', "one: BAR FOO\ntwo: BAZ FOO\n");
    2533
    2634# $makefile2 = &get_tmpfile;
     
    3240
    3341# all: foo
    34 #       @echo X1 = $(X1)
    35 #       @echo X2 = $(X2)
    36 #       @echo LAST = $(sort $(.TARGETS))
     42#       @echo X1 = $(X1)
     43#       @echo X2 = $(X2)
     44#       @echo LAST = $(sort $(.TARGETS))
    3745
    3846# X2 := $(sort $(.TARGETS))
     
    5563&run_make_test('
    5664define foo
    57 : foo-one \
     65: foo-one\
    5866foo-two
    5967: foo-three
     
    116124: foo-four');
    117125
     126# Test that the "did you mean TAB" message is printed properly
     127
     128run_make_test(q!
     129$x.
     130!,
     131              '', '#MAKEFILE#:2: *** missing separator.  Stop.', 512);
     132
     133run_make_test(q!
     134foo:
     135        bar
     136!,
     137              '', '#MAKEFILE#:3: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.', 512);
     138
     139run_make_test(q!
     140.RECIPEPREFIX = :
     141foo:
     142        bar
     143!,
     144              '', '#MAKEFILE#:4: *** missing separator.  Stop.', 512);
     145
    1181461;
     147
     148### Local Variables:
     149### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     150### End:
  • trunk/src/kmk/tests/test_driver.pl

    r2591 r3140  
    66# Modified 92-02-11 through 92-02-22 by Chris Arthur to further generalize.
    77#
    8 # Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
    9 # 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    10 # Foundation, Inc.
     8# Copyright (C) 1991-2016 Free Software Foundation, Inc.
    119# This file is part of GNU Make.
    1210#
     
    3129# variables and then calls &toplevel, which does all the real work.
    3230
    33 # $Id: test_driver.pl,v 1.30 2010/07/28 05:39:50 psmith Exp $
     31# $Id$
    3432
    3533
     
    5149$test_passed = 1;
    5250
    53 
    5451# Timeout in seconds.  If the test takes longer than this we'll fail it.
    5552$test_timeout = 5;
     53$test_timeout = 10 if $^O eq 'VMS';
    5654
    5755# Path to Perl
     
    6563%extraENV = ();
    6664
     65sub vms_get_process_logicals {
     66  # Sorry for the long note here, but to keep this test running on
     67  # VMS, it is needed to be understood.
     68  #
     69  # Perl on VMS by default maps the %ENV array to the system wide logical
     70  # name table.
     71  #
     72  # This is a very large dynamically changing table.
     73  # On Linux, this would be the equivalent of a table that contained
     74  # every mount point, temporary pipe, and symbolic link on every
     75  # file system.  You normally do not have permission to clear or replace it,
     76  # and if you did, the results would be catastrophic.
     77  #
     78  # On VMS, added/changed %ENV items show up in the process logical
     79  # name table.  So to track changes, a copy of it needs to be captured.
     80
     81  my $raw_output = `show log/process/access_mode=supervisor`;
     82  my @raw_output_lines = split('\n',$raw_output);
     83  my %log_hash;
     84  foreach my $line (@raw_output_lines) {
     85    if ($line =~ /^\s+"([A-Za-z\$_]+)"\s+=\s+"(.+)"$/) {
     86      $log_hash{$1} = $2;
     87    }
     88  }
     89  return \%log_hash
     90}
     91
    6792# %origENV is the caller's original environment
    68 %origENV = %ENV;
     93if ($^O ne 'VMS') {
     94  %origENV = %ENV;
     95} else {
     96  my $proc_env = vms_get_process_logicals;
     97  %origENV = %{$proc_env};
     98}
    6999
    70100sub resetENV
     
    73103  # through Perl 5.004.  It was fixed in Perl 5.004_01, but we don't
    74104  # want to require that here, so just delete each one individually.
    75   foreach $v (keys %ENV) {
    76     delete $ENV{$v};
    77   }
    78 
    79   %ENV = %makeENV;
     105
     106  if ($^O ne 'VMS') {
     107    foreach $v (keys %ENV) {
     108      delete $ENV{$v};
     109    }
     110
     111    %ENV = %makeENV;
     112  } else {
     113    my $proc_env = vms_get_process_logicals();
     114    my %delta = %{$proc_env};
     115    foreach my $v (keys %delta) {
     116      if (exists $origENV{$v}) {
     117        if ($origENV{$v} ne $delta{$v}) {
     118          $ENV{$v} = $origENV{$v};
     119        }
     120      } else {
     121        delete $ENV{$v};
     122      }
     123    }
     124  }
     125
    80126  foreach $v (keys %extraENV) {
    81127    $ENV{$v} = $extraENV{$v};
     
    90136  foreach (# UNIX-specific things
    91137           'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',
     138           'LD_LIBRARY_PATH',
    92139           # Purify things
    93140           'PURIFYOPTIONS',
     
    107154  # Replace the environment with the new one
    108155  #
    109   %origENV = %ENV;
     156  %origENV = %ENV unless $^O eq 'VMS';
    110157
    111158  resetENV();
     
    135182  &parse_command_line (@ARGV);
    136183
    137   print "OS name = `$osname'\n" if $debug;
     184  print "OS name = '$osname'\n" if $debug;
    138185
    139186  $workpath = "$cwdslash$workdir";
     
    143190
    144191  &print_banner;
     192
     193  if ($osname eq 'VMS' && $cwdslash eq "")
     194  {
     195    # Porting this script to VMS revealed a small bug in opendir() not
     196    # handling search lists correctly when the directory only exists in
     197    # one of the logical_devices.  Need to find the first directory in
     198    # the search list, as that is where things will be written to.
     199    my @dirs = split("/", $pwd);
     200
     201    my $logical_device = $ENV{$dirs[1]};
     202    if ($logical_device =~ /([A-Za-z0-9_]+):(:?.+:)+/)
     203    {
     204        # A search list was found.  Grab the first logical device
     205        # and use it instead of the search list.
     206        $dirs[1]=$1;
     207        my $lcl_pwd = join('/', @dirs);
     208        $workpath = $lcl_pwd . '/' . $workdir
     209    }
     210  }
    145211
    146212  if (-d $workpath)
     
    170236        push (@rmdirs, $dir);
    171237        -d "$workpath/$dir"
    172            || mkdir ("$workpath/$dir", 0777)
     238           || mkdir ("$workpath/$dir", 0777)
    173239           || &error ("Couldn't mkdir $workpath/$dir: $!\n");
    174240      }
     
    179245    print "Finding tests...\n";
    180246    opendir (SCRIPTDIR, $scriptpath)
    181         || &error ("Couldn't opendir $scriptpath: $!\n");
     247        || &error ("Couldn't opendir $scriptpath: $!\n");
    182248    @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR) );
    183249    closedir (SCRIPTDIR);
     
    186252      next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d "$scriptpath/$dir");
    187253      push (@rmdirs, $dir);
     254      # VMS can have overlayed file systems, so directories may repeat.
     255      next if -d "$workpath/$dir";
    188256      mkdir ("$workpath/$dir", 0777)
    189            || &error ("Couldn't mkdir $workpath/$dir: $!\n");
     257          || &error ("Couldn't mkdir $workpath/$dir: $!\n");
    190258      opendir (SCRIPTDIR, "$scriptpath/$dir")
    191           || &error ("Couldn't opendir $scriptpath/$dir: $!\n");
     259          || &error ("Couldn't opendir $scriptpath/$dir: $!\n");
    192260      @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR) );
    193261      closedir (SCRIPTDIR);
     
    195263      {
    196264        -d $test and next;
    197         push (@TESTS, "$dir/$test");
     265        push (@TESTS, "$dir/$test");
    198266      }
    199267    }
     
    207275  print "\n";
    208276
    209   &run_each_test;
     277  run_all_tests();
    210278
    211279  foreach $dir (@rmdirs)
     
    225293    print " in $categories_failed Categor";
    226294    print ($categories_failed == 1 ? "y" : "ies");
    227     print " Failed (See .$diffext files in $workdir dir for details) :-(\n\n";
     295    print " Failed (See .$diffext* files in $workdir dir for details) :-(\n\n";
    228296    return 0;
    229297  }
     
    244312  $osname = defined($^O) ? $^O : '';
    245313
     314  if ($osname eq 'VMS')
     315  {
     316    $vos = 0;
     317    $pathsep = "/";
     318    return;
     319  }
     320
    246321  # Find a path to Perl
    247322
     
    280355    if ($osname =~ /not found/i)
    281356    {
    282         $osname = "(something posixy with no uname)";
     357        $osname = "(something posixy with no uname)";
    283358    }
    284359    elsif ($@ ne "" || $?)
     
    287362        if ($@ ne "" || $?)
    288363        {
    289             $osname = "(something posixy)";
    290         }
     364            $osname = "(something posixy)";
     365        }
    291366    }
    292367    $vos = 0;
     
    441516}
    442517
    443 sub run_each_test
    444 {
    445   $categories_run = 0;
    446 
    447   foreach $testname (sort @TESTS)
    448   {
    449     ++$categories_run;
    450     $suite_passed = 1;       # reset by test on failure
    451     $num_of_logfiles = 0;
    452     $num_of_tmpfiles = 0;
    453     $description = "";
    454     $details = "";
    455     $old_makefile = undef;
    456     $testname =~ s/^$scriptpath$pathsep//;
    457     $perl_testname = "$scriptpath$pathsep$testname";
    458     $testname =~ s/(\.pl|\.perl)$//;
    459     $testpath = "$workpath$pathsep$testname";
    460     # Leave enough space in the extensions to append a number, even
    461     # though it needs to fit into 8+3 limits.
    462     if ($short_filenames) {
    463       $logext = 'l';
    464       $diffext = 'd';
    465       $baseext = 'b';
    466       $runext = 'r';
    467       $extext = '';
    468     } else {
    469       $logext = 'log';
    470       $diffext = 'diff';
    471       $baseext = 'base';
    472       $runext = 'run';
    473       $extext = '.';
    474     }
    475     $log_filename = "$testpath.$logext";
    476     $diff_filename = "$testpath.$diffext";
    477     $base_filename = "$testpath.$baseext";
    478     $run_filename = "$testpath.$runext";
    479     $tmp_filename = "$testpath.$tmpfilesuffix";
    480 
    481     &setup_for_test;          # suite-defined
    482 
    483     $output = "........................................................ ";
    484 
    485     substr($output,0,length($testname)) = "$testname ";
    486 
    487     print $output;
    488 
    489     # Run the actual test!
    490     $tests_run = 0;
    491     $tests_passed = 0;
    492 
    493     $code = do $perl_testname;
    494 
    495     $total_tests_run += $tests_run;
    496     $total_tests_passed += $tests_passed;
    497 
    498     # How did it go?
    499     if (!defined($code))
    500     {
    501       $suite_passed = 0;
    502       if (length ($@)) {
    503         warn "\n*** Test died ($testname): $@\n";
    504       } else {
    505         warn "\n*** Couldn't run $perl_testname\n";
    506       }
    507     }
    508     elsif ($code == -1) {
    509       $suite_passed = 0;
    510     }
    511     elsif ($code != 1 && $code != -1) {
    512       $suite_passed = 0;
    513       warn "\n*** Test returned $code\n";
    514     }
    515 
    516     if ($suite_passed) {
    517       ++$categories_passed;
    518       $status = "ok     ($tests_passed passed)";
    519       for ($i = $num_of_tmpfiles; $i; $i--)
    520       {
    521         &rmfiles ($tmp_filename . &num_suffix ($i) );
    522       }
    523 
    524       for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--)
    525       {
    526         &rmfiles ($log_filename . &num_suffix ($i) );
    527         &rmfiles ($base_filename . &num_suffix ($i) );
    528       }
    529     }
    530     elsif (!defined $code || $code > 0) {
    531       $status = "FAILED ($tests_passed/$tests_run passed)";
    532     }
    533     elsif ($code < 0) {
    534       $status = "N/A";
    535       --$categories_run;
    536     }
    537 
    538     # If the verbose option has been specified, then a short description
    539     # of each test is printed before displaying the results of each test
    540     # describing WHAT is being tested.
    541 
    542     if ($verbose)
    543     {
    544       if ($detail)
    545       {
    546         print "\nWHAT IS BEING TESTED\n";
    547         print "--------------------";
    548       }
    549       print "\n\n$description\n\n";
    550     }
    551 
    552     # If the detail option has been specified, then the details of HOW
    553     # the test is testing what it says it is testing in the verbose output
    554     # will be displayed here before the results of the test are displayed.
    555 
    556     if ($detail)
    557     {
    558       print "\nHOW IT IS TESTED\n";
    559       print "----------------";
    560       print "\n\n$details\n\n";
    561     }
    562 
    563     print "$status\n";
    564   }
     518sub run_all_tests
     519{
     520    $categories_run = 0;
     521
     522    $lasttest = '';
     523    foreach $testname (sort @TESTS) {
     524        # Skip duplicates on VMS caused by logical name search lists.
     525        next if $testname eq $lasttest;
     526        $lasttest = $testname;
     527        $suite_passed = 1;       # reset by test on failure
     528        $num_of_logfiles = 0;
     529        $num_of_tmpfiles = 0;
     530        $description = "";
     531        $details = "";
     532        $old_makefile = undef;
     533        $testname =~ s/^$scriptpath$pathsep//;
     534        $perl_testname = "$scriptpath$pathsep$testname";
     535        $testname =~ s/(\.pl|\.perl)$//;
     536        $testpath = "$workpath$pathsep$testname";
     537        # Leave enough space in the extensions to append a number, even
     538        # though it needs to fit into 8+3 limits.
     539        if ($short_filenames) {
     540            $logext = 'l';
     541            $diffext = 'd';
     542            $baseext = 'b';
     543            $runext = 'r';
     544            $extext = '';
     545        } else {
     546            $logext = 'log';
     547            $diffext = 'diff';
     548            $baseext = 'base';
     549            $runext = 'run';
     550            $extext = '.';
     551        }
     552        $extext = '_' if $^O eq 'VMS';
     553        $log_filename = "$testpath.$logext";
     554        $diff_filename = "$testpath.$diffext";
     555        $base_filename = "$testpath.$baseext";
     556        $run_filename = "$testpath.$runext";
     557        $tmp_filename = "$testpath.$tmpfilesuffix";
     558
     559        setup_for_test();
     560
     561        $output = "........................................................ ";
     562
     563        substr($output,0,length($testname)) = "$testname ";
     564
     565        print $output;
     566
     567        $tests_run = 0;
     568        $tests_passed = 0;
     569
     570        # Run the test!
     571        $code = do $perl_testname;
     572
     573        ++$categories_run;
     574        $total_tests_run += $tests_run;
     575        $total_tests_passed += $tests_passed;
     576
     577        # How did it go?
     578        if (!defined($code)) {
     579            # Failed to parse or called die
     580            if (length ($@)) {
     581                warn "\n*** Test died ($testname): $@\n";
     582            } else {
     583                warn "\n*** Couldn't parse $perl_testname\n";
     584            }
     585            $status = "FAILED ($tests_passed/$tests_run passed)";
     586        }
     587
     588        elsif ($code == -1) {
     589            # Skipped... not supported
     590            $status = "N/A";
     591            --$categories_run;
     592        }
     593
     594        elsif ($code != 1) {
     595            # Bad result... this shouldn't really happen.  Usually means that
     596            # the suite forgot to end with "1;".
     597            warn "\n*** Test returned $code\n";
     598            $status = "FAILED ($tests_passed/$tests_run passed)";
     599        }
     600
     601        elsif ($tests_run == 0) {
     602            # Nothing was done!!
     603            $status = "FAILED (no tests found!)";
     604        }
     605
     606        elsif ($tests_run > $tests_passed) {
     607            # Lose!
     608            $status = "FAILED ($tests_passed/$tests_run passed)";
     609        }
     610
     611        else {
     612            # Win!
     613            ++$categories_passed;
     614            $status = "ok     ($tests_passed passed)";
     615
     616            # Clean up
     617            for ($i = $num_of_tmpfiles; $i; $i--) {
     618                rmfiles($tmp_filename . num_suffix($i));
     619            }
     620            for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--) {
     621                rmfiles($log_filename . num_suffix($i));
     622                rmfiles($base_filename . num_suffix($i));
     623            }
     624        }
     625
     626        # If the verbose option has been specified, then a short description
     627        # of each test is printed before displaying the results of each test
     628        # describing WHAT is being tested.
     629
     630        if ($verbose) {
     631            if ($detail) {
     632                print "\nWHAT IS BEING TESTED\n";
     633                print "--------------------";
     634            }
     635            print "\n\n$description\n\n";
     636        }
     637
     638        # If the detail option has been specified, then the details of HOW
     639        # the test is testing what it says it is testing in the verbose output
     640        # will be displayed here before the results of the test are displayed.
     641
     642        if ($detail) {
     643            print "\nHOW IT IS TESTED\n";
     644            print "----------------";
     645            print "\n\n$details\n\n";
     646        }
     647
     648        print "$status\n";
     649    }
    565650}
    566651
     
    679764  local($slurp, $answer_matched) = ('', 0);
    680765
    681   print "Comparing Output ........ " if $debug;
    682 
    683   $slurp = &read_file_into_string ($logfile);
    684 
    685   # For make, get rid of any time skew error before comparing--too bad this
    686   # has to go into the "generic" driver code :-/
    687   $slurp =~ s/^.*modification time .*in the future.*\n//gm;
    688   $slurp =~ s/^.*Clock skew detected.*\n//gm;
    689 
    690766  ++$tests_run;
    691767
    692   if ($slurp eq $answer) {
    693     $answer_matched = 1;
     768  if (! defined $answer) {
     769      print "Ignoring output ........ " if $debug;
     770      $answer_matched = 1;
    694771  } else {
    695     # See if it is a slash or CRLF problem
    696     local ($answer_mod, $slurp_mod) = ($answer, $slurp);
    697 
    698     $answer_mod =~ tr,\\,/,;
    699     $answer_mod =~ s,\r\n,\n,gs;
    700 
    701     $slurp_mod =~ tr,\\,/,;
    702     $slurp_mod =~ s,\r\n,\n,gs;
    703 
    704     $answer_matched = ($slurp_mod eq $answer_mod);
    705 
    706     # If it still doesn't match, see if the answer might be a regex.
    707     if (!$answer_matched && $answer =~ m,^/(.+)/$,) {
    708       $answer_matched = ($slurp =~ /$1/);
    709       if (!$answer_matched && $answer_mod =~ m,^/(.+)/$,) {
    710           $answer_matched = ($slurp_mod =~ /$1/);
     772      print "Comparing Output ........ " if $debug;
     773
     774      $slurp = &read_file_into_string ($logfile);
     775
     776      # For make, get rid of any time skew error before comparing--too bad this
     777      # has to go into the "generic" driver code :-/
     778      $slurp =~ s/^.*modification time .*in the future.*\n//gm;
     779      $slurp =~ s/^.*Clock skew detected.*\n//gm;
     780
     781      if ($slurp eq $answer) {
     782          $answer_matched = 1;
     783      } else {
     784          # See if it is a slash or CRLF problem
     785          local ($answer_mod, $slurp_mod) = ($answer, $slurp);
     786
     787          $answer_mod =~ tr,\\,/,;
     788          $answer_mod =~ s,\r\n,\n,gs;
     789
     790          $slurp_mod =~ tr,\\,/,;
     791          $slurp_mod =~ s,\r\n,\n,gs;
     792
     793          $answer_matched = ($slurp_mod eq $answer_mod);
     794          if ($^O eq 'VMS') {
     795
     796            # VMS has extra blank lines in output sometimes.
     797            # Ticket #41760
     798            if (!$answer_matched) {
     799              $slurp_mod =~ s/\n\n+/\n/gm;
     800              $slurp_mod =~ s/\A\n+//g;
     801              $answer_matched = ($slurp_mod eq $answer_mod);
     802            }
     803
     804            # VMS adding a "Waiting for unfinished jobs..."
     805            # Remove it for now to see what else is going on.
     806            if (!$answer_matched) {
     807              $slurp_mod =~ s/^.+\*\*\* Waiting for unfinished jobs.+$//m;
     808              $slurp_mod =~ s/\n\n/\n/gm;
     809              $slurp_mod =~ s/^\n+//gm;
     810              $answer_matched = ($slurp_mod eq $answer_mod);
     811            }
     812
     813            # VMS wants target device to exist or generates an error,
     814            # Some test tagets look like VMS devices and trip this.
     815            if (!$answer_matched) {
     816              $slurp_mod =~ s/^.+\: no such device or address.*$//gim;
     817              $slurp_mod =~ s/\n\n/\n/gm;
     818              $slurp_mod =~ s/^\n+//gm;
     819              $answer_matched = ($slurp_mod eq $answer_mod);
     820            }
     821
     822            # VMS error message has a different case
     823            if (!$answer_matched) {
     824              $slurp_mod =~ s/no such file /No such file /gm;
     825              $answer_matched = ($slurp_mod eq $answer_mod);
     826            }
     827
     828            # VMS is putting comas instead of spaces in output
     829            if (!$answer_matched) {
     830              $slurp_mod =~ s/,/ /gm;
     831              $answer_matched = ($slurp_mod eq $answer_mod);
     832            }
     833
     834            # VMS Is sometimes adding extra leading spaces to output?
     835            if (!$answer_matched) {
     836               my $slurp_mod = $slurp_mod;
     837               $slurp_mod =~ s/^ +//gm;
     838               $answer_matched = ($slurp_mod eq $answer_mod);
     839            }
     840
     841            # VMS port not handling POSIX encoded child status
     842            # Translate error case it for now.
     843            if (!$answer_matched) {
     844              $slurp_mod =~ s/0x1035a00a/1/gim;
     845              $answer_matched = 1 if $slurp_mod =~ /\Q$answer_mod\E/i;
     846
     847            }
     848            if (!$answer_matched) {
     849              $slurp_mod =~ s/0x1035a012/2/gim;
     850              $answer_matched = ($slurp_mod eq $answer_mod);
     851            }
     852
     853            # Tests are using a UNIX null command, temp hack
     854            # until this can be handled by the VMS port.
     855            # ticket # 41761
     856            if (!$answer_matched) {
     857              $slurp_mod =~ s/^.+DCL-W-NOCOMD.*$//gim;
     858              $slurp_mod =~ s/\n\n+/\n/gm;
     859              $slurp_mod =~ s/^\n+//gm;
     860              $answer_matched = ($slurp_mod eq $answer_mod);
     861            }
     862            # Tests are using exit 0;
     863            # this generates a warning that should stop the make, but does not
     864            if (!$answer_matched) {
     865              $slurp_mod =~ s/^.+NONAME-W-NOMSG.*$//gim;
     866              $slurp_mod =~ s/\n\n+/\n/gm;
     867              $slurp_mod =~ s/^\n+//gm;
     868              $answer_matched = ($slurp_mod eq $answer_mod);
     869            }
     870
     871            # VMS is sometimes adding single quotes to output?
     872            if (!$answer_matched) {
     873              my $noq_slurp_mod = $slurp_mod;
     874              $noq_slurp_mod =~ s/\'//gm;
     875              $answer_matched = ($noq_slurp_mod eq $answer_mod);
     876
     877              # And missing an extra space in output
     878              if (!$answer_matched) {
     879                $noq_answer_mod = $answer_mod;
     880                $noq_answer_mod =~ s/\h\h+/ /gm;
     881                $answer_matched = ($noq_slurp_mod eq $noq_answer_mod);
     882              }
     883
     884              # VMS adding ; to end of some lines.
     885              if (!$answer_matched) {
     886                $noq_slurp_mod =~ s/;\n/\n/gm;
     887                $answer_matched = ($noq_slurp_mod eq $noq_answer_mod);
     888              }
     889
     890              # VMS adding trailing space to end of some quoted lines.
     891              if (!$answer_matched) {
     892                $noq_slurp_mod =~ s/\h+\n/\n/gm;
     893                $answer_matched = ($noq_slurp_mod eq $noq_answer_mod);
     894              }
     895
     896              # And VMS missing leading blank line
     897              if (!$answer_matched) {
     898                $noq_answer_mod =~ s/\A\n//g;
     899                $answer_matched = ($noq_slurp_mod eq $noq_answer_mod);
     900              }
     901
     902              # Unix double quotes showing up as single quotes on VMS.
     903              if (!$answer_matched) {
     904                $noq_answer_mod =~ s/\"//g;
     905                $answer_matched = ($noq_slurp_mod eq $noq_answer_mod);
     906              }
     907            }
     908          }
     909
     910          # If it still doesn't match, see if the answer might be a regex.
     911          if (!$answer_matched && $answer =~ m,^/(.+)/$,) {
     912              $answer_matched = ($slurp =~ /$1/);
     913              if (!$answer_matched && $answer_mod =~ m,^/(.+)/$,) {
     914                  $answer_matched = ($slurp_mod =~ /$1/);
     915              }
     916          }
    711917      }
    712     }
    713918  }
    714919
     
    732937    local($command) = "diff -c " . &get_basefile . " " . $logfile;
    733938    &run_command_with_output(&get_difffile,$command);
    734   } else {
    735       &rmfiles ();
    736   }
    737 
    738   $suite_passed = 0;
     939  }
     940
    739941  return 0;
    740942}
     
    756958}
    757959
     960my @OUTSTACK = ();
     961my @ERRSTACK = ();
     962
    758963sub attach_default_output
    759964{
     
    768973  }
    769974
    770   open ("SAVEDOS" . $default_output_stack_level . "out", ">&STDOUT")
    771         || &error ("ado: $! duping STDOUT\n", 1);
    772   open ("SAVEDOS" . $default_output_stack_level . "err", ">&STDERR")
    773         || &error ("ado: $! duping STDERR\n", 1);
    774 
    775   open (STDOUT, "> " . $filename)
    776         || &error ("ado: $filename: $!\n", 1);
    777   open (STDERR, ">&STDOUT")
    778         || &error ("ado: $filename: $!\n", 1);
    779 
    780   $default_output_stack_level++;
     975  my $dup = undef;
     976  open($dup, '>&', STDOUT) or error("ado: $! duping STDOUT\n", 1);
     977  push @OUTSTACK, $dup;
     978
     979  $dup = undef;
     980  open($dup, '>&', STDERR) or error("ado: $! duping STDERR\n", 1);
     981  push @ERRSTACK, $dup;
     982
     983  open(STDOUT, '>', $filename) or error("ado: $filename: $!\n", 1);
     984  open(STDERR, ">&STDOUT") or error("ado: $filename: $!\n", 1);
    781985}
    782986
     
    795999  }
    7961000
    797   if (--$default_output_stack_level < 0)
    798   {
    799     &error ("default output stack has flown under!\n", 1);
    800   }
    801 
    802   close (STDOUT);
    803   close (STDERR);
    804 
    805   open (STDOUT, ">&SAVEDOS" . $default_output_stack_level . "out")
    806         || &error ("ddo: $! duping STDOUT\n", 1);
    807   open (STDERR, ">&SAVEDOS" . $default_output_stack_level . "err")
    808         || &error ("ddo: $! duping STDERR\n", 1);
    809 
    810   close ("SAVEDOS" . $default_output_stack_level . "out")
    811         || &error ("ddo: $! closing SCSDOSout\n", 1);
    812   close ("SAVEDOS" . $default_output_stack_level . "err")
    813          || &error ("ddo: $! closing SAVEDOSerr\n", 1);
     1001  @OUTSTACK or error("default output stack has flown under!\n", 1);
     1002
     1003  close(STDOUT);
     1004  close(STDERR) unless $^O eq 'VMS';
     1005
     1006
     1007  open (STDOUT, '>&', pop @OUTSTACK) or error("ddo: $! duping STDOUT\n", 1);
     1008  open (STDERR, '>&', pop @ERRSTACK) or error("ddo: $! duping STDERR\n", 1);
    8141009}
    8151010
     
    8251020
    8261021  eval {
    827       local $SIG{ALRM} = sub { die "timeout\n"; };
    828       alarm $test_timeout;
    829       $code = system(@_);
     1022      if ($^O eq 'VMS') {
     1023          local $SIG{ALRM} = sub {
     1024              my $e = $ERRSTACK[0];
     1025              print $e "\nTest timed out after $test_timeout seconds\n";
     1026              die "timeout\n"; };
     1027#          alarm $test_timeout;
     1028          system(@_);
     1029          my $severity = ${^CHILD_ERROR_NATIVE} & 7;
     1030          $code = 0;
     1031          if (($severity & 1) == 0) {
     1032              $code = 512;
     1033          }
     1034
     1035          # Get the vms status.
     1036          my $vms_code = ${^CHILD_ERROR_NATIVE};
     1037
     1038          # Remove the print status bit
     1039          $vms_code &= ~0x10000000;
     1040
     1041          # Posix code translation.
     1042          if (($vms_code & 0xFFFFF000) == 0x35a000) {
     1043              $code = (($vms_code & 0xFFF) >> 3) * 256;
     1044          }
     1045      } else {
     1046          my $pid = fork();
     1047          if (! $pid) {
     1048              exec(@_) or die "Cannot execute $_[0]\n";
     1049          }
     1050          local $SIG{ALRM} = sub { my $e = $ERRSTACK[0]; print $e "\nTest timed out after $test_timeout seconds\n"; die "timeout\n"; };
     1051          alarm $test_timeout;
     1052          waitpid($pid, 0) > 0 or die "No such pid: $pid\n";
     1053          $code = $?;
     1054      }
    8301055      alarm 0;
    8311056  };
    8321057  if ($@) {
    8331058      # The eval failed.  If it wasn't SIGALRM then die.
    834       $@ eq "timeout\n" or die;
     1059      $@ eq "timeout\n" or die "Command failed: $@";
    8351060
    8361061      # Timed out.  Resend the alarm to our process group to kill the children.
     
    8511076  my $code = _run_command(@_);
    8521077  print "run_command returned $code.\n" if $debug;
    853 
     1078  print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $^O eq 'VMS';
    8541079  return $code;
    8551080}
     
    8661091  print "\nrun_command_with_output($filename,$runname): @_\n" if $debug;
    8671092  &attach_default_output ($filename);
    868   my $code = _run_command(@_);
     1093  my $code = eval { _run_command(@_) };
     1094  my $err = $@;
    8691095  &detach_default_output;
     1096
     1097  $err and die $err;
     1098
    8701099  print "run_command_with_output returned $code.\n" if $debug;
    871 
     1100  print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $^O eq 'VMS';
    8721101  return $code;
    8731102}
     
    9291158    else
    9301159    {
    931       unlink $object || return 0;
     1160      if ($^O ne 'VMS')
     1161      {
     1162        unlink $object || return 0;
     1163      }
     1164      else
     1165      {
     1166        # VMS can have multiple versions of a file.
     1167        1 while unlink $object;
     1168      }
    9321169    }
    9331170  }
     
    9671204  foreach $file (@_) {
    9681205    (open(T, ">> $file") && print(T "\n") && close(T))
    969         || &error("Couldn't touch $file: $!\n", 1);
     1206        || &error("Couldn't touch $file: $!\n", 1);
    9701207  }
    9711208}
Note: See TracChangeset for help on using the changeset viewer.