diff --git a/qtest/bin/qtest-driver b/qtest/bin/qtest-driver index 723a3e3f..c51030ea 100755 --- a/qtest/bin/qtest-driver +++ b/qtest/bin/qtest-driver @@ -33,7 +33,7 @@ require TestDriver; if ((@ARGV == 1) && ($ARGV[0] eq '--version')) { - print "$whoami version 1.2\n"; + print "$whoami version 1.3\n"; exit 0; } if ((@ARGV == 1) && ($ARGV[0] eq '--print-path')) diff --git a/qtest/module/TestDriver.pm b/qtest/module/TestDriver.pm index ea421702..9a8e0f96 100644 --- a/qtest/module/TestDriver.pm +++ b/qtest/module/TestDriver.pm @@ -940,8 +940,8 @@ sub runtest # $outcome_text is for the human-readable. We need something # different for the xml file. $testxml->print(" print("cwd: $cwd\n"); - $testxml->print(" $cwd\n"); + $testxml->print(" " . xmlify($cwd) . "\n"); my $cmd = $in_command; if ((defined $cmd) && (ref($cmd) eq 'ARRAY')) { @@ -966,7 +966,7 @@ sub runtest if (defined $cmd) { $testlog->print("command: $cmd\n"); - $testxml->print(" $cmd\n"); + $testxml->print(" " . xmlify($cmd) . "\n"); } if (defined $out_file) { @@ -975,7 +975,8 @@ sub runtest # real output was original in a file. $testlog->print("expected output in $out_file\n"); $testxml->print( - " $out_file\n"); + " " . xmlify($out_file) . + "\n"); } # It would be nice if we could filter out internal calls for @@ -984,7 +985,7 @@ sub runtest $testlog->print(Carp::longmess()); $testxml->print(" test failure" . - Carp::longmess() . + xmlify(Carp::longmess()) . "\n"); if (! $status_match) @@ -1014,7 +1015,7 @@ sub runtest { $testlog->print("\n"); } - $testxml->print("regexp: " . $out_regexp); + $testxml->print("regexp: " . xmlify($out_regexp)); } else { @@ -1169,6 +1170,18 @@ sub write_file_to_fh } } +sub xmlify +{ + my ($str, $attr) = @_; + $attr = 0 unless defined $attr; + $str =~ s/\&/\&/g; + $str =~ s//>/g; + $str =~ s/\"/"/g if $attr; + $str =~ s/([\000-\010\013-\037\177-\377])/sprintf("&#x%02x;", ord($1))/ge; + $str; +} + sub xml_write_file_to_fh { my ($file, $out) = @_; @@ -1178,11 +1191,7 @@ sub xml_write_file_to_fh binmode $in; while (defined ($_ = <$in>)) { - s/\&/\&/g; - s//>/g; - s/([\000-\011\013-\037\177-\377])/sprintf("&#x%02x;", ord($1))/ge; - $out->print($_); + $out->print(xmlify($_)); } $in->close(); }