#!/usr/bin/env perl
########################################################################
# Locate a test fixture, t/etc/tests.yaml, from a program outside of
# t/: dir=t looks under the t dir of each parent.  See POD.
########################################################################

use v5.40;

use FindBin::Bin    qw( $Bin_p );

use FindBin::Files
qw
(
    dir=t
    file=etc/tests.yaml
    scalar
    export=tests_yaml
    nofail
);

$tests_yaml
or die "No t/etc/tests.yaml in any directory above '$Bin_p'.\n";

say "Fixture: $tests_yaml";

__END__

=head1 NAME

test_fixture - locate t/etc/tests.yaml from outside of t/

=head1 SYNOPSIS

    test_fixture

=head1 DESCRIPTION

    use FindBin::Files qw( dir=t file=etc/tests.yaml scalar nofail );

C<dir=t> puts C<t> in front of C<file>: each parent is searched for
F<t/etc/tests.yaml>.  This finds the test data from anywhere in the
project, e.g., a tool in F<bin/> or F<xt/> that generates or checks
the tests:

    project/
    +-- bin/
    |   \-- make-tests                  finds project/t/etc/tests.yaml
    +-- xt/
    |   \-- check-tests                 finds project/t/etc/tests.yaml
    \-- t/
        \-- etc/
            \-- tests.yaml

A test in F<t/> itself needs only C<file=etc/tests.yaml>: its walk
passes through F<t>.

C<dir> takes one directory name: C<dir=t/etc> croaks, put the rest in
C<file>.

=head1 SEE ALSO

L<FindBin::Files>, F<example/test_lib_dirs>
