Use new $node->next()/address() to correctly skip tests.
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy.pm
index 6997079..b3c0aeb 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: IRSpy.pm,v 1.69 2007-02-26 14:49:23 mike Exp $
+# $Id: IRSpy.pm,v 1.72 2007-02-28 17:36:00 mike Exp $
 
 package ZOOM::IRSpy;
 
@@ -199,8 +199,9 @@ sub initialise {
 
     $this->log("irspy_debug", "query '", $this->{query}, "'");
     my $rs = $this->{conn}->search(new ZOOM::Query::CQL($this->{query}));
+    $this->log("irspy", "'", $this->{query}, "' found ",
+              $rs->size(), " target records");
     delete $this->{query};     # No longer needed at all
-    $this->log("irspy_debug", "found ", $rs->size(), " target records");
     my $gatherTargets = !$this->{targets};
     foreach my $i (1 .. $rs->size()) {
        my $target = _render_record($rs, $i-1, "id");
@@ -262,7 +263,8 @@ sub _irspy_to_zeerex {
 
     if ($save_xml) {
        unlink('/tmp/irspy_orig.xml');
-       open FH, '>/tmp/irspy_orig.xml';
+       open FH, '>/tmp/irspy_orig.xml'
+           or die "can't write irspy_orig.xml: $!";
        print FH $irspy_doc->toString();
        close FH;
     }
@@ -270,7 +272,8 @@ sub _irspy_to_zeerex {
     my $result = $this->{irspy_to_zeerex_style}->transform($irspy_doc, %params);
     if ($save_xml) {
        unlink('/tmp/irspy_transformed.xml');
-       open FH, '>/tmp/irspy_transformed.xml';
+       open FH, '>/tmp/irspy_transformed.xml'
+           or die "can't write irspy_transformed.xml: $!";
        print FH $result->toString();
        close FH;
     }
@@ -346,6 +349,7 @@ sub check {
     $tname = "Main" if !defined $tname;
     $this->{tree} = $this->_gather_tests($tname)
        or die "No tests defined for '$tname'";
+    $this->{tree}->resolve();
     #$this->{tree}->print(0);
     my $nskipped = 0;
 
@@ -474,12 +478,22 @@ sub check {
            $conn->next_task(0);
            if ($res == ZOOM::IRSpy::Status::TEST_BAD) {
                my $address = $conn->option('current_test_address');
-               ($address, my $n) = $this->_last_sibling_test($address);
-               if (defined $address) {
-                   $conn->log("irspy_test", "skipped $n tests");
-                   $conn->option(current_test_address => $address);
-                   $nskipped += $n;
+               $conn->log("irspy", "top-level test failed!")
+                   if $address eq "";
+               my $node = $this->{tree}->select($address);
+               my $skipcount = 0;
+               while (defined $node->next() &&
+                      length($node->next()->address()) >= length($address)) {
+                   $conn->log("irspy_debug", "skipping from '",
+                              $node->address(), "' to '",
+                              $node->next()->address(), "'");
+                   $node = $node->next();
+                   $skipcount++;
                }
+
+               $conn->option(current_test_address => $node->address());
+               $conn->log("irspy_test", "skipped $skipcount tests");
+               $nskipped += $skipcount;
            }
 
        } elsif ($res == ZOOM::IRSpy::Status::TEST_SKIPPED) {