aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-10-16 17:10:33 +0200
committerJay Berkenbilt <ejb@ql.org>2018-10-16 17:41:00 +0200
commit88fb2e5258608d413dd26470b6c0e713908dbbc8 (patch)
tree4a9bd89ecbf2e781b19d40333e6828941990fbd0
parent978532c5b3fe59a12503bcf92f1522f9591f2228 (diff)
downloadqpdf-88fb2e5258608d413dd26470b6c0e713908dbbc8.tar.zst
Workaround for fragile test on Windows
-rw-r--r--TODO5
-rwxr-xr-xazure-pipelines/build-windows3
-rw-r--r--qpdf/qtest/qpdf.test34
3 files changed, 31 insertions, 11 deletions
diff --git a/TODO b/TODO
index d2b30156..8f175adc 100644
--- a/TODO
+++ b/TODO
@@ -30,11 +30,6 @@ Soon
- See ../misc/broken-files
- * Some qpdf --check tests are fragile on Windows. The output gets
- truncated. This happens in the loop for content preservation tests.
- Figure out the source of the fragility.
-
-
Next ABI
========
diff --git a/azure-pipelines/build-windows b/azure-pipelines/build-windows
index c69e6499..224f49d4 100755
--- a/azure-pipelines/build-windows
+++ b/azure-pipelines/build-windows
@@ -29,8 +29,7 @@ installdir=install-$tool$wordsize
rm -rf $installdir
./config-$tool --with-windows-wordsize=$wordsize --enable-show-failed-test-output
make -j$(nproc)
-# XXX Fix test fragility -- it's always check status in the content preservation tests.
-make -k check || echo "WARNING: TESTS FAILED"
+make -k check
make install
v=`(cd $installdir; ls -d qpdf-*)`
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 21e15e1d..17497710 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -2847,10 +2847,36 @@ foreach my $file (@files)
{$td->STRING => "",
$td->EXIT_STATUS => 0});
+ # This test is fragile on Windows for unknown reasons.
+ # Sometimes the output of qpdf --check is truncated yet
+ # qpdf --check still exits normally. As a workaround, try
+ # writing the output of qpdf --check to a file and test
+ # for truncation. If we get a non-truncated output, use
+ # that output as the test input. If this loop fails to
+ # produce a non-truncated output, the truncated or
+ # otherwise incorrect output will still be used as the
+ # test input, so the test will fail as it should. We lose
+ # a check of qpdf --check's output, but it's not important
+ # for this test to verify that.
+ unlink "check.tmpout";
+ for (my $i = 0; $i < 5; ++$i)
+ {
+ if ((system("qpdf --check a.pdf > check.tmpout") == 0) &&
+ open(F, "<check.tmpout"))
+ {
+ local $/ = undef;
+ my $text = <F>;
+ close(F);
+ if ($text =~ m/No syntax or stream/)
+ {
+ last;
+ }
+ }
+ sleep 1;
+ }
$td->runtest("check status",
- {$td->COMMAND => "qpdf --check a.pdf"},
- {$td->FILE => "$base.$n$osuf.check",
- $td->EXIT_STATUS => 0},
+ {$td->FILE => "check.tmpout"},
+ {$td->FILE => "$base.$n$osuf.check"},
$td->NORMALIZE_NEWLINES);
$td->runtest("check with C API",
@@ -3186,5 +3212,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");
+ system("rm -rf *split-out* ???-kfo.pdf *.tmpout");
}