[Po4a-commits] "po4a/t 06-addendums.t,NONE,1.1"

Denis Barbier barbier-guest at alioth.debian.org
Wed Jan 20 23:22:43 UTC 2010


Update of /cvsroot/po4a/po4a/t
In directory alioth:/tmp/cvs-serv31238

Added Files:
	06-addendums.t 
Log Message:
Add t/06-addendums.t and t/data-06 to test new features with addenda


--- NEW FILE: 06-addendums.t ---
#! /usr/bin/perl
# Addenda modifiers tester.

#########################

use strict;
use warnings;

my @tests;

mkdir "t/tmp" unless -e "t/tmp";

push @tests, {
  'run' => 'perl ../po4a-translate -k 0 -f text -m data-06/Titles.asciidoc -p /dev/null -l tmp/Titles.trans ' .
		'-a data-06/addendum1 -a data-06/addendum2 -a data-06/addendum3',
  'test'=> 'diff -U 50 data-06/Titles.trans.add123 tmp/Titles.trans',
  'doc' => 'translate with addendum1, 2 and 3'
  };

push @tests, {
  'run' => 'perl ../po4a-translate -k 0 -f text -m data-06/Titles.asciidoc -p /dev/null -l tmp/Titles.trans ' .
		'-a @data-06/addendum123.list',
  'test'=> 'diff -U 50 data-06/Titles.trans.add123 tmp/Titles.trans',
  'doc' => 'translate with @addendum'
  };

push @tests, {
  'run' => 'perl ../po4a-translate -k 0 -f text -m data-06/Titles.asciidoc -p /dev/null -l tmp/Titles.trans ' .
		'-a !data-06/addendum2 -a @data-06/addendum123.list',
  'test'=> 'diff -U 50 data-06/Titles.trans.add13 tmp/Titles.trans',
  'doc' => 'translate with !addendum'
  };

push @tests, {
  'run' => 'perl ../po4a-translate -k 0 -f text -m data-06/Titles.asciidoc -p /dev/null -l tmp/Titles.trans ' .
		'-a ?/does/not/exist',
  'test'=> 'diff -U 50 data-06/Titles.asciidoc tmp/Titles.trans',
  'doc' => 'translate with non-existing ?addendum'
  };

push @tests, {
  'run' => 'perl ../po4a-translate -k 0 -f text -m data-06/Titles.asciidoc -p /dev/null -l tmp/Titles.trans ' .
		'-a @data-06/addendum123.list2',
  'test'=> 'diff -U 50 data-06/Titles.trans.add1 tmp/Titles.trans',
  'doc' => 'translate with recursive @addendum'
  };

use Test::More tests => 10; # tests * (run+validity)

for (my $i=0; $i<scalar @tests; $i++) {
    chdir "t" || die "Can't chdir to my test directory";
    
    my ($val,$name);

    my $cmd=$tests[$i]{'run'};
    $val=system($cmd);
    
    $name=$tests[$i]{'doc'}.' runs';
    ok($val == 0,$name);
    diag(%{$tests[$i]{'run'}}) unless ($val == 0);

    SKIP: {
    	skip ("Command don't run, can't test the validity of its return",1)
	     if $val;
        $val=system($tests[$i]{'test'});	
    	$name=$tests[$i]{'doc'}.' returns what is expected';
        ok($val == 0,$name);
	unless ($val == 0) {
	    my $add = $tests[$i]{'run'};
	    $add =~ s/.*-a (\S*) .*/$1/;
	    $add = `cat $add | head -n 1`;
	    diag ("Failed (retval=$val) on:");
	    diag ($tests[$i]{'test'});
	    diag ("Was created with:");
	    diag ($tests[$i]{'run'});
	    diag ("Header was: $add");
	}
    }

#    system("rm -f tmp/* 2>&1");

    chdir ".." || die "Can't chdir back to my root";
}

0;




More information about the Po4a-commits mailing list