mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-25 05:29:46 +00:00
tests: Enhance output to contain filename/line number info
* tests/scripts/options/dash-I: Use string comparison operator. * tests/test_driver.pl (cmd2str): New method to convert a command line to a string with proper quoting. * tests/run_make_tests.pl (create_command): Call cmd2str() to format the command. Add the filename/line number to the output.
This commit is contained in:
parent
f8f9d371ff
commit
29d92d4091
3 changed files with 32 additions and 16 deletions
|
@ -310,7 +310,7 @@ sub create_command {
|
|||
# Using a ref should be preferred as it's more portable but all the older
|
||||
# invocations use strings.
|
||||
sub run_make_with_options {
|
||||
my ($filename,$options,$logname,$expected_code,$timeout,@call) = @_;
|
||||
my ($filename, $options, $logname, $expected_code, $timeout, @call) = @_;
|
||||
@call = caller unless @call;
|
||||
my $code;
|
||||
my $command = create_command($options);
|
||||
|
@ -364,13 +364,8 @@ sub run_make_with_options {
|
|||
$command = add_options($command, $options);
|
||||
}
|
||||
|
||||
my $cmdstr = ref($command) ? "'".join("' '", @$command)."'" : $command;
|
||||
|
||||
if (@call) {
|
||||
$command_string = "#$call[1]:$call[2]\n$cmdstr\n";
|
||||
} else {
|
||||
$command_string = $cmdstr;
|
||||
}
|
||||
my $cmdstr = cmd2str($command);
|
||||
$command_string = "# $call[1]:$call[2]:\n$cmdstr\n";
|
||||
|
||||
if ($valgrind) {
|
||||
print VALGRIND "\n\nExecuting: $cmdstr\n";
|
||||
|
@ -409,9 +404,9 @@ sub run_make_with_options {
|
|||
}
|
||||
|
||||
if ($code != $expected_code) {
|
||||
print "Error running @make_command (expected $expected_code; got $code): $cmdstr\n";
|
||||
print "Error running @make_command (expected $expected_code; got $code)\n$call[1]:$call[2]: $cmdstr\n";
|
||||
$test_passed = 0;
|
||||
&create_file (&get_runfile, $command_string);
|
||||
&create_file(get_runfile(), $command_string);
|
||||
# If it's a SIGINT, stop here
|
||||
if ($code & 127) {
|
||||
print STDERR "\nCaught signal ".($code & 127)."!\n";
|
||||
|
|
|
@ -92,7 +92,7 @@ unlink('defaultdirs.mk');
|
|||
my $fn = undef;
|
||||
foreach my $dn (split ' ', $dirs) {
|
||||
# On Windows the default is "." which is bogus!
|
||||
if ($dn != '.') {
|
||||
if ($dn ne '.') {
|
||||
my @files = glob(File::Spec->catfile($dn, "*"));
|
||||
if (@files) {
|
||||
(undef, undef, $fn) = File::Spec->splitpath($files[0]);
|
||||
|
|
|
@ -148,6 +148,27 @@ sub resetENV
|
|||
}
|
||||
}
|
||||
|
||||
# Returns a string-ified version of cmd which is a value provided to exec()
|
||||
# so it can either be a ref of a list or a string.
|
||||
sub cmd2str
|
||||
{
|
||||
my $cmd = $_[0];
|
||||
if (!ref($cmd)) {
|
||||
return $cmd;
|
||||
}
|
||||
|
||||
my @c;
|
||||
foreach (@$cmd) {
|
||||
if (/[][#;"*?&|<>(){}\$`^~!]/) {
|
||||
s/\'/\'\\'\'/g;
|
||||
push @c, "'$_'";
|
||||
} else {
|
||||
push @c, $_;
|
||||
}
|
||||
}
|
||||
return join(' ', @c);
|
||||
}
|
||||
|
||||
sub toplevel
|
||||
{
|
||||
# Pull in benign variables from the user's environment
|
||||
|
@ -733,7 +754,7 @@ sub error
|
|||
|
||||
sub compare_output
|
||||
{
|
||||
my ($answer,$logfile) = @_;
|
||||
my ($answer, $logfile) = @_;
|
||||
my ($slurp, $answer_matched) = ('', 0);
|
||||
|
||||
++$tests_run;
|
||||
|
@ -899,15 +920,15 @@ sub compare_output
|
|||
if (! $answer_matched) {
|
||||
print "DIFFERENT OUTPUT\n" if $debug;
|
||||
|
||||
&create_file (&get_basefile, $answer);
|
||||
&create_file (&get_runfile, $command_string);
|
||||
&create_file(&get_basefile, $answer);
|
||||
&create_file(&get_runfile, $command_string);
|
||||
|
||||
print "\nCreating Difference File ...\n" if $debug;
|
||||
|
||||
# Create the difference file
|
||||
|
||||
my $command = "diff -c " . &get_basefile . " " . $logfile;
|
||||
&run_command_with_output(&get_difffile,$command);
|
||||
&run_command_with_output(get_difffile(), $command);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -938,7 +959,7 @@ sub attach_default_output
|
|||
if ($vos)
|
||||
{
|
||||
my $code = system "++attach_default_output_hack $filename";
|
||||
$code == -2 or &error ("adoh death\n", 1);
|
||||
$code == -2 or &error ("ado death\n", 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue