xmltv/t test_tv_imdb.t,NONE,1.1
Jerry Veldhuis <[email protected]>
| Newsgroups | gmane.comp.tv.xmltv.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/xmltv/xmltv/t In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv30329/t Added Files: test_tv_imdb.t Log Message: tv_imdb test cases --- NEW FILE: test_tv_imdb.t --- #!/usr/bin/perl # # Run tv_split on some input files and check the output looks # reasonable. This is not done by diffing against expected output but # by reading the files generated and making sure channels and dates # seem to match. # # -- Ed Avis, [email protected], 2003-10-04 # $Id: test_tv_imdb.t,v 1.1 2015/03/08 19:45:52 jveldhuis Exp $ # use warnings; use strict; use Getopt::Long; use Cwd; use File::Temp qw(tempdir); use File::Copy; use XMLTV::Usage <<END $0: test suite for tv_split usage: $0 [--tests-dir DIR] [--verbose] END ; my $tests_dir = 't/data-tv_imdb'; # where to find input XML files die "no directory $tests_dir" if not -d $tests_dir; my $cmds_dir = 'blib/script'; # directory tv_split lives in die "no directory $cmds_dir" if not -d $cmds_dir; my $verbose = 0; GetOptions('tests-dir=s' => \$tests_dir, 'cmds-dir=s' => \$cmds_dir, 'verbose' => \$verbose) or usage(0); usage(0) if @ARGV; #my $tmpDir = tempdir(CLEANUP => 1); my $tmpDir = "/tmp/jv1"; mkdir($tmpDir); system("/bin/cp -rp $tests_dir/lists $tmpDir/"); my @inputs = <$tests_dir/*.xml>; my @inputs_gz = <$tests_dir/*.xml.gz>; s/\.gz$// foreach @inputs_gz; @inputs = sort (@inputs, @inputs_gz); die "no test cases (*.xml, *.xml.gz) found in $tests_dir" if not @inputs; print '1..', (scalar(@inputs)+1), "\n"; # build database with test data my @cmd = ("$cmds_dir/tv_imdb", '--quiet', '--imdbdir', "$tmpDir", '--prepStage', 'all', ">", "$tmpDir/txt.log", "2>&1"); #print STDERR "============================================\n"; #print STDERR "running: ". join(' ', @cmd)."\n"; #print STDERR "============================================\n"; my $r=system(join(' ', @cmd)); #print STDERR "status: $r\n"; # Check command return status. if ($r) { my ($status, $sig, $core) = ($? >> 8, $? & 127, $? & 128); if ($sig) { die "@cmd killed by signal $sig, aborting"; } warn "@cmd failed: $status, $sig, $core\n"; print "not ok 1\n"; exit(1); } print "ok 1\n"; my $n = 1; my $old_cwd; INPUT: foreach my $input (@inputs) { ++$n; if (defined $old_cwd) { chdir $old_cwd or die "cannot chdir to $old_cwd: $!"; } else { $old_cwd = cwd; } use File::Basename; my $output="$tmpDir/".File::Basename::basename($input)."-output.xml"; # Make temporary directory and split into it. my $cmd="$cmds_dir/tv_imdb --quiet --imdbdir '$tmpDir' --with-keywords --with-plot < $input > '$output' 2>&1"; if ( $input=~m/movies-only/ ) { $cmd="$cmds_dir/tv_imdb --movies-only --quiet --imdbdir '$tmpDir' --with-keywords --with-plot < $input > '$output' 2>&1"; } #print STDERR "\nRUN:$cmd\n"; my $r = system($cmd); # Check command return status. if ($r) { my ($status, $sig, $core) = ($? >> 8, $? & 127, $? & 128); if ($sig) { die "$cmd killed by signal $sig, aborting"; } warn "$cmd failed: $status, $sig, $core\n"; print "not ok $n\n"; next; } open(FD, "$input-expected") || die "$input-expected:$!"; open(OD, "$output") || die "$output:$!"; while(<FD>) { my $in=$_; my $out=<OD>; chomp($in); chomp($out); if ( $in ne $out ) { #system("cp $dir/output.xml /tmp/$n-output"); #system("cp $input-expected /tmp/$n-expected"); warn "$input failed to match expected ('$in' != '$out')\n"; print "not ok $n\n"; last; } } close(FD); close(OD); print "ok $n\n"; } ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/