Better sample command-line.
[irspy-moved-to-github.git] / bin / irspy.pl
1 #!/usr/bin/perl -w
2
3 # $Id: irspy.pl,v 1.17 2006-11-28 12:01:54 mike Exp $
4 #
5 # Run like this:
6 #       YAZ_LOG=irspy,irspy_test perl -I ../lib irspy.pl -t Quick localhost:3313/IR-Explain---1 bagel.indexdata.dk/gils z3950.loc.gov:7090/Voyager 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:', \%opts) || @ARGV < 1) {
22     print STDERR "\
23 Usage $0: [options] <IRSpy-database> [<target> ...]
24 If no targets are specified, all targets in DB are tested.
25         -w              Use ZOOM::IRSpy::Web subclass
26         -t <test>       Run the specified <test> [default: all tests]
27 ";
28     exit 1;
29 }
30
31 my($dbname, @targets) = @ARGV;
32 my $class = "ZOOM::IRSpy";
33 $class .= "::Web" if $opts{w};
34
35 my $spy = $class->new($dbname, "admin", "fruitbat");
36 $spy->targets(@targets) if @targets;
37 $spy->initialise();
38 my $res = $spy->check($opts{t});
39 if ($res == 0) {
40     print "All tests were run\n";
41 } else {
42     print "$res tests were skipped\n";
43 }
44
45
46 # Fake the HTML::Mason class that ZOOM::IRSpy::Web uses
47 package HTML::Mason::Commands;
48 BEGIN { our $m = bless {}, "HTML::Mason::Commands" }
49 sub flush_buffer { print shift(), " flushing\n" if 0 }