5 use Test::More tests => 24;
8 use File::Temp qw/tempdir/;
11 use Time::HiRes qw/time/;
14 my $debug = shift @ARGV;
17 use_ok( 'WebPAC::Lookup' );
18 use_ok( 'WebPAC::Input' );
19 use_ok( 'WebPAC::Store' );
20 use_ok( 'WebPAC::Lookup::Normalize' );
21 use_ok( 'WebPAC::Normalize' );
22 use_ok( 'WebPAC::Output::TT' );
25 ok(my $abs_path = abs_path($0), "abs_path");
26 $abs_path =~ s#/[^/]*$#/#;
27 diag "abs_path: $abs_path" if ($debug);
29 my $isis_file = "$abs_path../t/winisis/BIBL";
30 #$isis_file = '/data/hidra/THS/THS';
31 #$isis_file = '/data/isis_data/ffkk/';
33 diag "isis_file: $isis_file" if ($debug);
35 my $normalize_set_pl = "$abs_path/data/normalize.pl";
36 my $lookup_file = "$abs_path../conf/lookup/isis.pm";
38 ok(my $lookup = new WebPAC::Lookup(
39 lookup_file => $lookup_file,
42 ok(my $isis = new WebPAC::Input(
43 module => 'WebPAC::Input::ISIS',
44 code_page => 'ISO-8859-2', # application encoding
47 ), "new Input::ISIS");
49 ok(my $maxmfn = $isis->open(
51 code_page => '852', # database encoding
53 ), "Input::ISIS->open");
55 ok(my $path = tempdir( CLEANUP => 1 ), "path");
57 ok(my $db = new WebPAC::Store(
62 ok(my $norm_pl = read_file( $normalize_set_pl ), "set definitions: $normalize_set_pl" );
64 ok(my $out = new WebPAC::Output::TT(
65 include_path => "$abs_path../conf/output/tt",
66 filters => { foo => sub { shift } },
69 diag " lookup => ",Dumper($lookup->lookup_hash) if ($debug);
73 foreach my $pos ( 0 ... $isis->size ) {
75 my $row = $isis->fetch || next;
77 diag " row $pos => ",Dumper($row) if ($debug);
80 ok( my $ds = WebPAC::Normalize::data_structure(
81 lookup => $lookup->lookup_hash,
84 ), "Set data_structure");
85 $t_norm += time() - $t;
87 diag " ds $pos => ",Dumper($ds) if ($debug);
89 ok(my $html = $out->apply(
90 template => 'html.tt',
94 $html =~ s#\s*[\n\r]+\s*##gs;
100 diag sprintf("timings: %.2fs\n", $t_norm);