summaryrefslogtreecommitdiffstats
path: root/qpdf/qtest
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-08-31 21:11:11 +0200
committerJay Berkenbilt <ejb@ql.org>2019-08-31 21:51:21 +0200
commitd492bb0a90e30c8c57f36434479ddb708d322e79 (patch)
tree3e721d5622acb0fe6f74ab0889b317cde7daf7a2 /qpdf/qtest
parentbabd12c9b2b824416d2e5992d961396090e2bfea (diff)
downloadqpdf-d492bb0a90e30c8c57f36434479ddb708d322e79.tar.zst
Add --replace-input option (fixes #321)
Diffstat (limited to 'qpdf/qtest')
-rw-r--r--qpdf/qtest/qpdf.test43
-rw-r--r--qpdf/qtest/qpdf/bad-jpeg-show.out2
-rw-r--r--qpdf/qtest/qpdf/empty-object.out2
-rw-r--r--qpdf/qtest/qpdf/replace-input.pdfbin0 -> 743 bytes
-rw-r--r--qpdf/qtest/qpdf/replace-warn.out3
-rw-r--r--qpdf/qtest/qpdf/warn-replace.pdfbin0 -> 16504 bytes
-rw-r--r--qpdf/qtest/qpdf/xref-with-short-size.out2
7 files changed, 48 insertions, 4 deletions
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 41c94519..460685d9 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -191,6 +191,47 @@ foreach my $d (['auto-ü', 1], ['auto-öπ', 2])
show_ntests();
# ----------
+$td->notify("--- Replace Input ---");
+$n_tests += 8;
+
+# Use Unicode file names to test replace input so we can be sure it
+# works for that case.
+$td->runtest("create unicode filenames",
+ {$td->COMMAND => "test_unicode_filenames"},
+ {$td->STRING => "created Unicode filenames\n",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+
+foreach my $d (['auto-ü', 1], ['auto-öπ', 2])
+{
+ my ($u, $n) = @$d;
+ $td->runtest("replace input $u",
+ {$td->COMMAND => "qpdf --deterministic-id" .
+ " --object-streams=generate --replace-input $u.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+ $td->runtest("check output ($u)",
+ {$td->FILE => "$u.pdf"},
+ {$td->FILE => "replace-input.pdf"},
+ $td->NORMALIZE_NEWLINES);
+}
+
+system("cp xref-with-short-size.pdf auto-warn.pdf") == 0 or die;
+$td->runtest("replace input with warnings",
+ {$td->COMMAND =>
+ "qpdf --deterministic-id --replace-input auto-warn.pdf"},
+ {$td->FILE => "replace-warn.out", $td->EXIT_STATUS => 3},
+ $td->NORMALIZE_NEWLINES);
+
+$td->runtest("check output",
+ {$td->FILE => "auto-warn.pdf"},
+ {$td->FILE => "warn-replace.pdf"});
+$td->runtest("check orig output",
+ {$td->FILE => "auto-warn.pdf.~qpdf-orig"},
+ {$td->FILE => "xref-with-short-size.pdf"});
+
+show_ntests();
+# ----------
$td->notify("--- Final Version ---");
$n_tests += 1;
@@ -4233,5 +4274,5 @@ sub get_md5_checksum
sub cleanup
{
system("rm -rf *.ps *.pnm ?.pdf ?.qdf *.enc* tif1 tif2 tiff-cache");
- system("rm -rf *split-out* ???-kfo.pdf *.tmpout \@file.pdf auto-*.pdf");
+ system("rm -rf *split-out* ???-kfo.pdf *.tmpout \@file.pdf auto-*");
}
diff --git a/qpdf/qtest/qpdf/bad-jpeg-show.out b/qpdf/qtest/qpdf/bad-jpeg-show.out
index f1b0bcc7..ca178e50 100644
--- a/qpdf/qtest/qpdf/bad-jpeg-show.out
+++ b/qpdf/qtest/qpdf/bad-jpeg-show.out
@@ -1,2 +1,2 @@
WARNING: bad-jpeg.pdf (offset 735): error decoding stream data for object 6 0: Not a JPEG file: starts with 0x77 0x77
-qpdf: operation succeeded with warnings; resulting file may have some problems
+qpdf: operation succeeded with warnings
diff --git a/qpdf/qtest/qpdf/empty-object.out b/qpdf/qtest/qpdf/empty-object.out
index 7ebfe52c..e2181c6e 100644
--- a/qpdf/qtest/qpdf/empty-object.out
+++ b/qpdf/qtest/qpdf/empty-object.out
@@ -1,3 +1,3 @@
WARNING: empty-object.pdf (object 7 0, offset 575): empty object treated as null
null
-qpdf: operation succeeded with warnings; resulting file may have some problems
+qpdf: operation succeeded with warnings
diff --git a/qpdf/qtest/qpdf/replace-input.pdf b/qpdf/qtest/qpdf/replace-input.pdf
new file mode 100644
index 00000000..b0a7e2e9
--- /dev/null
+++ b/qpdf/qtest/qpdf/replace-input.pdf
Binary files differ
diff --git a/qpdf/qtest/qpdf/replace-warn.out b/qpdf/qtest/qpdf/replace-warn.out
new file mode 100644
index 00000000..09a9261a
--- /dev/null
+++ b/qpdf/qtest/qpdf/replace-warn.out
@@ -0,0 +1,3 @@
+WARNING: auto-warn.pdf (xref stream, offset 16227): Cross-reference stream data has the wrong size; expected = 52; actual = 56
+qpdf: there are warnings; original file kept in auto-warn.pdf.~qpdf-orig
+qpdf: operation succeeded with warnings; resulting file may have some problems
diff --git a/qpdf/qtest/qpdf/warn-replace.pdf b/qpdf/qtest/qpdf/warn-replace.pdf
new file mode 100644
index 00000000..7d1bef39
--- /dev/null
+++ b/qpdf/qtest/qpdf/warn-replace.pdf
Binary files differ
diff --git a/qpdf/qtest/qpdf/xref-with-short-size.out b/qpdf/qtest/qpdf/xref-with-short-size.out
index 9041f854..9b4ef1ce 100644
--- a/qpdf/qtest/qpdf/xref-with-short-size.out
+++ b/qpdf/qtest/qpdf/xref-with-short-size.out
@@ -11,4 +11,4 @@ WARNING: xref-with-short-size.pdf (xref stream, offset 16227): Cross-reference s
10/0: compressed; stream = 5, index = 3
11/0: compressed; stream = 5, index = 7
12/0: compressed; stream = 5, index = 8
-qpdf: operation succeeded with warnings; resulting file may have some problems
+qpdf: operation succeeded with warnings