Running perl tests from command line

I made it to the first learning exercise, Lasagna. :innocent:

When I run the tests from the command line, via

prove .

I see the following output

./lasagna.t … Can’t locate Lasagna.pm in @INC (you may need to install the Lasagna module) (@INC contains: {a bunch of paths to my perl installation}

This exercise is different from HelloWorld in that the test is in a directory named ‘t’ and the system-under-test in a directory named ‘lib’.

The HELP.md for the exercise is the basic boilerplate to run tests via prove .
I’ve tried cd’ing to each folder to run the command, moving the .t file to the same directory as the .pm file, none of which changed the error.

In addition to the file location differences, the HelloWorld example uses a different import(?) mechanism:

use Exporter qw;
our @EXPORT_OK = qw;

I feel I’m missing something obvious but am not sure what that is. Any ideas?

Yes, the concept exercises have a different source code layout than the practice exercises. I don’t know why that was done.

To answer your question, the source code lives in the lib dir and the tests are in the t dir:

prove -Ilib t/
# or, for slightly more verbose output
perl -Ilib t/lasagna.t
1 Like

Perfect! That works on the command line and gives me the expected output.

It does seem like there’s a bigger task of updating all HELP.md files to give folks the correct command to run the tests. I’ll add that to my backlog and wait to see if someone else chimes in here.

I’ve created a PR which both updates the documentation and unifies the directory structure of the practice and concept exercises. lib is set in the test files so after the PR is merged Ilib should no longer be necessary.

And I have approved and brought the changes in.

Thanks @pdmoore for reporting your experience!

Thank you @m-dango for that massive cleanup! :heart_hands: