commit 0015861934b4cbf09826405f900a5df1d472eab3
parent 0ebf750a9bf3faf17e48c032a721ca7e6248b781
Author: Kyle Milz <krwmilz@gmail.com>
Date: Sat, 14 Aug 2021 21:22:53 +0000
t: remove newlines in output
Different preprocessors add different amounts of whitespace to output.
Test in a way that is agnostic to trivial whitespace differences.
Sneak in some other small typo fixes.
Diffstat:
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/t/img_html.t b/t/img_html.t
@@ -2,9 +2,9 @@
# Verify the img_html suffix generates a thumbnail and correct HTML
# fragment.
#
+use File::Spec::Functions;
use Imager;
use Modern::Perl;
-use File::Spec::Functions;
use Test::Cmd;
use Test::File;
use Test::File::Contents;
@@ -35,13 +35,13 @@ $cmd->write( 'Makefile', <<EOF );
EOF
$cmd->run( args => 'depend', chdir => $cmd->curdir );
-like( $cmd->stdout, qr/.*/, 'make stdout' );
-is( $cmd->stderr, "", 'make stderr' );
-is( $? >> 8, 0, 'make exit status' );
+like( $cmd->stdout, qr/.*/, 'make depend stdout' );
+is( $cmd->stderr, '', 'make depend stderr' );
+is( $? >> 8, 0, 'make depend exit status' );
$cmd->run( chdir => $cmd->curdir );
like( $cmd->stdout, qr/.*/, 'make stdout' );
-is( $cmd->stderr, "", 'make stderr' );
+is( $cmd->stderr, '', 'make stderr' );
is( $? >> 8, 0, 'make exit status' );
#
@@ -51,7 +51,7 @@ is( $? >> 8, 0, 'make exit status' );
# - html generated
# - final html file looks good
#
-my $index_good = "\n\n";
+my $index_good;
for my $sfx (@sfxs) {
my $cp_file = catfile( '_img', "pic_${sfx}.${sfx}" );
@@ -70,4 +70,10 @@ EOF
$index_good .= $html_good;
}
+# Adjust for different preprocessors adding different amounts of whitespace.
+my $index_html;
+$cmd->read( \$index_html, 'index.html' );
+$index_html =~ s/^\n//mg;
+$cmd->write( 'index.html', $index_html );
+
file_contents_eq_or_diff( catfile( $cmd->workdir, 'index.html' ), $index_good );