From: Karl Williamson Date: Mon, 30 May 2016 16:39:05 +0000 (-0600) Subject: Unicode/UCD.t: better handling of errors X-Git-Tag: v5.25.2~109 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/bdc905d035d4f835a808f1825dad9a8cd726d1ec Unicode/UCD.t: better handling of errors 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. --- diff --git a/lib/Unicode/UCD.t b/lib/Unicode/UCD.t index 83320d3..8f8e551 100644 --- a/lib/Unicode/UCD.t +++ b/lib/Unicode/UCD.t @@ -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>;