fix-qdf.test
2.63 KB
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
#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;
unshift(@INC, '.');
require qpdf_test_helpers;
chdir("qpdf") or die "chdir testdir failed: $!\n";
require TestDriver;
cleanup();
my $td = new TestDriver('fix-qdf');
my $n_tests = 11;
for (my $n = 1; $n <= 2; ++$n)
{
$td->runtest("fix-qdf $n",
{$td->COMMAND => "fix-qdf fix$n.qdf"},
{$td->FILE => "fix$n.qdf.out",
$td->EXIT_STATUS => 0});
$td->runtest("fix-qdf $n with named output",
{$td->COMMAND => "fix-qdf fix$n.qdf a.pdf"},
{$td->STRING => "",
$td->EXIT_STATUS => 0});
$td->runtest("check fix-qdf $n output",
{$td->FILE => "a.pdf"},
{$td->FILE => "fix$n.qdf.out"});
$td->runtest("identity fix-qdf $n",
{$td->COMMAND => "fix-qdf fix$n.qdf.out"},
{$td->FILE => "fix$n.qdf.out",
$td->EXIT_STATUS => 0});
}
if (! (($^O eq 'MSWin32') || ($^O eq 'Win32') || ($^O eq 'msys') || ($^O eq 'cygwin')))
{
# The pipe tests are unstable on Windows. It has not been
# determined whether this is because the code doesn't work or the
# tests don't work, but as of September 2023, I think it works
# with MSVC and not with mingw. Fixing fix-qdf to read from pipes
# on Windows is not a high priority, but patches are welcome.
$n_tests += 4;
for (my $n = 1; $n <= 2; ++$n)
{
$td->runtest("fix-qdf $n from pipe (os=$^O)",
{$td->COMMAND => "cat fix$n.qdf | fix-qdf "},
{$td->FILE => "fix$n.qdf.out",
$td->EXIT_STATUS => 0});
$td->runtest("identity fix-qdf $n (os=$^O)",
{$td->COMMAND => "fix-qdf fix$n.qdf.out"},
{$td->FILE => "fix$n.qdf.out",
$td->EXIT_STATUS => 0});
}
}
$td->runtest("fix-qdf with big object stream", # > 255 objects in a stream
{$td->COMMAND => "fix-qdf big-ostream.pdf"},
{$td->FILE => "big-ostream.pdf",
$td->EXIT_STATUS => 0});
$td->runtest("fix-qdf error opening input",
{$td->COMMAND => "fix-qdf /does/not/exist/potato.pdf"},
{$td->REGEXP => "^fix-qdf: error: open .*/does/not/exist/potato.pdf: .*",
$td->EXIT_STATUS => 2});
$td->runtest("fix-qdf error opening output", # > 255 objects in a stream
{$td->COMMAND => "fix-qdf fix1.qdf /does/not/exist/salad.pdf"},
{$td->REGEXP => "^fix-qdf: error: open .*/does/not/exist/salad.pdf: .*",
$td->EXIT_STATUS => 2});
cleanup();
$td->report($n_tests);