Merge branch 'rertzinger/generic-load-save' into weechat
[videosite.git] / videosite-test.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Getopt::Long;
5 use File::Spec;
6 use File::Basename;
7 use Module::Load;
8 use Cwd qw(realpath);
9 use Carp;
10
11 $SIG{ __DIE__ } = sub { Carp::confess( @_ ) };
12
13 my $debug = 0;
14 my %config = (
15     mode => 'download',
16     getter => 'filegetter',
17 );
18 my $success = 0;
19 my $fail = 0;
20 my $notest = 0;
21
22 push(@INC, dirname(realpath($0)));
23 load 'libvideosite';
24
25 unless(libvideosite::register_api({
26     _debug => sub { return $debug },
27 })) {
28     die("Error registering API: $libvideosite::error");
29 }
30
31 unless(libvideosite::init()) {
32     die("Could not init libvideosite: $libvideosite::error");
33 }
34
35 select(STDOUT);
36 $| = 1;
37 printf("Doing self tests:\n");
38 foreach my $g (libvideosite::_grabbers()) {
39     my $r;
40
41     if (@ARGV) {
42         my $found;
43
44         # If there are grabber names given on the command line check
45         # the current name against that list and skip if not present
46         $found = grep { $_ eq $g->{'NAME'} } @ARGV;
47
48         if ($found == 0) {
49             next;
50         }
51     }
52
53     printf("  %s...", $g->{'NAME'});
54     $r = $g->_selftest();
55     if(defined($r)) {
56         if ($r == 1) {
57             printf(" OK\n");
58             $success++;
59         } else {
60             printf(" no self test\n");
61             $notest++;
62         }
63     } else {
64         $fail++;
65     }
66 }
67
68 printf("\n\n%d succeeded\n%d failed\n%d not testable\n", $success, $fail, $notest);