Commit 88fb2e5258608d413dd26470b6c0e713908dbbc8

Authored by Jay Berkenbilt
1 parent 978532c5

Workaround for fragile test on Windows

@@ -30,11 +30,6 @@ Soon @@ -30,11 +30,6 @@ Soon
30 30
31 - See ../misc/broken-files 31 - See ../misc/broken-files
32 32
33 - * Some qpdf --check tests are fragile on Windows. The output gets  
34 - truncated. This happens in the loop for content preservation tests.  
35 - Figure out the source of the fragility.  
36 -  
37 -  
38 Next ABI 33 Next ABI
39 ======== 34 ========
40 35
azure-pipelines/build-windows
@@ -29,8 +29,7 @@ installdir=install-$tool$wordsize @@ -29,8 +29,7 @@ installdir=install-$tool$wordsize
29 rm -rf $installdir 29 rm -rf $installdir
30 ./config-$tool --with-windows-wordsize=$wordsize --enable-show-failed-test-output 30 ./config-$tool --with-windows-wordsize=$wordsize --enable-show-failed-test-output
31 make -j$(nproc) 31 make -j$(nproc)
32 -# XXX Fix test fragility -- it's always check status in the content preservation tests.  
33 -make -k check || echo "WARNING: TESTS FAILED" 32 +make -k check
34 make install 33 make install
35 34
36 v=`(cd $installdir; ls -d qpdf-*)` 35 v=`(cd $installdir; ls -d qpdf-*)`
qpdf/qtest/qpdf.test
@@ -2847,10 +2847,36 @@ foreach my $file (@files) @@ -2847,10 +2847,36 @@ foreach my $file (@files)
2847 {$td->STRING => "", 2847 {$td->STRING => "",
2848 $td->EXIT_STATUS => 0}); 2848 $td->EXIT_STATUS => 0});
2849 2849
  2850 + # This test is fragile on Windows for unknown reasons.
  2851 + # Sometimes the output of qpdf --check is truncated yet
  2852 + # qpdf --check still exits normally. As a workaround, try
  2853 + # writing the output of qpdf --check to a file and test
  2854 + # for truncation. If we get a non-truncated output, use
  2855 + # that output as the test input. If this loop fails to
  2856 + # produce a non-truncated output, the truncated or
  2857 + # otherwise incorrect output will still be used as the
  2858 + # test input, so the test will fail as it should. We lose
  2859 + # a check of qpdf --check's output, but it's not important
  2860 + # for this test to verify that.
  2861 + unlink "check.tmpout";
  2862 + for (my $i = 0; $i < 5; ++$i)
  2863 + {
  2864 + if ((system("qpdf --check a.pdf > check.tmpout") == 0) &&
  2865 + open(F, "<check.tmpout"))
  2866 + {
  2867 + local $/ = undef;
  2868 + my $text = <F>;
  2869 + close(F);
  2870 + if ($text =~ m/No syntax or stream/)
  2871 + {
  2872 + last;
  2873 + }
  2874 + }
  2875 + sleep 1;
  2876 + }
2850 $td->runtest("check status", 2877 $td->runtest("check status",
2851 - {$td->COMMAND => "qpdf --check a.pdf"},  
2852 - {$td->FILE => "$base.$n$osuf.check",  
2853 - $td->EXIT_STATUS => 0}, 2878 + {$td->FILE => "check.tmpout"},
  2879 + {$td->FILE => "$base.$n$osuf.check"},
2854 $td->NORMALIZE_NEWLINES); 2880 $td->NORMALIZE_NEWLINES);
2855 2881
2856 $td->runtest("check with C API", 2882 $td->runtest("check with C API",
@@ -3186,5 +3212,5 @@ sub get_md5_checksum @@ -3186,5 +3212,5 @@ sub get_md5_checksum
3186 sub cleanup 3212 sub cleanup
3187 { 3213 {
3188 system("rm -rf *.ps *.pnm ?.pdf ?.qdf *.enc* tif1 tif2 tiff-cache"); 3214 system("rm -rf *.ps *.pnm ?.pdf ?.qdf *.enc* tif1 tif2 tiff-cache");
3189 - system("rm -rf *split-out* ???-kfo.pdf"); 3215 + system("rm -rf *split-out* ???-kfo.pdf *.tmpout");
3190 } 3216 }