#!/usr/bin/env perl
########################################################################
# What "use FindBin::libs" does in a test: add every lib dir from the
# test's directory up, so a test in t/NN-group/ loads t/lib before the
# project's lib, without blib or prove -l.  See POD.
########################################################################

use v5.40;

# "use" adds the dirs to @INC; "export" also keeps the list as @lib.

use FindBin::libs   qw( export use nofail );

say 'lib dirs found, nearest first:';
say "    $_"
for @lib;

say '';
say 'start of @INC:';
say "    $_"
for @INC[ 0 .. $#lib ];

__END__

=head1 NAME

test_lib_dirs - lib dirs a test gets from "use FindBin::libs"

=head1 SYNOPSIS

    test_lib_dirs

=head1 DESCRIPTION

A test needs only

    use FindBin::libs;

to load the project's modules and its own helpers.  The default looks
for C<lib> in each directory from the test's up to the root, and adds
them to C<@INC> nearest first:

    project/
    +-- lib/
    |   \-- My/Module.pm
    \-- t/
        +-- lib/
        |   \-- My/Testy.pm             test helpers
        \-- 10-basic/
            +-- lib/                    helpers for this group only
            \-- 01-load.t               use FindBin::libs;

For F<t/10-basic/01-load.t>:

    project/t/10-basic/lib
    project/t/lib
    project/lib

The tests can then be run with

    prove -r t/

with no C<make>, C<-l> or C<-b>, from any working directory: the dirs
are found from the test's own location.  A nearer C<lib> comes first,
so a test group can override a helper from F<t/lib>.

This program prints C<@lib> and the start of C<@INC>.  They can
differ: FindBin::libs adds to C<@INC> only the dirs
L<File::Util::SecureDir> accepts, while C<export> keeps every dir
found.

=head1 SEE ALSO

L<FindBin::libs>, F<example/dual_lib_paths>, F<example/test_fixture>
