1 |
#!/usr/bin/perl |
#!/usr/bin/perl -w |
2 |
# -*- Mode: Perl -*- |
|
3 |
# $Basename: wais.t $ |
use Test::More; |
4 |
# $Revision: 1.6 $ |
use blib; |
|
# Author : Ulrich Pfeifer |
|
|
# Created On : Tue Dec 12 16:55:05 1995 |
|
|
# Last Modified By: Ulrich Pfeifer |
|
|
# Last Modified On: Wed Nov 12 19:46:12 1997 |
|
|
# Language : Perl |
|
|
# Update Count : 157 |
|
|
# Status : Unknown, Use with caution! |
|
|
# |
|
|
# (C) Copyright 1997, Ulrich Pfeifer, all rights reserved. |
|
|
# |
|
|
# |
|
5 |
|
|
6 |
use WAIT::Database; |
use WAIT::Database; |
7 |
use WAIT::Wais; |
use WAIT::Wais; |
8 |
use Cwd; |
use Cwd; |
9 |
use strict; |
use strict; |
10 |
|
use File::Path qw(mkpath rmtree); |
11 |
|
|
12 |
|
plan tests => 10; |
13 |
|
|
14 |
$SIG{__DIE__} = $SIG{INT} = \&cleanup; |
$SIG{__DIE__} = $SIG{INT} = \&cleanup; |
15 |
|
|
16 |
my $pwd = getcwd(); |
my $pwd = getcwd(); |
17 |
print "$^X -Iblib blib/script/bibdb -dir /tmp -database sample\n"; |
mkpath "/tmp/wait-test-$$"; |
18 |
system "$^X -Iblib blib/script/bibdb -dir /tmp -database sample > /dev/null 2>&1"; |
print "$^X -Mblib blib/script/bibdb -dir /tmp/wait-test-$$ -database sample\n"; |
19 |
|
system "$^X -Mblib blib/script/bibdb -dir /tmp/wait-test-$$ -database sample > /dev/null 2>&1"; |
20 |
|
|
21 |
|
use Fcntl; |
22 |
|
|
23 |
|
ok( |
24 |
|
my $db = WAIT::Database->open( |
25 |
|
name => 'sample', |
26 |
|
'directory' => "/tmp/wait-test-$$", |
27 |
|
'mode' => O_RDWR, |
28 |
|
), "open"); |
29 |
|
|
30 |
|
ok(my $tb = $db->table(name => 'bibdb'), "table"); |
31 |
|
|
32 |
|
ok($tb->open, "open"); |
33 |
|
|
34 |
|
ok($tb->set(top => 1), "set(top => 1)"); |
35 |
|
|
36 |
print "1..3\n"; |
ok($tb->close, "tb->close"); |
37 |
my $db = '/tmp/sample/bibdb'; |
ok($db->close, "db->close"); |
38 |
|
|
39 |
|
$db = "/tmp/wait-test-$$/sample/bibdb"; |
40 |
print "# Testing WAIT searches\n"; |
print "# Testing WAIT searches\n"; |
41 |
my $result = WAIT::Wais::Search({ |
ok(my $result = WAIT::Wais::Search({ |
42 |
'query' => 'pfeifer', |
'query' => 'pfeifer', |
43 |
'database' => $db, |
'database' => $db, |
44 |
}); |
}), |
45 |
|
"WAIT::Wais::Search"); |
|
&headlines($result); |
|
|
my $id = ($result->header)[9]->[6]; |
|
|
#$length = ($result->header)[9]->[3]; |
|
|
my @header = $result->header; |
|
46 |
|
|
47 |
#my $types=($result->header)[9]->[5]; |
ok(&headlines($result), "headlines"); |
|
#print STDERR "\n## @$types\n"; |
|
48 |
|
|
49 |
my $short = ($result->header)[0]->[6]; |
my @header = $result->header; |
50 |
|
my $N; |
51 |
|
for (my $n=0;$n<@header;$n++) { |
52 |
|
$N = $n if ${$header[$n]->[6]} eq "wait;/tmp/wait-test-$$/sample/bibdb;13"; |
53 |
|
} |
54 |
|
my $id = ($result->header)[$N]->[6]; |
55 |
|
my $short = ($result->header)[$N]->[6]; |
56 |
|
|
57 |
my $result_text = $result->text; |
my $result_text = $result->text; |
58 |
print $#header >= 14 ? |
ok($#header >= 14, "\$\#header[$#header]result_text[$result_text]"); |
|
"ok 1\n" : |
|
|
"#\$\#header[$#header]result_text[$result_text]\nnot ok 1\n"; |
|
59 |
|
|
60 |
print "# Testing local retrieve\n"; |
print "# Testing local retrieve\n"; |
61 |
$result = WAIT::Wais::Retrieve( |
$result = WAIT::Wais::Retrieve( |
66 |
); |
); |
67 |
$result_text = $result->text; |
$result_text = $result->text; |
68 |
$result_text =~ s/^/# /gm; |
$result_text =~ s/^/# /gm; |
69 |
print $result_text =~ m!Pfeifer/Fuhr:93! ? |
ok($result_text =~ m!Pfeifer/Fuhr:93!, "result_text[$result_text]"); |
|
"ok 2\n" : |
|
|
"# result_text[$result_text]\nnot ok 2\n"; |
|
70 |
|
|
71 |
my @x = $short->split; |
my @x = $short->split; |
72 |
print $x[2] =~ /test.ste 3585 393$/ || $x[2] == 1 ? |
ok($x[2] =~ /test.ste 3585 393$/ || $x[2] == 13, "\@x:[@x]"); |
|
"ok 3\n" : |
|
|
"# \@x:[@x]\nnot ok 3\n"; |
|
73 |
|
|
74 |
|
|
75 |
####################################################################### |
####################################################################### |
85 |
} |
} |
86 |
} |
} |
87 |
|
|
88 |
|
# releasing 1 pending lock... at .../LockFile/Simple.pm |
89 |
|
open STDERR, '>/dev/null'; |
90 |
|
|
91 |
sub cleanup |
sub cleanup |
92 |
{ |
{ |
93 |
system 'rm -rf /tmp/sample'; |
rmtree "/tmp/wait-test-$$"; |
94 |
} |
} |
95 |
|
|
96 |
|
|