From 2e9252584842fcf90aa4774eff326c631475852e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 15 Oct 2018 17:29:35 -0300 Subject: [PATCH] Bug 21576: Keep compatibility with QA script The QA script call 'missing_filters', it sounds better to keep it in order to avoid fixing it and have a weird condition (if module->can('subroutine_name')) to maintain Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens --- t/lib/QA/TemplateFilters.pm | 8 ++++---- t/template_filters.t | 20 ++++++++++---------- xt/find-missing-filters.t | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/t/lib/QA/TemplateFilters.pm b/t/lib/QA/TemplateFilters.pm index be3c2ffa3a..60b2d5debf 100644 --- a/t/lib/QA/TemplateFilters.pm +++ b/t/lib/QA/TemplateFilters.pm @@ -31,8 +31,8 @@ sub fix_filters { return _process_tt_content( @_ )->{new_content}; } -sub search_missing_filters { - return _process_tt_content( @_ )->{errors}; +sub missing_filters { + return @{_process_tt_content( @_ )->{errors}}; } @@ -217,7 +217,7 @@ t::lib::QA::TemplateFilters - Module used by tests and QA script to catch missin my $content = read_file($filename); my $new_content = t::lib::QA::TemplateFilters::fix_filters($content); - my $errors = t::lib::QA::TemplateFilters::search_missing_filters($content); + my $errors = t::lib::QA::TemplateFilters::missing_filters($content); =head1 DESCRIPTION @@ -232,7 +232,7 @@ and to not duplicate the code. the correct (guessed) filters. It will also add the [% USE raw %] statement if it is needed. -=head2 search_missing_filters +=head2 missing_filters Take a template content file in parameter and return an arrayref of errors. diff --git a/t/template_filters.t b/t/template_filters.t index 3c9c5a97a3..96547a3cd2 100644 --- a/t/template_filters.t +++ b/t/template_filters.t @@ -33,9 +33,9 @@ EXPECTED my $new_content = t::lib::QA::TemplateFilters::fix_filters($input); is( $new_content . "\n", $expected, ); - my $missing_filters = t::lib::QA::TemplateFilters::search_missing_filters($input); + my @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input); is_deeply( - $missing_filters, + \@missing_filters, [ { error => "asset_must_be_raw", @@ -79,9 +79,9 @@ EXPECTED my $new_content = t::lib::QA::TemplateFilters::fix_filters($input); is( $new_content . "\n", $expected, ); - my $missing_filters = t::lib::QA::TemplateFilters::search_missing_filters($input); + my @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input); is_deeply( - $missing_filters, + \@missing_filters, [{ error => "missing_filter", line => " [% just_a_var %]", @@ -163,9 +163,9 @@ EXPECTED my $new_content = t::lib::QA::TemplateFilters::fix_filters($input); is( $new_content . "\n", $expected, ); - my $missing_filters = t::lib::QA::TemplateFilters::search_missing_filters($input); + my @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input); is_deeply( - $missing_filters,[],); + \@missing_filters,[],); }; subtest 'Preserve pre/post chomps' => sub { @@ -228,9 +228,9 @@ EXPECTED $input = <[% var | html %] INPUT - my $missing_filters = t::lib::QA::TemplateFilters::search_missing_filters($input); + my @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input); is_deeply( - $missing_filters, + \@missing_filters, [ { error => "wrong_html_filter", @@ -245,6 +245,6 @@ INPUT $input = <[% var | html %] INPUT - $missing_filters = t::lib::QA::TemplateFilters::search_missing_filters($input); - is_deeply( $missing_filters, [], ); + @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input); + is_deeply( \@missing_filters, [], ); }; diff --git a/xt/find-missing-filters.t b/xt/find-missing-filters.t index 858c8362f2..6b7e80f4aa 100755 --- a/xt/find-missing-filters.t +++ b/xt/find-missing-filters.t @@ -52,8 +52,8 @@ find({ wanted => \&wanted, no_chdir => 1 }, @themes ); my @errors; for my $file ( @files ) { my $content = read_file($file); - my $e = t::lib::QA::TemplateFilters::search_missing_filters($content); - push @errors, { file => $file, errors => $e } if @$e; + my @e = t::lib::QA::TemplateFilters::missing_filters($content); + push @errors, { file => $file, errors => \@e } if @e; } is( @errors, 0, "Template variables should be correctly escaped" ) -- 2.39.5