Some of the MARC::Record tests have been updated in the past weeks, to use File::Spec for file paths. This should allow them to run without much user modification on multiple platforms (MacPerl on MacOS 9, for example). After some trial and error, the tests seem to be working (though more testing is welcome). During the process of modifying 81.decode.t, I may have discovered a problem with MARC::File::MicroLIF's decode(). Below is some discussion of the possible problem:

On Wed, 5 Jan 2005 10:16:01 -0600, Ed Summers wrote (offlist)
On Tue, Jan 04, 2005 at 10:32:58PM -0600, Bryan Baldus wrote (offlist):
OK. The tests for MARC::Record have now been updated, removing
File::Spec->updir(). All pass on my machine (except the ones I
mentioned before--81.decode.t (problem with line endings in MicroLIF
decode() when endings differ from those of the system--since decode()
splits on "\n", and depends on other subs to turn non-native endings
into "\n") and utf8.t (requires 5.8.1)).

Can you send the test report for these failures?

perl -I lib t/81.decode.t

You will probably have to remove the -T flag at the top of the script.

I modified my local copy of 81.decode.t as follows and created 2 new files (sample1unix.lif and sample1mac.lif), though I probably could have used the lif files from linendings.t instead.


## slurp up some microlif
my @lifnames = ( 'sample1.lif', 'sample1unix.lif', 'sample1mac.lif' );
foreach my $file (@lifnames) {
my $lifname = File::Spec->catfile( 't', $file );
open(IN, $lifname );
my $str = join( '', <IN> );
close IN;

## attempt to use decode() on it

DECODE_MICROLIF_METHOD: {
    my $rec = MARC::File::MicroLIF->decode( $str );
    isa_ok( $rec, 'MARC::Record' );
    like( $rec->title(), qr/all about whales/i, "retrieved title from file
$lifname" );
}

DECODE_MICROLIF_FUNCTION: {
    my $rec = MARC::File::MicroLIF::decode( $str );
    isa_ok( $rec, 'MARC::Record' );
    like( $rec->title(), qr/all about whales/i, "retrieved title from file
$lifname" );
}
}

#and add 'my' in front of $str below, in the usmarc test.

Results:

C:\Perl\site>perl -I lib t/81.decode.t
1..32
ok 1 - use MARC::Record;
ok 2 - use MARC::File::MicroLIF;
ok 3 - use MARC::File::USMARC;
ok 4 - The object isa MARC::Record
ok 5 - retrieved title from file t\sample1.lif
ok 6 - The object isa MARC::Record
ok 7 - retrieved title from file t\sample1.lif
ok 8 - The object isa MARC::Record
ok 9 - retrieved title from file t\sample1unix.lif
ok 10 - The object isa MARC::Record
ok 11 - retrieved title from file t\sample1unix.lif
ok 12 - The object isa MARC::Record
not ok 13 - retrieved title from file t\sample1mac.lif
#     Failed test (t/81.decode.t at line 39)
#                   ''
#     doesn't match '(?i-xsm:all about whales)'
ok 14 - The object isa MARC::Record
not ok 15 - retrieved title from file t\sample1mac.lif
#     Failed test (t/81.decode.t at line 45)
#                   ''
#     doesn't match '(?i-xsm:all about whales)'
ok 16 - The object isa MARC::Record
ok 17 - retrieved title
ok 18 - The object isa MARC::Record
ok 19 - retrieved title
ok 20 - should be no warnings
ok 21 - gap after field data should not be returned
ok 22 - The object isa MARC::Field
ok 23 - indicators in tag after gap should be OK
ok 24 - subfield a in tag after gap should be OK
ok 25 - subfield b in tag after gap should be OK
ok 26 - subfield c in tag after gap should be OK
ok 27 - The object isa MARC::Record
ok 28 - 001 field correct
ok 29 - 010 field correct
ok 30 - 100 field correct
ok 31 - 245 field correct
ok 32 - 260 field correct
ok 33 - 650 field correct
ok 34 - The object isa MARC::Record
ok 35 - check for appropriate warnings count
ok 36 - 040 warning present
ok 37 - 041 warning present
ok 38 - 245 should not exist
ok 39 - 040 should not exist
ok 40 - 041 should not exist
# Looks like you planned 32 tests but ran 8 extra.

##I didn't bother to change the number in the plan, since this was only a
quick test.


The unmodified version fails (if line endings in sample1.lif differ) with errors:
not ok 5 - retrieved title
# Failed test (:t:81.decode.t at line 37)
# ''
# doesn't match '(?i-xsm:all about whales)'
ok 6 - The object isa MARC::Record
not ok 7 - retrieved title
# Failed test (:t:81.decode.t at line 43)
# ''
# doesn't match '(?i-xsm:all about whales)'
########################################################################



In other tests, I went for a complicated solution (Bryan wrote:
50.batch.t now has:
MicroLIF: {

    my $filepath = File::Spec->catdir( 't' );
    opendir(TESTDIR, $filepath) || die "can't opendir $filepath: $!";
    my @files = map {$filepath.$_} (grep { /sample.*\.lif/ && -f
$filepath.$_ } readdir(TESTDIR));
    closedir TESTDIR;
#...
)

(Ed responded:
I updated and found t/50.batch.t to fail. I've committed some changes
which fix the problem.

And, of course, specifying the 3 filenames directly, instead of going through a convoluted procedure looking for them, would make more sense: MicroLIF: {

    my @files = (
        File::Spec->catfile( 't', 'sample1.lif' ),
        File::Spec->catfile( 't', 'sample20.lif' ),
        File::Spec->catfile( 't', 'sample100.lif' )
    );

    my $batch = new MARC::Batch( 'MicroLIF', @files );



(Bryan:)
I considered adding:

1.39_03 not yet released, Jan. 4, 2005
        [FIXES]
        - Updated tests to use File::Spec for paths.

to Changes, but wasn't sure if that was appropriate.

(Ed:)
Please do, and please bring this conversation onto perl4lib. Other
people on the list might like to know what's going on. At the very least
people could learn about using File::Spec :-)

Changes now mentions using File::Spec for paths.

--

Bryan Baldus
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://home.inwave.com/eija



Reply via email to