Koha/xt/yaml_valid.pl
Jonathan Druart 46f7239b08 Bug 27673: Replace YAML with YAML::XS
From tht YAML pod:

"""
This module has been released to CPAN as YAML::Old, and soon YAML.pm will be changed to just be a frontend interface module for all the various Perl YAML implementation modules, including YAML::Old.

If you want robust and fast YAML processing using the normal Dump/Load API, please consider switching to YAML::XS. It is by far the best Perl module for YAML at this time. It requires that you have a C compiler, since it is written in C.
"""

See also
https://gitlab.com/koha-community/qa-test-tools/-/merge_requests/35

Test plan:
Try some place where YAML::XS is not used and confirm that it works
correctly

QA note: This patch removes some uses of YAML that were not useful

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-02-16 14:54:50 +01:00

67 lines
1.6 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright (C) 2012 BibLibre
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Getopt::Long;
use YAML::XS;
my $usage = <<EOF;
yaml_valid.pl - give it a filename and it will told you if it is an exact yaml file.
-h|--help Print this help and exit;
-f|--file File to check
Tests yaml config files
It does not tell if the params are correct, only if the file is well-formed (ie: readable by yaml)
EOF
my $help = 0;
my $file = 0;
GetOptions(
"help" => \$help,
"file=s" => \$file,
) or die $usage;
die $usage if $help;
say "Testing file: $file";
eval { YAML::XS::LoadFile($file); };
if ($@) {
print "KO!\n$@\n";
}
else {
print "Loading and Syntax OK\n";
}
#yaml_file_ok("$file", "$file is YAML");
=head1 NAME
yaml_valid.pl
=head1 DESCRIPTION
Tests yaml config files
It does not tell if the params are correct, only if the file is well-formed (ie: readable by yaml)
=head1 USAGE
From Koha root directory:
perl xt/yaml_valid.pl -f filename.yaml
=cut