summaryrefslogtreecommitdiff
path: root/tests/test_driver.pl
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2021-11-27 14:03:44 -0500
committerPaul Smith <psmith@gnu.org>2021-11-27 14:03:44 -0500
commit29d92d40911aeb517c044d733fc652e7097294e8 (patch)
tree2b65d37c9e9089ba8ea467ab01b788ad558a6a17 /tests/test_driver.pl
parentf8f9d371ff58a7195ca4abc9413f435c2bf2b998 (diff)
downloadmake-git-29d92d40911aeb517c044d733fc652e7097294e8.tar.gz
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.
Diffstat (limited to 'tests/test_driver.pl')
-rw-r--r--tests/test_driver.pl31
1 files changed, 26 insertions, 5 deletions
diff --git a/tests/test_driver.pl b/tests/test_driver.pl
index ec17be1f..686f5239 100644
--- a/tests/test_driver.pl
+++ b/tests/test_driver.pl
@@ -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;
}