Bug 22844: Fix yaml_valid.t - don't pick .json files
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 21 Jul 2020 07:47:11 +0000 (09:47 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 21 Jul 2020 07:47:11 +0000 (09:47 +0200)
Only .pref are considered yaml files.

kohadev-koha@kohadevbox:/kohadevbox/koha$ time prove xt/yaml_valid.t
xt/yaml_valid.t .. 1/19
 #   Failed test 'borrowers.json is YAML'
 #   at xt/yaml_valid.t line 39.

 #   Failed test 'items.json is YAML'
 #   at xt/yaml_valid.t line 39.
 # Looks like you failed 2 tests of 19.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

xt/yaml_valid.t

index 4f38321..b6f3c60 100755 (executable)
@@ -19,7 +19,7 @@
 
 use Modern::Perl;
 use Test::YAML::Valid;
-use Data::Dumper;
+use File::Find;
 
 use Test::More;
 
@@ -30,13 +30,19 @@ BEGIN {
 
 my $filebase = "$FindBin::Bin/../koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences";
 
-my @files = `ls -1 $filebase`;
+my @files;
+sub wanted {
+    my $name = $File::Find::name;
+    push @files, $name
+        if $name =~ /\.pref/;
+}
+find({ wanted => \&wanted, no_chdir => 1 }, $filebase);
 
 plan tests => scalar @files;
 
 foreach my $f (@files) {
     chomp $f;
-    yaml_file_ok( "$filebase/$f", "$f is YAML" );
+    yaml_file_ok( $f, "$f is YAML" );
 }