1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
# -*- Mode: Perl -*- |
|
3 |
# $Basename: wais.t $ |
use Test::More; |
4 |
# $Revision: 1.14 $ |
use blib; |
|
# Author : Ulrich Pfeifer |
|
|
# Created On : Tue Dec 12 16:55:05 1995 |
|
|
# Last Modified By: Ulrich Pfeifer |
|
|
# Last Modified On: Sat Nov 11 16:33:54 2000 |
|
|
# Language : Perl |
|
|
# Update Count : 187 |
|
|
# 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; |
9 |
use strict; |
use strict; |
10 |
use File::Path qw(mkpath rmtree); |
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 |
mkpath "/tmp/wait-test-$$"; |
mkpath "/tmp/wait-test-$$"; |
18 |
print "$^X -Mblib blib/script/bibdb -dir /tmp/wait-test-$$ -database sample\n"; |
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"; |
system "$^X -Mblib blib/script/bibdb -dir /tmp/wait-test-$$ -database sample > /dev/null 2>&1"; |
|
print "1..7\n"; |
|
20 |
|
|
21 |
use Fcntl; |
use Fcntl; |
22 |
if (1) { |
|
23 |
|
ok( |
24 |
my $db = WAIT::Database->open( |
my $db = WAIT::Database->open( |
25 |
name => 'sample', |
name => 'sample', |
26 |
'directory' => "/tmp/wait-test-$$", |
'directory' => "/tmp/wait-test-$$", |
27 |
'mode' => O_RDWR, |
'mode' => O_RDWR, |
28 |
); |
), "open"); |
|
print "not " unless $db; |
|
|
print "ok 1\n"; |
|
|
my $tb = $db->table(name => 'bibdb'); |
|
|
print "not " unless $tb; |
|
|
print "ok 2\n"; |
|
|
|
|
|
print "not " unless $tb->open; |
|
|
print "ok 3\n"; |
|
29 |
|
|
30 |
print "not " unless $tb->set(top => 1); |
ok(my $tb = $db->table(name => 'bibdb'), "table"); |
31 |
print "ok 4\n"; |
|
32 |
|
ok($tb->open, "open"); |
33 |
|
|
34 |
$tb->close; |
ok($tb->set(top => 1), "set(top => 1)"); |
|
$db->close; |
|
|
} |
|
35 |
|
|
36 |
|
ok($tb->close, "tb->close"); |
37 |
|
ok($db->close, "db->close"); |
38 |
|
|
39 |
my $db = "/tmp/wait-test-$$/sample/bibdb"; |
$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]; |
|
|
# no strict order |
|
|
$$id = "wait;/tmp/wait-test-$$/sample/bibdb;13"; |
|
|
#$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 5\n" : |
|
|
"#\$\#header[$#header]result_text[$result_text]\nnot ok 5\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 6\n" : |
|
|
"# result_text[$result_text]\nnot ok 6\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 7\n" : |
|
|
"# \@x:[@x]\nnot ok 7\n"; |
|
73 |
|
|
74 |
|
|
75 |
####################################################################### |
####################################################################### |