Web-based tests now apply configured rule-sets before running. At
[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 my $db = ZOOM::IRSpy::connect_to_registry();
38 my $spy = new ZOOM::IRSpy::Web($db,
39                                admin => "fruitbat");
40 $spy->log_init_level($YAZ_LOG);
41 $spy->targets(@id) if !$allTargets;
42 foreach my $rulesFile (@rulesFiles) {
43     $spy->apply_rules($ENV{DOCUMENT_ROOT} . "/../../etc/" . $rulesFile);
44     print "applied rules '$rulesFile'\n";
45 }
46 $spy->initialise($test);
47 my $res = $spy->check();
48 print "<p>\n";
49 if ($res == 0) {
50     print "<b>All tests were attempted</b>\n";
51 } else {
52     print "<b>$res tests were skipped</b>\n";
53 }
54 print "</p>\n";
55 }
56 </%perl>