Learning Perl Objects, References amp;amp; Modules [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Learning Perl Objects, References amp;amp; Modules [Electronic resources] - نسخه متنی

Randal L. Schwartz

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید














13.7 Trivial make test


Testing. Testing. Testing.

Testing is important. First, you should at least ensure that the code
you've written even compiles before you install it
and start playing with it. That test is free. You can invoke it
directly from the newly created Makefile by simply
typing make test, as in:

$ make test
cp Maps.pm blib/lib/Island/Plotting/Maps.pm
PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0,
'blib/lib', 'blib/arch')" t/*.t
t/1....ok
All tests successful.
Files=1, Tests=1, 1 wallclock secs ( 0.08 cusr + 0.04 csys = 0.12 CPU)

But what happened there?

First, the .pm file was copied to the testing
staging area: the area headed by blib (build
library) below the current directory.[12]

[12] Had there been
XS files or other more complex build steps, these also would have
happened here.


Next, the perl that invoked the
Makefile.PL is called upon to run the
test harnessa program that manages all
test invocations and reports the results at the end.[13]

[13] The perl that invoked the
Makefile.PL is used for all configuration
decisions. If you have more than one version of Perl installed on
your system, be sure to execute the Makefile.PL
with the correct one. From there, full paths are always used, so
there's no chance of mixing anything else up.



The test harness runs all files in the
t subdirectory that end in .t
in their natural order. You have only one file (created by
h2xs), which looks like this:

$ cat t/1.t
# Before 'make install' is performed this script should be runnable with
# 'make test'. After 'make install' it should work as 'perl 1.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1;
BEGIN { use_ok('Island::Plotting::Maps') };
#########################
# Insert your test code below, the Test::More module is use( )ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

It's a simple test program. The test pulls in the
Test::More module, described further in Chapter 14. The import list for the module is treated
specially; you're declaring that this test file
consists of only one "test."

The test is given in the following line and attempts to
use the module. If this succeeds, you get an
"OK" sign, and the overall test
file succeeds. This would fail with bad syntax, or perhaps if you
forgot to have that true value at the end of the file.

In this example, the test succeeds, so you get a message for it and a
summary of the CPU time used for the test.



/ 199