/[webpac2]/trunk/t/6-unit.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/t/6-unit.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 625 - (show annotations)
Sat Aug 26 12:00:36 2006 UTC (17 years, 8 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2262 byte(s)
 r878@llin:  dpavlin | 2006-08-26 14:00:08 +0200
 removed some debugging output (or moved it to debug level), few tweaks [2.26]

1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use Test::More tests => 24;
6 use Test::Exception;
7 use Cwd qw/abs_path/;
8 use File::Temp qw/tempdir/;
9 use File::Slurp;
10 use Data::Dumper;
11 use Time::HiRes qw/time/;
12 use blib;
13
14 my $debug = shift @ARGV;
15
16 BEGIN {
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' );
23 }
24
25 ok(my $abs_path = abs_path($0), "abs_path");
26 $abs_path =~ s#/[^/]*$#/#;
27 diag "abs_path: $abs_path" if ($debug);
28
29 my $isis_file = "$abs_path../t/winisis/BIBL";
30 #$isis_file = '/data/hidra/THS/THS';
31 #$isis_file = '/data/isis_data/ffkk/';
32
33 diag "isis_file: $isis_file" if ($debug);
34
35 my $normalize_set_pl = "$abs_path/data/normalize.pl";
36 my $lookup_file = "$abs_path../conf/lookup/isis.pm";
37
38 ok(my $lookup = new WebPAC::Lookup(
39 lookup_file => $lookup_file,
40 ), "new Lookup");
41
42 ok(my $isis = new WebPAC::Input(
43 module => 'WebPAC::Input::ISIS',
44 code_page => 'ISO-8859-2', # application encoding
45 limit => 100,
46 no_progress_bar => 1,
47 ), "new Input::ISIS");
48
49 ok(my $maxmfn = $isis->open(
50 path => $isis_file,
51 code_page => 'cp852', # database encoding
52 lookup_coderef => sub {
53 my $rec = shift || return;
54 $lookup->add( $rec );
55 },
56 ), "Input::ISIS->open");
57
58 ok(my $path = tempdir( CLEANUP => 1 ), "path");
59
60 ok(my $db = new WebPAC::Store(
61 path => $path,
62 database => '.',
63 ), "new Store");
64
65 ok(my $norm_pl = read_file( $normalize_set_pl ), "set definitions: $normalize_set_pl" );
66
67 ok(my $out = new WebPAC::Output::TT(
68 include_path => "$abs_path../conf/output/tt",
69 filters => { foo => sub { shift } },
70 ), "new Output::TT");
71
72 diag " lookup => ",Dumper($lookup->lookup_hash) if ($debug);
73
74 my $t_norm = 0;
75
76 foreach my $pos ( 0 ... $isis->size ) {
77
78 my $row = $isis->fetch || next;
79
80 diag " row $pos => ",Dumper($row) if ($debug);
81
82 my $t = time();
83 ok( my $ds = WebPAC::Normalize::data_structure(
84 lookup => $lookup->lookup_hash,
85 row => $row,
86 rules => $norm_pl,
87 ), "Set data_structure");
88 $t_norm += time() - $t;
89
90 diag " ds $pos => ",Dumper($ds) if ($debug);
91
92 ok(my $html = $out->apply(
93 template => 'html.tt',
94 data => $ds,
95 ), "apply");
96
97 $html =~ s#\s*[\n\r]+\s*##gs;
98
99 #diag $html;
100
101 };
102
103 diag sprintf("timings: %.2fs\n", $t_norm);

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26