Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/irspy
[irspy-moved-to-github.git] / web / htdocs / details / check.mc
1 <%args>
2 @id
3 $test => "Quick"
4 $really => 0
5 $YAZ_LOG => "irspy,irspy_test"
6 </%args>
7 <%perl>
8 my @rulesFiles = ("dallas.rules");
9
10 my $allTargets = (@id == 1 && $id[0] eq "");
11 if ($allTargets && !$really) {
12 </%perl>
13      <h2>Warning</h2>
14      <p class="error">
15       Testing all the targets is a very slow process.
16       Are you sure you want to do this?
17      </p>
18      <p>
19       <a href="?really=1&amp;test=Quick">Yes: Quick Test</a><br/>
20       <a href="?really=1&amp;test=Main">Yes: Full Test</a><br/>
21       <a href="/">No</a><br/>
22      </p>
23 <%perl>
24 } else {
25
26 print "<h2>Testing ...</h2>\n";
27 print "     <ul>\n", join("", map { "      <li>$_</li>\n" } @id), "</ul>\n"
28     if !$allTargets;
29 print "<p>Logging: <tt>", join("/", split /,/, $YAZ_LOG), "</tt></p>\n";
30 $m->flush_buffer();
31
32 # Turning on autoflush with $m->autoflush() doesn't seem to work if
33 # even if the "MasonEnableAutoflush" configuration parameter is turned
34 # on in the HTTP configuration, so we don't even try -- instead,
35 # having ZOOM::IRSpy::Web::log() explicitly calling $m->flush_buffer()
36
37 $ZOOM::IRSpy::xslt_max_depth = 3500; ### Hideous hack
38 my $db = ZOOM::IRSpy::connect_to_registry();
39 my $spy = new ZOOM::IRSpy::Web($db,
40                                admin => "fruitbat");
41 $spy->log_init_level($YAZ_LOG);
42 $spy->targets(@id) if !$allTargets;
43 foreach my $rulesFile (@rulesFiles) {
44     $spy->apply_rules($ENV{DOCUMENT_ROOT} . "/../../etc/" . $rulesFile);
45     print "applied rules '$rulesFile'\n";
46 }
47 $spy->initialise($test);
48 my $res = $spy->check();
49 print "<p>\n";
50 if ($res == 0) {
51     print "<b>All tests were attempted</b>\n";
52 } else {
53     print "<b>$res tests were skipped</b>\n";
54 }
55 print "</p>\n";
56 }
57 </%perl>