Dani Bolliger wrote:
>
> Johnson, Reginald (GTI) am Sunday, 24. September 2006 04:47:
>>
>> Tom Phoenix wrote:
>>>
>>> On 9/23/06, Johnson, Reginald (GTI) <[EMAIL PROTECTED]> wrote:
>>>>
>>>> t/1....Test header seen more than once!
>>>>
>>>> use Test::More tests => 1;
>>>> BEGIN { $| = 1; print "1..3\n";}
>>>
>>> Using Test::More outputs the test header line, so you don't need to
>>> print "1..3\n"; but be sure to use the correct number of tests:
>>>
>>>     use Test::More tests => 3;
>>
>> I made the changes that you advised
>> use Test::More tests => 3;
>> #BEGIN { $| = 1; print "1..3\n";}
>>
>> My error has changed slightly
>>
>> PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
>> t/1....# No tests run!
>> t/1....dubious
>>         Test returned status 255 (wstat 65280, 0xff00)
>> DIED. FAILED tests 1-3
>>         Failed 3/3 tests, 0.00% okay
>> Failed Test Stat Wstat Total Fail  Failed  List of Failed
>> 
-------------------------------------------------------------------------------
>> t/1.t        255 65280     3    3 100.00%  1-3
>> Failed 1/1 test scripts, 0.00% okay. 3/3 subtests failed, 0.00% okay.
>> make: 1254-004 The error code from the last command is 2.>>
>>
>> Stop.
>
>
> Hi Reginald,
>
> (please don't top post)
>
> I testet your test script under
>
>   use strict;
>
> It's a very good line, saves a lot of time, guides in finding errors, etc.  
:-)
> I got:
>
>    1..3
>    ... error: Undefined subroutine &main::cmp_file called
>               at ./script.pl line 30.
>
>    # No tests run!
>
>
> Hope this helps!

<rant subject="top-posting">
I've reconstructed this thread as best I could, but couldn't be bothered to put
back in key details from the original post which have been snipped in the course
of the discussion. Please refer back to see the source of Reginald's original
test program. And please, please, bottom-post replies: a one-off top-posted
reply would be fine if it was never followed up, but it can swiftly make a
thread of any length incomprehensible later on. You must always expect a thread
to be continued after your own post so please bear this in mind.
</rant>

It looks to me like 'Effective Perl Programming' used an earlier version of h2xs
Reginald, as the problem you're seeing is because there is no 'use File::Cmp' in
your code, and h2xs starts its template test program with

  use Test::More tests => 1;
  BEGIN { use_ok('File::Cmp') };

which provides both the 'use' and the first of the three tests.

Ignore the intruction in the book to change the BEGIN line as this is no longer
necessary, so put it back as it was. You do need to alter the number of tests as
Tom said, remembering that the use_ok() constututes the first test. The
remainder of the test should be OK, except that with Test::More it is more in
keeping to write simply:

  ok(cmp_file('xx', 'xxcopy') == 0, 'Identical files match');
  ok(cmp_file('xx', 'xxshort') > 0, 'Different files mismatch');

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to