develooper Front page | perl.module-authors | Postings from November 2003

FW: How to indicate a dependency in my module

Thread Next
From:
Sherzod Ruzmetov
Date:
November 10, 2003 13:12
Subject:
FW: How to indicate a dependency in my module
Message ID:
000901c3a7cf$b63b14e0$dc024544@sherzodwgibb4u

    : > In my test script, I cause the test to fail if it 
    : cannot find a process,
    : > 'svscan', running on the machine. Do you think that 
    : this can cause all the
    : > cpan-testers to fail?

If the whole library has a dependency, and wouldn't function as intended if
they are found missing,
then you have to let Makefile.PL to take care of it (read my prev. message
to this thread).

If dependencies of your test script(s) are different than those of your
actual module, then making them
fail is not a good idea. You have to get them skip all the tests gracefully.

For example, let's skip all the tests if "DB_File" is not installed.
Remember, that this makes sense
only if "DB_File" is not a requirement for your actual Module but ONLY for
this particular test:

	eval "require DB_File";
	if ( $@ ) {
		print "1..0 #Skipped: DB_File is not available\n";
		exit(0);
	}

You can also achieve the same effect using Test::More:

	use Test::More;
	eval "require DB_File";
	if ( $@ ) {
		plan(skip_all=>"DB_File is not available");
		exit(0)
	}

If, in our above example, "DB_File" is a requirement by your actuall module,
say "Acme::Module",
then putting checks in your test scripts as we did above would make no
sense! This check had to
put in Makefile.PL:

	WriteMakefile (
		PREREQ_PM => {
			DB_File => 0
		}
	);



-- 
Sherzod Ruzmetov
<URI: http://author.handalak.com/ >

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About