From 4f35e16275f20aa6d9c6b023f9f4ef4dce21afed Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Thu, 16 Sep 2004 15:07:55 +0000 Subject: [PATCH] After fixing the sorting bug, enabled its tests in t/07sort.t. At the same time removed the crashing version of the test, as its test is included in 07. --- perl/t/07_sort.CRASH.t | 79 ------------------------------------------------ perl/t/07_sort.t | 21 ++++++------- 2 files changed, 10 insertions(+), 90 deletions(-) delete mode 100644 perl/t/07_sort.CRASH.t diff --git a/perl/t/07_sort.CRASH.t b/perl/t/07_sort.CRASH.t deleted file mode 100644 index 5421909..0000000 --- a/perl/t/07_sort.CRASH.t +++ /dev/null @@ -1,79 +0,0 @@ -#!perl -# ============================================================================= -# $Id: 07_sort.CRASH.t,v 1.1 2004-09-15 14:11:06 heikki Exp $ -# -# Perl API header -# ============================================================================= -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - } - push (@INC,'demo','blib/lib','blib/arch'); -} - -use strict; -use warnings; - -use Test::More skip_all =>"sort into a new rset crashes due to rset_dup bug"; -#use Test::More tests => 13; - -# ---------------------------------------------------------------------------- -# Session opening and closing -BEGIN { - use IDZebra; - unlink("test07.log"); - IDZebra::logFile("test07.log"); -# IDZebra::logLevel(0x4F); -# IDZebra::logLevel(15); - use_ok('IDZebra::Session'); - use_ok('pod'); -} - - -# ---------------------------------------------------------------------------- -# Session opening and closing -my $sess = IDZebra::Session->open(configFile => 'demo/zebra.cfg', - groupName => 'demo2'); -# ---------------------------------------------------------------------------- -# Insert some test data -my $ret; -my $sysno; -my $F; -my $filecount=0; -$sess->init; -$sess->begin_trans; -$sess->databases('demo1', 'demo2'); -$ret=$sess->end_trans; - -$sess->begin_trans; -for $F () -{ - ($ret,$sysno)=$sess->insert_record (file=>$F, recordType => 'grs.perl.pod'); - ok( $ret==0, "inserted $F"); - #print STDERR "Inserted $F ok. ret=$ret sys=$sysno\n"; - $filecount++; -} -$ret=$sess->end_trans; -ok($filecount>0,"Inserted files"); -is($ret->{inserted},$filecount, "Inserted all"); - - -# ----------------------------------------------------------------------------- -# Search 1 database, retrieve records, sort "titles" locally (dangerous!) - -my $rs1 = $sess->search(cqlmap => 'demo/cql.map', - cql => 'IDZebra', - databases => [qw(demo1)]); -$rs1 = $rs1->sort('1=4 id'); - -# ----------------------------------------------------------------------------- -# Sort descending, new rs - -my $rs2 = $rs1->sort('1=4 id'); - -isa_ok ($rs2, 'IDZebra::Resultset'); - -# ---------------------------------------------------------------------------- -# Close session -$sess->close; - diff --git a/perl/t/07_sort.t b/perl/t/07_sort.t index b106420..4081dff 100644 --- a/perl/t/07_sort.t +++ b/perl/t/07_sort.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 07_sort.t,v 1.3 2004-09-15 14:11:06 heikki Exp $ +# $Id: 07_sort.t,v 1.4 2004-09-16 15:07:55 heikki Exp $ # # Perl API header # ============================================================================= @@ -14,7 +14,7 @@ BEGIN { use strict; use warnings; -use Test::More tests => 24; +use Test::More tests => 32; # ---------------------------------------------------------------------------- # Session opening and closing @@ -106,28 +106,27 @@ ok (($sortError == 0), "sorting ascending"); # ----------------------------------------------------------------------------- # Sort descending, new rs -TODO: { - todo_skip "Sort into different rset crashes", 3; -print STDERR "\nSort #4: $rs1\n"; +#TODO: { +# todo_skip "Sort into different rset crashes", 3; my $rs2 = $rs1->sort('1=4 id'); -print STDERR "\nSort #5: $rs1\n"; isa_ok ($rs2, 'IDZebra::Resultset'); $wasError = 0; $sortError = 0; -foreach my $rec ($rs1->records()) { +foreach my $rec ($rs2->records()) { if ($rec->{errCode}) { $wasError++; } my ($title) = ($rec->buf =~ /\n\s*package\s+([a-zA-Z0-9:]+)\s*\;\s*\n/); - if ($sortedi[$rs2->count - $rec->position] ne $title) { $sortError++; } + if ($sorted[$rs2->count - $rec->position] ne $title) { $sortError++; } + is ($title, $sorted[$rs2->count - $rec->position], "sort order $title"); } -ok (($wasError == 0), "retrieval"); -ok (($sortError == 0), "sorting descending"); +is ($wasError,0 , "retrieval"); +is ($sortError, 0, "sorting descending"); -} # end of SKIP +# } # end of SKIP # ----------------------------------------------------------------------------- # Search + sort ascending -- 1.7.10.4