d7fda0679fb0847f537fcdaf31085f6dff47dd8c
[irspy-moved-to-github.git] / bin / irspy.pl
1 #!/usr/bin/perl -w
2
3 # $Id: irspy.pl,v 1.22 2007-02-23 16:44:50 mike Exp $
4 #
5 # Run like this:
6 #       YAZ_LOG=irspy,irspy_test IRSPY_SAVE_XML=1 perl -I../lib irspy.pl -t Quick localhost:8018/IR-Explain---1 z3950.loc.gov:7090/Voyager bagel.indexdata.dk/gils bagel.indexdata.dk:210/marc
7 # Available log-levels are as follows:
8 #       irspy -- high-level application logging
9 #       irspy_debug -- low-level debugging (not very interesting)
10 #       irspy_event -- invocations of ZOOM_event() and individual events
11 #       irspy_unhandled -- unhandled events (not very interesting)
12 #       irspy_test -- adding, queueing and running tests
13 #       irspy_task -- adding, queueing and running tasks
14
15 use strict;
16 use warnings;
17 use Getopt::Std;
18 use ZOOM::IRSpy::Web;
19
20 my %opts;
21 if (!getopts('wt:af:', \%opts) || @ARGV < 1) {
22     print STDERR "\
23 Usage $0: [options] <IRSpy-database> [<target> ...]
24         -w              Use ZOOM::IRSpy::Web subclass
25         -t <test>       Run the specified <test> [default: all tests]
26         -a              Test all targets (slow!)
27         -f <query>      Test targets found by the specified query
28 ";
29     exit 1;
30 }
31
32 my($dbname, @targets) = @ARGV;
33 my $class = "ZOOM::IRSpy";
34 $class .= "::Web" if $opts{w};
35
36 my $spy = $class->new($dbname, "admin", "fruitbat");
37 if (@targets) {
38     $spy->targets(@targets);
39 } elsif ($opts{f}) {
40     $spy->find_targets($opts{f});
41 } elsif (!$opts{a}) {
42     print STDERR "$0: specify -a, -f <query> or list of targets\n";
43     exit 1;
44 }
45
46 $spy->initialise();
47 my $res = $spy->check($opts{t});
48 if ($res == 0) {
49     print "All tests were attempted\n";
50 } else {
51     print "$res tests were skipped\n";
52 }
53
54
55 # Fake the HTML::Mason class that ZOOM::IRSpy::Web uses
56 package HTML::Mason::Commands;
57 BEGIN { our $m = bless {}, "HTML::Mason::Commands" }
58 sub flush_buffer { print shift(), " flushing\n" if 0 }