As a learning exercise I am trying to write a perl module that compare files. 
This is an example from Effective Perl Programming Book by Joseph Hall.

My error occurs when I run make test
        PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" 
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/1....Test header seen more than once!
# No tests run!
t/1....dubious
        Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 1-4
        Failed 4/4 tests, 0.00% okay
Failed Test Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/1.t        255 65280     4    4 100.00%  1-4
Failed 1/1 test scripts, 0.00% okay. 4/4 subtests failed, 0.00% okay.
make: 1254-004 The error code from the last command is 2.

The file that I am making is called 1.t and looks like
/File/Cmp/t> cat 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 { $| = 1; print "1..3\n";}
#########################

# 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.
srand();
        for ($i = 0; $i < 1000; $i++) {
                $test_blob .= pack 'S', rand 0xffff;
} #end for
$test_num = 2;

eval {
        open F, '>xx' or die "couldn't create: $!";
                print F $test_blob;

        open F, '>xxcopy' or die "couldn't create xcopy: $!";
                print F $test_blob;

        open F,'>xxshort' or die "couldn't create xshort: $!";
                print F substr $test_blob, 0,19999;

#test files created

        if (cmp_file('xx', 'xxcopy') ==0) {
                print "ok", $test_num++, "\n";
        } else {
                print "NOT ok", $test_num++, "\n";
                } #end else
        if (cmp_file('xx', 'xxshort') > 0) {
                print "ok ", $test_num++, "\n";
        } else {
                print "NOT of ", $test_num++, "\n";
                } #end else
};
        if ($@) {
                print "... error: [EMAIL PROTECTED]";
        }
        unlink glob 'xx*';
--------------------------------------------------------

If you are not an intended recipient of this e-mail, please notify the sender, 
delete it and do not read, act upon, print, disclose, copy, retain or 
redistribute it. Click here for important additional terms relating to this 
e-mail.     http://www.ml.com/email_terms/
--------------------------------------------------------

Reply via email to