This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Unicode/UCD.t: better handling of errors
authorKarl Williamson <khw@cpan.org>
Mon, 30 May 2016 16:39:05 +0000 (10:39 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 30 May 2016 16:45:27 +0000 (10:45 -0600)
This now looks for the PERL_DIFF_TOOL environment variable, and if found
uses that to display some problems.  If not found, it uses is(), with a
message that better output is available through setting this variable.

PERL_DIFF_TOOL is a convention I wasn't familiar with.

lib/Unicode/UCD.t

index 83320d3..8f8e551 100644 (file)
@@ -1415,9 +1415,14 @@ sub fail_with_diff ($$$$) {
     # For use below to output better messages
     my ($prop, $official, $constructed, $tested_function_name) = @_;
 
-    is($constructed, $official, "$tested_function_name('$prop')");
-    diag("Comment out lines " . (__LINE__ - 1) . " through " . (__LINE__ + 1) . " in '$0' on Un*x-like systems to see just the differences.  Uses the 'diff' first in your \$PATH");
-    return;
+    if (! $ENV{PERL_DIFF_TOOL}) {
+
+        is($constructed, $official, "$tested_function_name('$prop')");
+
+        diag("Set environment variable PERL_DIFF_TOOL=diff_tool to see just "
+           . "the differences.");
+        return;
+    }
 
     fail("$tested_function_name('$prop')");
 
@@ -1434,7 +1439,7 @@ sub fail_with_diff ($$$$) {
     close $gend || die "Can't close gend";
 
     my $diff = File::Temp->new();
-    system("diff $off $gend > $diff");
+    system("$ENV{PERL_DIFF_TOOL} $off $gend > $diff");
 
     open my $fh, "<", $diff || die "Can't open $diff";
     my @diffs = <$fh>;