File: 10-output.t

package info (click to toggle)
libtemplate-plugin-latex-perl 3.06-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 280 kB
  • ctags: 54
  • sloc: perl: 572; makefile: 2
file content (112 lines) | stat: -rwxr-xr-x 2,287 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/perl --  ========================================== -*-perl-*-
#
# t/10-output.t
#
# Test the Latex plugin's ability to generate output files.
#
# Written by Andy Wardley <abw@wardley.org>
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
#========================================================================

use strict;
use warnings;
use FindBin qw($Bin);
use Cwd qw(abs_path);
use lib ( abs_path("$Bin/../lib"), "$Bin/lib" );
use Carp;
use Template;
use Template::Test;
use Template::Plugin::Latex;
use File::Spec;

my $run_tests = $ENV{LATEX_TESTING} || $ENV{ALL_TESTING};

my $out = 'output';
my $dir = -d 't' ? File::Spec->catfile('t', $out) : $out;

my $files = {
    pdf => 'test1.pdf',
    ps  => 'test1.ps',
    dvi => 'test1.dvi',
};
clean_file($_) for values %$files;
    
my $ttcfg = {
    OUTPUT_PATH => $dir,
    VARIABLES => {
        dir   => $dir,
        file  => $files,
        check => \&check_file,
    },
};

if ($run_tests){
    test_expect(\*DATA, $ttcfg);
} else {
    ok(1, 'Skipping tests, LATEX_TESTING not set');
}

sub clean_file {
    my $file = shift;
    my $path = File::Spec->catfile($dir, $file);
    if (-f $path) {
	unlink($path) or carp "cannot unlink $file ($!)";
    }
}

sub check_file {
    my $file = shift;
    my $path = File::Spec->catfile($dir, $file);
    return -f $path ? "PASS - $file exists" : "FAIL - $file does not exist";
}

__END__

-- test --
[% USE Latex;
   FILTER latex(file.pdf)
-%]
\documentclass{article}
\begin{document}
This is a PDF document generated by 
Latex and the Template Toolkit.
\end{document}
[% END -%]
[% check(file.pdf) %]
-- expect --
-- process --
PASS - [% file.pdf %] exists

-- test --
[% USE Latex;
   FILTER latex(output=file.ps)
-%]
\documentclass{article}
\begin{document}
This is a PostScript document generated by 
Latex and the Template Toolkit.
\end{document}
[% END -%]
[% check(file.ps) %]
-- expect --
-- process --
PASS - [% file.ps %] exists

-- test --
[% USE Latex;
   FILTER latex(file.dvi)
-%]
\documentclass{article}
\begin{document}
This is a DVI document generated by 
Latex and the Template Toolkit.
\end{document}
[% END -%]
[% check(file.dvi) %]
-- expect --
-- process --
PASS - [% file.dvi %] exists