From 950d0e1978355d60d7ab5d4cb6ff0088dd1941d6 Mon Sep 17 00:00:00 2001 From: marc tobias Date: Wed, 15 May 2024 22:53:49 +0200 Subject: [PATCH] fail test if YAML files contain duplicate keys --- bin/run_tests.t | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bin/run_tests.t b/bin/run_tests.t index a999b28..8a65728 100755 --- a/bin/run_tests.t +++ b/bin/run_tests.t @@ -22,6 +22,21 @@ binmode $builder->failure_output, ":utf8"; binmode $builder->todo_output, ":utf8"; +{ + # Some YAML parsers croak on duplicate keys. By default the Perl parser + # doesn't. Here we make sure we didn't overlook any duplicate keys. + $YAML::XS::ForbidDuplicateKeys = 1; + + my @a_conf_files = File::Find::Rule->file() + ->name( '*.yaml' ) + ->in( dirname(__FILE__) . '/../conf/' ); + + foreach my $conf_file (@a_conf_files) { + lives_ok { LoadFile($conf_file) } "parsing file $conf_file"; + } +} + + my $path = dirname(__FILE__) . '/../testcases'; my @files = File::Find::Rule->file()->name( '*.yaml' )->in( $path );