Date: Sun, 22 Aug 1999 10:41:13 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: "Paul D. Smith" cc: Esa A E Peuha , Laszlo Molnar , djgpp-workers AT delorie DOT com Subject: Re: Make 3.78 is in pretest (fwd) In-Reply-To: <14266.61356.636908.533905@baynetworks.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Wed, 18 Aug 1999, Paul D. Smith wrote: > %% Eli Zaretskii writes: > > ez> These are patches sent by Esa to which I referred in my message. > ez> I see a new version of the test suite is out; I will get it and see > ez> whether it solves some of the problems (or adds new ones ;-). > > At least some of them are solved, I know, by Rob's NT changes (the > case-insensitive Makefile vs. makefile, for example, and some others). Okay, I tried the new test suite with the DJGPP Make. The patches necessary to make it work are attached below; they also incorporate patches sent earlier by Esa Peuha (to which I added a few comments). These leave one problem unsolved: what to do with features/parallelism that cannot work in the DJGPP version. Paul, do you have any suggestions how to handle this without causing the tester wonder whether Make is broken? In addition, I have several mysteries to ask about, probably because I don't know too much about Perl. They are all connected to the following fragment from test_driver.pl: sub toplevel { # clean out the environment $p = $ENV{"PATH"}; $h = $ENV{"HOME"}; $u = $ENV{"PURIFYOPTIONS"}; # NT specific stuff $pnt = $ENV{"Path"}; $sr = $ENV{"SystemRoot"}; foreach $k (keys %ENV) { delete $ENV{$k}; } %ENV = ( "HOME", $h, "PATH", $p, "Path", $pnt, "SystemRoot", $sr); First, if I leave the last line as shown, most of the tests fail, as far as I understand because PATH is either empty or undefined, so none of the programs invoked by the scripts and Makefile's are found. If I replace the last line with this one: %ENV = ( "HOME", $h, "PATH", $p); then everything works. It seems like the value of $Path (which isn't defined on MSDOS) somehow causes $PATH to be emptied. Laszlo, can it be that environment variables are compared case-insensitively somewhere in Perl? If so, this is a bug. The other question I have about this is why does the script remove all the variables from the environment? This undefines some crucial variables like SHELL and COMSPEC, which are important for correct operation of Make. For example, if echo.exe is not installed, almost all tests fail because "echo" is not found, although it is an internal command in both Bash and COMMAND.COM: Make cannot run "echo" because it needs to find the shell to invoke for this, and it looks for the shell using $SHELL and $COMSPEC. If the script relies on the default "/bin/sh" to come to the rescue, then this doesn't work on DOS/Windows, where we cannot rely on /bin being available. Other environment variables, like $DJDIR, $USER, $HOST, and probably some more, are also important for smooth operation of various DJGPP utilities and library functions. I can be sure that if these are undefined, something will sooner or later break. Can somebody suggest a way out of this predicament? Is it possible to not empty the environment at all? Here are the patches I needed to run the test suite. First, a patch for Make itself: 1999-08-16 Eli Zaretskii * main.c (main) [__MSDOS__]: Mirror any backslashes in argv[0], to avoid problems in shell commands that use backslashes as escape characters. *** main.c~0 Sun Aug 1 10:43:46 1999 --- main.c Mon Aug 16 20:33:32 1999 *************** int main (int argc, char ** argv) *** 944,950 **** if (print_version_flag) die (0); ! #if !defined(__MSDOS__) && !defined(VMS) /* Set the "MAKE_COMMAND" variable to the name we were invoked with. (If it is a relative pathname with a slash, prepend our directory name so the result will run the same program regardless of the current dir. --- 944,950 ---- if (print_version_flag) die (0); ! #ifndef VMS /* Set the "MAKE_COMMAND" variable to the name we were invoked with. (If it is a relative pathname with a slash, prepend our directory name so the result will run the same program regardless of the current dir. *************** int main (int argc, char ** argv) *** 962,970 **** --- 962,982 ---- strneq(argv[0], "//", 2)) argv[0] = xstrdup(w32ify(argv[0],1)); #else /* WINDOWS32 */ + #ifdef __MSDOS__ + if (strchr (argv[0], '\\')) + { + char *p; + + argv[0] = xstrdup (argv[0]); + for (p = argv[0]; *p; p++) + if (*p == '\\') + *p = '/'; + } + #else /* !__MSDOS__ */ if (current_directory[0] != '\0' && argv[0] != 0 && argv[0][0] != '/' && index (argv[0], '/') != 0) argv[0] = concat (current_directory, "/", argv[0]); + #endif /* !__MSDOS__ */ #endif /* WINDOWS32 */ #endif Now the patches for the scripts: *** run_make_tests.p~0 Fri Aug 13 07:45:56 1999 --- run_make_tests.pl Thu Aug 19 20:18:30 1999 *************** *** 122,127 **** --- 122,144 ---- $make_path = "make"; $tmpfilesuffix = "mk"; $pwd = &get_this_pwd; + + # Find the full pathname of Make. + open(MAKEFILE,"> makefile.tmp"); + print MAKEFILE "all:\n" + . "\t\@echo \$(MAKE)\n"; + close(MAKEFILE); + &attach_default_output ("makepath.tmp"); + $code = system "$make_path -f makefile.tmp"; + &detach_default_output; + $make_path = &read_file_into_string ("makepath.tmp"); + $index = index ($make_path, "\n"); + if ($index > 0) + { + $make_path = substr ($make_path, 0, $index); + } + unlink ("makepath.tmp"); + unlink ("makefile.tmp"); } sub set_more_defaults *************** *** 138,150 **** } $testee_version = $string; ! if ($make_path =~ /$pathsep([^\n$pathsep]*)$/) { ! $make_name = $1; } else { ! $make_name = $make_path; } # prepend pwd if this is a relative path (ie, does not --- 155,180 ---- } $testee_version = $string; ! &attach_default_output ("makename.tmp"); ! $code = system "$make_path -f /dev/null"; ! &detach_default_output; ! $string = &read_file_into_string ("makename.tmp"); ! unlink ("makename.tmp"); ! $index = index ($string, ": *** No targets. Stop."); ! if ($index > 0) { ! $make_name = substr ($string, 0, $index); } else { ! if ($make_path =~ /$pathsep([^\n$pathsep]*)$/) ! { ! $make_name = $1; ! } ! else ! { ! $make_name = $make_path; ! } } # prepend pwd if this is a relative path (ie, does not *** test_driver.p~0 Fri Aug 13 07:42:02 1999 --- test_driver.pl Thu Aug 19 17:49:14 1999 *************** *** 36,48 **** $keep = 0; # keep temp files around $workdir = "work"; # The directory where the test will start running $scriptdir = "scripts"; # The directory where we find the test scripts - $tmpfilesuffix = "tmp"; # the suffix used on tmpfiles $default_output_stack_level = 0; # used by attach_default_output, etc. $default_input_stack_level = 0; # used by attach_default_input, etc. $cwd = "."; # don't we wish we knew $cwdslash = ""; # $cwd . $pathsep, but "" rather than "./" ! &get_osname; # sets $osname, $vos, and $pathsep &set_defaults; # suite-defined --- 37,57 ---- $keep = 0; # keep temp files around $workdir = "work"; # The directory where the test will start running $scriptdir = "scripts"; # The directory where we find the test scripts $default_output_stack_level = 0; # used by attach_default_output, etc. $default_input_stack_level = 0; # used by attach_default_input, etc. $cwd = "."; # don't we wish we knew $cwdslash = ""; # $cwd . $pathsep, but "" rather than "./" ! &get_osname; # sets $osname, $vos, $pathsep, and $fancy_file_names ! ! if ($fancy_file_names) ! { ! $tmpfilesuffix = "tmp"; # the suffix used on tmpfiles ! } ! else ! { ! $tmpfilesuffix = "t"; ! } &set_defaults; # suite-defined *************** *** 151,168 **** # $osname = defined($^O) ? $^O : ''; ! # Thanks go to meyering AT cs DOT utexas DOT edu (Jim Meyering) for suggesting a ! # better way of doing this. (We used to test for existence of a /mnt ! # dir, but that apparently fails on an SGI Indigo (whatever that is).) ! # Because perl on VOS translates /'s to >'s, we need to test for ! # VOSness rather than testing for Unixness (ie, try > instead of /). ! ! mkdir (".ostest", 0777) || &error ("Couldn't create .ostest: $!\n", 1); ! (open (TOUCHFD, "> .ostest>ick") && close (TOUCHFD)) ! || print "Couldn't touch .ostest>ick: $!\n"; ! chdir (".ostest") || &error ("Couldn't chdir to .ostest: $!\n", 1); ! if (-f "ick") { $osname = "vos"; $vos = 1; --- 160,187 ---- # $osname = defined($^O) ? $^O : ''; ! # See if the filesystem supports long file names with multiple ! # dots. DOS doesn't. ! $fancy_file_names = 1; ! (open (TOUCHFD, "> fancy.file.name") && close (TOUCHFD)) ! || ($fancy_file_names = 0); ! unlink ("fancy.file.name") || ($fancy_file_names = 0); ! ! if ($fancy_file_names) ! { ! # Thanks go to meyering AT cs DOT utexas DOT edu (Jim Meyering) for suggesting a ! # better way of doing this. (We used to test for existence of a /mnt ! # dir, but that apparently fails on an SGI Indigo (whatever that is).) ! # Because perl on VOS translates /'s to >'s, we need to test for ! # VOSness rather than testing for Unixness (ie, try > instead of /). ! ! mkdir (".ostest", 0777) || &error ("Couldn't create .ostest: $!\n", 1); ! (open (TOUCHFD, "> .ostest>ick") && close (TOUCHFD)) ! || print "Couldn't touch .ostest>ick: $!\n"; ! chdir (".ostest") || &error ("Couldn't chdir to .ostest: $!\n", 1); ! } ! if ($fancy_file_names && -f "ick") { $osname = "vos"; $vos = 1; *************** *** 174,187 **** # to not get ugly error messages if uname can't be found. # Hmmm, BSD/OS 2.0's uname -a is excessively verbose. Let's try it # with switches first. ! eval "chop (\$osname = `sh -c 'uname -nmsr' 2>&1`)"; if ($osname =~ /not found/i) { $osname = "(something unixy with no uname)"; } elsif ($@ ne "" || $?) { ! eval "chop (\$osname = `sh -c 'uname -a' 2>&1`)"; if ($@ ne "" || $?) { $osname = "(something unixy)"; --- 193,206 ---- # to not get ugly error messages if uname can't be found. # Hmmm, BSD/OS 2.0's uname -a is excessively verbose. Let's try it # with switches first. ! eval "chop (\$osname = `sh -c 'uname -nmsr 2>&1'`)"; if ($osname =~ /not found/i) { $osname = "(something unixy with no uname)"; } elsif ($@ ne "" || $?) { ! eval "chop (\$osname = `sh -c 'uname -a 2>&1'`)"; if ($@ ne "" || $?) { $osname = "(something unixy)"; *************** *** 191,199 **** $pathsep = "/"; } ! chdir ("..") || &error ("Couldn't chdir to ..: $!\n", 1); ! unlink (".ostest>ick"); ! rmdir (".ostest") || &error ("Couldn't rmdir .ostest: $!\n", 1); } sub parse_command_line --- 210,221 ---- $pathsep = "/"; } ! if ($fancy_file_names) ! { ! chdir ("..") || &error ("Couldn't chdir to ..: $!\n", 1); ! unlink (".ostest>ick"); ! rmdir (".ostest") || &error ("Couldn't rmdir .ostest: $!\n", 1); ! } } sub parse_command_line *************** *** 331,339 **** $perl_testname = "$scriptpath$pathsep$testname"; $testname =~ s/(\.pl|\.perl)$//; $testpath = "$workpath$pathsep$testname"; ! $log_filename = "$testpath.log"; ! $diff_filename = "$testpath.diff"; ! $base_filename = "$testpath.base"; $tmp_filename = "$testpath.$tmpfilesuffix"; &setup_for_test; # suite-defined --- 353,372 ---- $perl_testname = "$scriptpath$pathsep$testname"; $testname =~ s/(\.pl|\.perl)$//; $testpath = "$workpath$pathsep$testname"; ! if ($fancy_file_names) ! { ! $log_filename = "$testpath.log"; ! $diff_filename = "$testpath.diff"; ! $base_filename = "$testpath.base"; ! } ! # Leave enough space in the extensions to append a number, even ! # though it needs to fit into 8+3 limits. ! else ! { ! $log_filename = "$testpath.l"; ! $diff_filename = "$testpath.d"; ! $base_filename = "$testpath.b"; ! } $tmp_filename = "$testpath.$tmpfilesuffix"; &setup_for_test; # suite-defined *************** *** 973,979 **** if (--$num > 0) { ! return ".$num"; } return ""; --- 1006,1020 ---- if (--$num > 0) { ! if ($fancy_file_names) ! { ! return ".$num"; ! } ! # Cannot have more than a single dot in a file name... ! else ! { ! return "$num"; ! } } return ""; *** scripts/features/default_names.~0~ Fri Aug 13 07:54:30 1999 --- scripts/features/default_names Thu Aug 19 16:39:12 1999 *************** *** 10,19 **** close(MAKEFILE); ! # WIN32 platforms preserve case, but Makefile is the same file as makefile. # Just test what we can here (avoid Makefile versus makefile test). # ! if ($osname !~ /Windows/i) { # Create another makefile called "makefile" open(MAKEFILE,"> makefile"); --- 10,20 ---- close(MAKEFILE); ! # DOS/WIN32 platforms are case-insensitive, so Makefile is the same file ! # as makefile. # Just test what we can here (avoid Makefile versus makefile test). # ! if ($osname !~ /Windows/i && $osname !~ /DOS/i) { # Create another makefile called "makefile" open(MAKEFILE,"> makefile"); *************** *** 43,52 **** unlink $makefile; # ! # WIN32 platforms preserve case, but Makefile is the same file as makefile. # Just test what we can here (avoid Makefile versus makefile test). # ! if ($osname !~ /Windows/i) { $answer = "It chose makefile\n"; --- 44,53 ---- unlink $makefile; # ! # DOS/WIN32 platforms ignore case, so Makefile is the same file as makefile. # Just test what we can here (avoid Makefile versus makefile test). # ! if ($osname !~ /Windows/i && $osname !~ /DOS/i) { $answer = "It chose makefile\n"; *** scripts/features/echoing.~0~ Sun Apr 30 09:56:50 1995 --- scripts/features/echoing Thu Aug 19 19:41:48 1999 *************** *** 31,37 **** # The Contents of the MAKEFILE ... print MAKEFILE "all: \n"; ! print MAKEFILE "\techo This makefile did not clean the dir ... good\n"; print MAKEFILE "clean: \n"; print MAKEFILE "\t\@$delete_command $example\n"; --- 31,37 ---- # The Contents of the MAKEFILE ... print MAKEFILE "all: \n"; ! print MAKEFILE "\techo This makefile did not clean the dir... good\n"; print MAKEFILE "clean: \n"; print MAKEFILE "\t\@$delete_command $example\n"; *************** *** 45,52 **** # ------- &run_make_with_options($makefile,"",&get_logfile,0); ! $answer = "echo This makefile did not clean the dir ... good\n" ! ."This makefile did not clean the dir ... good\n"; &compare_output($answer,&get_logfile(1)); --- 45,52 ---- # ------- &run_make_with_options($makefile,"",&get_logfile,0); ! $answer = "echo This makefile did not clean the dir... good\n" ! ."This makefile did not clean the dir... good\n"; &compare_output($answer,&get_logfile(1)); *************** *** 74,80 **** # ------- &run_make_with_options($makefile,"-s",&get_logfile,0); ! $answer = "This makefile did not clean the dir ... good\n"; &compare_output($answer,&get_logfile(1)); --- 74,80 ---- # ------- &run_make_with_options($makefile,"-s",&get_logfile,0); ! $answer = "This makefile did not clean the dir... good\n"; &compare_output($answer,&get_logfile(1)); *** scripts/features/errors.~0~ Sun Apr 30 09:49:42 1995 --- scripts/features/errors Thu Aug 19 19:43:02 1999 *************** *** 39,45 **** &touch("foo"); unlink("cleanit"); ! $cleanit_error = `$delete_command cleanit 2>&1`; $delete_error_code = $? >> 8; # TEST #1 --- 39,45 ---- &touch("foo"); unlink("cleanit"); ! $cleanit_error = `sh -c "$delete_command cleanit 2>&1"`; $delete_error_code = $? >> 8; # TEST #1 *** scripts/features/quoting.~0~ Tue Aug 26 17:47:26 1997 --- scripts/features/quoting Thu Aug 19 16:42:34 1999 *************** *** 5,10 **** --- 5,11 ---- # The Contents of the MAKEFILE ... + print MAKEFILE "SHELL = /bin/sh\n"; print MAKEFILE "TEXFONTS = NICEFONT\n"; print MAKEFILE "DEFINES = -DDEFAULT_TFM_PATH=\\\".:\$(TEXFONTS)\\\"\n"; print MAKEFILE "test:\n"; *** scripts/features/reinvoke.~0~ Wed Aug 13 18:51:38 1997 --- scripts/features/reinvoke Thu Aug 19 16:44:32 1999 *************** *** 11,23 **** # EXAMPLE: $makefile2 = &get_tmpfile; $makefile2 = &get_tmpfile; open(MAKEFILE,"> $makefile"); print MAKEFILE " all: \@echo 'running rules.' ! $makefile $makefile2: $makefile.orig \@echo 'rebuilding \$\@.' \@touch \$\@ --- 11,24 ---- # EXAMPLE: $makefile2 = &get_tmpfile; $makefile2 = &get_tmpfile; + $makefile_orig = &get_tmpfile; open(MAKEFILE,"> $makefile"); print MAKEFILE " all: \@echo 'running rules.' ! $makefile $makefile2: $makefile_orig \@echo 'rebuilding \$\@.' \@touch \$\@ *************** *** 28,36 **** &touch("$makefile2"); ! sleep(1); ! &touch("$makefile.orig"); &run_make_with_options($makefile, "", --- 29,39 ---- &touch("$makefile2"); ! # Sleep 2 seconds for DOS/Windows FAT volumes which have 2-second ! # granularity of file times. ! sleep(2); ! &touch("$makefile_orig"); &run_make_with_options($makefile, "", *************** *** 42,48 **** $answer = "rebuilding $makefile2.\nrebuilding $makefile.\nrunning rules.\n"; &compare_output($answer,&get_logfile(1)) ! && unlink "$makefile.orig"; # This tells the test driver that the perl test script executed properly. 1; --- 45,51 ---- $answer = "rebuilding $makefile2.\nrebuilding $makefile.\nrunning rules.\n"; &compare_output($answer,&get_logfile(1)) ! && unlink "$makefile_orig"; # This tells the test driver that the perl test script executed properly. 1; *** scripts/features/targetvars.~0~ Tue Apr 14 06:43:20 1998 --- scripts/features/targetvars Thu Aug 19 16:45:26 1999 *************** *** 9,14 **** --- 9,15 ---- open(MAKEFILE,"> $makefile"); print MAKEFILE <<'EOF'; + SHELL = /bin/sh export FOO = foo export BAR = bar one: override FOO = one *** scripts/features/vpathplus.~0~ Tue Jul 20 19:32:54 1999 --- scripts/features/vpathplus Thu Aug 19 16:46:40 1999 *************** *** 13,18 **** --- 13,19 ---- print MAKEFILE <<'EOMAKE'; + SHELL = /bin/sh .SUFFIXES: .a .b .c .d .PHONY: general rename notarget intermediate *************** *** 53,64 **** @touchedfiles = (); sub touchfiles { foreach (@_) { ($f = $_) =~ s,VP/,$VP,g; &touch($f); push(@touchedfiles, $f); ! sleep 1; } } --- 54,67 ---- @touchedfiles = (); + # Sleep 2 seconds for DOS/Windows FAT volumes which have 2-second + # granularity of file times. sub touchfiles { foreach (@_) { ($f = $_) =~ s,VP/,$VP,g; &touch($f); push(@touchedfiles, $f); ! sleep 2; } } *** scripts/functions/wildcard.~0~ Sat Mar 29 03:37:50 1997 --- scripts/functions/wildcard Thu Aug 19 16:54:38 1999 *************** *** 24,51 **** # The Contents of the MAKEFILE ... ! print MAKEFILE "print1: ;\@echo \$(wildcard *.example)\n" ."print2: \n" ! ."\t\@echo \$(wildcard ?.example)\n" ! ."\t\@echo \$(wildcard [a-z0-9].example)\n" ! ."\t\@echo \$(wildcard [!A-Za-z_\\\!].example)\n" ."clean: \n" ! ."\t$delete_command \$(wildcard *.example)\n"; # END of Contents of MAKEFILE close(MAKEFILE); ! &touch("1.example"); ! &touch("two.example"); ! &touch("3.example"); ! &touch("four.example"); ! &touch("F.example"); # TEST #1 # ------- ! $answer = "1.example 3.example F.example four.example two.example\n"; &run_make_with_options($makefile,"print1",&get_logfile); --- 24,51 ---- # The Contents of the MAKEFILE ... ! print MAKEFILE "print1: ;\@echo \$(wildcard example.*)\n" ."print2: \n" ! ."\t\@echo \$(wildcard example.?)\n" ! ."\t\@echo \$(wildcard example.[a-z0-9])\n" ! ."\t\@echo \$(wildcard example.[!A-Za-z_\\\!])\n" ."clean: \n" ! ."\t$delete_command \$(wildcard example.*)\n"; # END of Contents of MAKEFILE close(MAKEFILE); ! &touch("example.1"); ! &touch("example.two"); ! &touch("example.3"); ! &touch("example.for"); ! &touch("example._"); # TEST #1 # ------- ! $answer = "example.1 example.3 example._ example.for example.two\n"; &run_make_with_options($makefile,"print1",&get_logfile); *************** *** 55,63 **** # TEST #2 # ------- ! $answer = "1.example 3.example F.example\n" ! ."1.example 3.example\n" ! ."1.example 3.example\n"; &run_make_with_options($makefile,"print2",&get_logfile); --- 55,63 ---- # TEST #2 # ------- ! $answer = "example.1 example.3 example._\n" ! ."example.1 example.3\n" ! ."example.1 example.3\n"; &run_make_with_options($makefile,"print2",&get_logfile); *************** *** 67,74 **** # TEST #3 # ------- ! $answer = "$delete_command 1.example 3.example F.example four.example " ! ."two.example"; if ($vos) { $answer .= " \n"; --- 67,74 ---- # TEST #3 # ------- ! $answer = "$delete_command example.1 example.3 example._ example.for " ! ."example.two"; if ($vos) { $answer .= " \n"; *************** *** 82,88 **** &compare_output($answer,&get_logfile(1)); ! if ((-f "1.example")||(-f "two.example")||(-f "3.example")||(-f "four.example")) { $test_passed = 0; } --- 82,88 ---- &compare_output($answer,&get_logfile(1)); ! if ((-f "example.1")||(-f "example.two")||(-f "example.3")||(-f "example.for")) { $test_passed = 0; } *** scripts/options/dash-e.~0~ Fri Aug 13 08:07:44 1999 --- scripts/options/dash-e Thu Aug 19 18:14:32 1999 *************** *** 18,24 **** &run_make_with_options($makefile,"-e",&get_logfile); ! $answer = $ENV{"PATH"} . "\n"; &compare_output($answer,&get_logfile(1)); --- 18,33 ---- &run_make_with_options($makefile,"-e",&get_logfile); ! open(MAKEFILE,"> $makefile"); ! ! print MAKEFILE <