Browse Source

runtests: move showdiff into runtests.pl

It's not used anywhere else.
Dan Fandrich 1 year ago
parent
commit
a8706fd8d0
2 changed files with 46 additions and 45 deletions
  1. 5 45
      tests/getpart.pm
  2. 41 0
      tests/runtests.pl

+ 5 - 45
tests/getpart.pm

@@ -31,16 +31,15 @@ BEGIN {
     use base qw(Exporter);
 
     our @EXPORT = qw(
-        getpartattr
+        compareparts
+        fulltest
         getpart
-        partexists
+        getpartattr
+        loadarray
         loadtest
-        fulltest
+        partexists
         striparray
-        compareparts
         writearray
-        loadarray
-        showdiff
     );
 }
 
@@ -356,44 +355,5 @@ sub loadarray {
     return @array;
 }
 
-# Given two array references, this function will store them in two temporary
-# files, run 'diff' on them, store the result and return the diff output!
-
-sub showdiff {
-    my ($logdir, $firstref, $secondref)=@_;
-
-    my $file1="$logdir/check-generated";
-    my $file2="$logdir/check-expected";
-
-    open(my $temp, ">", "$file1") || die "Failure writing diff file";
-    for(@$firstref) {
-        my $l = $_;
-        $l =~ s/\r/[CR]/g;
-        $l =~ s/\n/[LF]/g;
-        $l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
-        print $temp $l;
-        print $temp "\n";
-    }
-    close($temp) || die "Failure writing diff file";
-
-    open($temp, ">", "$file2") || die "Failure writing diff file";
-    for(@$secondref) {
-        my $l = $_;
-        $l =~ s/\r/[CR]/g;
-        $l =~ s/\n/[LF]/g;
-        $l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
-        print $temp $l;
-        print $temp "\n";
-    }
-    close($temp) || die "Failure writing diff file";
-    my @out = `diff -u $file2 $file1 2>/dev/null`;
-
-    if(!$out[0]) {
-        @out = `diff -c $file2 $file1 2>/dev/null`;
-    }
-
-    return @out;
-}
-
 
 1;

+ 41 - 0
tests/runtests.pl

@@ -297,6 +297,47 @@ sub cleardir {
     return $done;
 }
 
+
+#######################################################################
+# Given two array references, this function will store them in two temporary
+# files, run 'diff' on them, store the result and return the diff output!
+sub showdiff {
+    my ($logdir, $firstref, $secondref)=@_;
+
+    my $file1="$logdir/check-generated";
+    my $file2="$logdir/check-expected";
+
+    open(my $temp, ">", "$file1") || die "Failure writing diff file";
+    for(@$firstref) {
+        my $l = $_;
+        $l =~ s/\r/[CR]/g;
+        $l =~ s/\n/[LF]/g;
+        $l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
+        print $temp $l;
+        print $temp "\n";
+    }
+    close($temp) || die "Failure writing diff file";
+
+    open($temp, ">", "$file2") || die "Failure writing diff file";
+    for(@$secondref) {
+        my $l = $_;
+        $l =~ s/\r/[CR]/g;
+        $l =~ s/\n/[LF]/g;
+        $l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
+        print $temp $l;
+        print $temp "\n";
+    }
+    close($temp) || die "Failure writing diff file";
+    my @out = `diff -u $file2 $file1 2>/dev/null`;
+
+    if(!$out[0]) {
+        @out = `diff -c $file2 $file1 2>/dev/null`;
+    }
+
+    return @out;
+}
+
+
 #######################################################################
 # compare test results with the expected output, we might filter off
 # some pattern that is allowed to differ, output test results