From bd96fdbe8f76ae771f52691a2992ccba4c16ff0a Mon Sep 17 00:00:00 2001 From: Terrence Brannon Date: Tue, 10 Jan 2012 15:10:46 -0500 Subject: [PATCH] added strip whitespace function to make html comparision work across OSes --- t/TestUtils.pm | 8 +++++++- t/crunch.t | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/t/TestUtils.pm b/t/TestUtils.pm index e2d2222..e4bb274 100644 --- a/t/TestUtils.pm +++ b/t/TestUtils.pm @@ -6,7 +6,7 @@ use File::Slurp; require Exporter; @ISA=qw(Exporter); -@EXPORT = qw(ptree html_dir); +@EXPORT = qw(ptree html_dir strip_ws); sub html_dir { 't/html/' @@ -24,6 +24,12 @@ sub ptree { join '', @$lines; } +sub strip_ws { + my($str)=@_; + + $str =~ s/\s+//g; + $str; +} 1; diff --git a/t/crunch.t b/t/crunch.t index 00f7947..383d5ed 100644 --- a/t/crunch.t +++ b/t/crunch.t @@ -19,9 +19,14 @@ sub tage { $tree->crunch(look_down => [ class => 'imageElement' ], leave => 1); - my $generated_html = ptree($tree, "$root.gen"); + my $generated_html = strip_ws ( ptree($tree, "$root.gen") ); + # must put read_file() in scalar context so that a string instead of first line is returned. + my $expected_html = strip_ws(scalar File::Slurp::read_file("$root.exp")); - is_xml ($generated_html, File::Slurp::read_file("$root.exp"), "HTML for crunch"); + #warn "g:$generated_html"; + #warn "e:$expected_html"; + + is ($generated_html, $expected_html, "HTML for crunch"); } -- 2.39.2