From 7d56a5fe00c3804d6f0a7709fd6deef1a6bcf9e3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 21 Sep 2018 12:33:19 -0300 Subject: [PATCH] Bug 21393: Add line nubmers to ease fixing Signed-off-by: Josef Moravec Signed-off-by: Katrin Fischer Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- t/lib/QA/TemplateFilters.pm | 6 ++-- t/template_filters.t | 70 +++++++++++++++++++++++-------------- 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/t/lib/QA/TemplateFilters.pm b/t/lib/QA/TemplateFilters.pm index 0185565ef5..4b4a3d2835 100644 --- a/t/lib/QA/TemplateFilters.pm +++ b/t/lib/QA/TemplateFilters.pm @@ -30,7 +30,9 @@ sub missing_filters { my ($content) = @_; my ( $use_raw, $has_use_raw ); my @errors; + my $line_number; for my $line ( split "\n", $content ) { + $line_number++; if ( $line =~ m{\[%[^%]+%\]} ) { # handle exceptions first @@ -39,7 +41,7 @@ sub missing_filters { # Do we have Asset without the raw filter? if ( $line =~ m{^\s*\[% Asset} ) { - push @errors, { error => 'asset_must_be_raw', line => $line } + push @errors, { error => 'asset_must_be_raw', line => $line, line_number => $line_number } and next unless $line =~ m{\|\s*\$raw}; } @@ -67,7 +69,7 @@ sub missing_filters { ; # We could escape it but should be safe next if $tt_block =~ m{^\#}; # Is a comment, skip it - push @errors, { error => 'missing_filter', line => $line } + push @errors, { error => 'missing_filter', line => $line, line_number => $line_number } if $tt_block !~ m{\|\s?\$raw} # already escaped correctly with raw && $tt_block !~ m{=} # assignment, maybe we should require to use SET (?) && $tt_block !~ m{\|\s?ur(l|i)} # already has url or uri filter diff --git a/t/template_filters.t b/t/template_filters.t index 4131534838..a36e75635b 100644 --- a/t/template_filters.t +++ b/t/template_filters.t @@ -61,56 +61,74 @@ INPUT my @expected_errors = ( { - error => q{missing_filter}, - line => q{ [% just_a_var %] A N D [% another_one_on_same_line %]}, + error => q{missing_filter}, + line => +q{ [% just_a_var %] A N D [% another_one_on_same_line %]}, + line_number => 6, }, { - error => q{missing_filter}, - line => q{ [% just_a_var %] A N D [% another_one_on_same_line %]}, + error => q{missing_filter}, + line => +q{ [% just_a_var %] A N D [% another_one_on_same_line %]}, + line_number => 6, }, { - error => q{missing_filter}, - line => q{ [% IF ( patron.othernames | html ) %]“[% patron.othernames %]”[% END %]}, + error => q{missing_filter}, + line => +q{ [% IF ( patron.othernames | html ) %]“[% patron.othernames %]”[% END %]}, + line_number => 12, }, { - error => q{asset_must_be_raw}, - line => q{ [% Asset.css("css/datatables.css").raw %]}, + error => q{asset_must_be_raw}, + line => q{ [% Asset.css("css/datatables.css").raw %]}, + line_number => 13, }, { - error => q{missing_filter}, - line => q{[% patron.phone %]}, + error => q{missing_filter}, + line => q{[% patron.phone %]}, + line_number => 16, }, { - error => q{missing_filter}, - line => q{[% patron.phone %]}, + error => q{missing_filter}, + line => q{[% patron.phone %]}, + line_number => 16, }, { - error => q{missing_filter}, - line => q{[% patron.emailpro %]}, + error => q{missing_filter}, + line => +q{[% patron.emailpro %]}, + line_number => 17, }, { - error => q{missing_filter}, - line => q{[% patron.emailpro %]}, + error => q{missing_filter}, + line => +q{[% patron.emailpro %]}, + line_number => 17, }, { - error => q{missing_filter}, - line => q{[% patron_message.get_column('manager_surname') %]}, + error => q{missing_filter}, + line => q{[% patron_message.get_column('manager_surname') %]}, + line_number => 18, }, { - error => q{missing_filter}, - line => q{[%- var -%]}, + error => q{missing_filter}, + line => q{[%- var -%]}, + line_number => 29, }, { - error => q{missing_filter}, - line => q{[% - var - %]}, + error => q{missing_filter}, + line => q{[% - var - %]}, + line_number => 30, }, { - error => q{missing_filter}, - line => q{[%~ var ~%]}, + error => q{missing_filter}, + line => q{[%~ var ~%]}, + line_number => 31, }, { - error => q{missing_filter}, - line => q{[% ~ var ~ %]}, + error => q{missing_filter}, + line => q{[% ~ var ~ %]}, + line_number => 32, } ); -- 2.39.5