Bod has asked for the wisdom of the Perl Monks concerning the following question:

Since Aldebaran found a problem with AI::Embedding in Re^2: perl hooks for AI, I have updated the module.

But, when I use prove to run my tests, it is using the installed version of AI::Embedding and not the one in my test directory. How can I get prove to ignore the version from CPAN and use the test version?

Replies are listed 'Best First'.
Re: Path to prove
by pryrt (Abbot) on Dec 19, 2023 at 00:16 UTC
    assuming you are in the . directory, your tests are the default t/*.t , and your module lives as lib/AI/Embedding.pm , then prove -l lib

    If you have XS binaries (I haven't looked at AI::Embedding, so I don't know), then you may need to build it first (which puts modules in blib/lib ), and then use prove -b blib

    prove describes all of these options, and more.

    And if you're using a standard build system, then the standard incantation

    perl Makefile.PL make make test
    (or your build system's equivalent incantation) will also make use of your in-progress copy rather than a previously installed.


    edit 1: standard incantation

    edit 2: remove ambiguous sentence full-stop in first paragraph, because it looked like part of the prove command, when it wasn't intended to

    edit 3: strike out lib and blib : per Re^3: Path to prove and Re^4: Path to prove, -l and -b options do not take arguments; use the -I path argument if you need to specify a specific directory.

      then prove -l lib

      I was clearly having a senior moment... I tried the -l switch but added lib\AI

      Thank you

        FYI the default value for -l is lib/ so the value doesn't have to be specified if that's where your libs live. -l is like -Ilib.

        Hope this helps!


        The way forward always starts with a minimal test.
Re: Path to prove
by SankoR (Prior) on Dec 19, 2023 at 00:14 UTC
    You could add your project's lib directory to the front of @INC with use lib ...; in the test files themselves. I'd go with the relative path.
Re: Path to prove
by etj (Priest) on Dec 21, 2024 at 16:11 UTC
    I use `prove -b` in PDL's `make coretest` target, but the most idiomatic way in your situation (where you don't have vast numbers of things to build that you want to limit) is `make test`.