Commit 8acf636b4e525169a7f52160ce1a5423be762271
1 parent
d491ed87
Incorporate improved Windows fragility workaround from qtest
Showing
4 changed files
with
10 additions
and
60 deletions
TODO
| @@ -3,13 +3,6 @@ Soon | @@ -3,13 +3,6 @@ Soon | ||
| 3 | 3 | ||
| 4 | * Set up OSS-Fuzz (Google). See starred email in qpdf label. | 4 | * Set up OSS-Fuzz (Google). See starred email in qpdf label. |
| 5 | 5 | ||
| 6 | - * Get to the bottom of Windows test fragility. The symptom is that | ||
| 7 | - sometimes the output of a command is truncated even though the | ||
| 8 | - command ran successfully. I strongly suspect it has to do with | ||
| 9 | - TestDriver->winrun and/or use of temporary files in qtest for | ||
| 10 | - Windows. If found, remove workarounds. Search for sleep to find | ||
| 11 | - them. | ||
| 12 | - | ||
| 13 | Next ABI | 6 | Next ABI |
| 14 | ======== | 7 | ======== |
| 15 | 8 |
examples/qtest/create.test
| @@ -11,30 +11,9 @@ cleanup(); | @@ -11,30 +11,9 @@ cleanup(); | ||
| 11 | 11 | ||
| 12 | my $td = new TestDriver('create'); | 12 | my $td = new TestDriver('create'); |
| 13 | 13 | ||
| 14 | -# This test is fragile on Windows for unknown reasons. Sometimes the | ||
| 15 | -# output of the command is truncated even though it works and exits | ||
| 16 | -# normally. | ||
| 17 | - | ||
| 18 | -for (my $i = 0; $i < 5; ++$i) | ||
| 19 | -{ | ||
| 20 | - unlink "tmp.out"; | ||
| 21 | - if ((system("pdf-create a.pdf > tmp.out") == 0) && | ||
| 22 | - open(F, "<check.tmpout")) | ||
| 23 | - { | ||
| 24 | - local $/ = undef; | ||
| 25 | - my $text = <F>; | ||
| 26 | - close(F); | ||
| 27 | - if ($text =~ m/passed/) | ||
| 28 | - { | ||
| 29 | - last; | ||
| 30 | - } | ||
| 31 | - } | ||
| 32 | - sleep 1; | ||
| 33 | -} | ||
| 34 | - | ||
| 35 | $td->runtest("create a simple PDF", | 14 | $td->runtest("create a simple PDF", |
| 36 | - {$td->FILE => "tmp.out"}, | ||
| 37 | - {$td->FILE => "create.out"}, | 15 | + {$td->COMMAND => "pdf-create a.pdf"}, |
| 16 | + {$td->FILE => "create.out", $td->EXIT_STATUS => 0}, | ||
| 38 | $td->NORMALIZE_NEWLINES); | 17 | $td->NORMALIZE_NEWLINES); |
| 39 | 18 | ||
| 40 | cleanup(); | 19 | cleanup(); |
qpdf/qtest/qpdf.test
| @@ -3724,36 +3724,10 @@ foreach my $file (@files) | @@ -3724,36 +3724,10 @@ foreach my $file (@files) | ||
| 3724 | {$td->STRING => "", | 3724 | {$td->STRING => "", |
| 3725 | $td->EXIT_STATUS => 0}); | 3725 | $td->EXIT_STATUS => 0}); |
| 3726 | 3726 | ||
| 3727 | - # This test is fragile on Windows for unknown reasons. | ||
| 3728 | - # Sometimes the output of qpdf --check is truncated yet | ||
| 3729 | - # qpdf --check still exits normally. As a workaround, try | ||
| 3730 | - # writing the output of qpdf --check to a file and test | ||
| 3731 | - # for truncation. If we get a non-truncated output, use | ||
| 3732 | - # that output as the test input. If this loop fails to | ||
| 3733 | - # produce a non-truncated output, the truncated or | ||
| 3734 | - # otherwise incorrect output will still be used as the | ||
| 3735 | - # test input, so the test will fail as it should. We lose | ||
| 3736 | - # a check of qpdf --check's output, but it's not important | ||
| 3737 | - # for this test to verify that. | ||
| 3738 | - unlink "check.tmpout"; | ||
| 3739 | - for (my $i = 0; $i < 5; ++$i) | ||
| 3740 | - { | ||
| 3741 | - if ((system("qpdf --check a.pdf > check.tmpout") == 0) && | ||
| 3742 | - open(F, "<check.tmpout")) | ||
| 3743 | - { | ||
| 3744 | - local $/ = undef; | ||
| 3745 | - my $text = <F>; | ||
| 3746 | - close(F); | ||
| 3747 | - if ($text =~ m/No syntax or stream/) | ||
| 3748 | - { | ||
| 3749 | - last; | ||
| 3750 | - } | ||
| 3751 | - } | ||
| 3752 | - sleep 1; | ||
| 3753 | - } | ||
| 3754 | $td->runtest("check status", | 3727 | $td->runtest("check status", |
| 3755 | - {$td->FILE => "check.tmpout"}, | ||
| 3756 | - {$td->FILE => "$base.$n$osuf.check"}, | 3728 | + {$td->COMMAND => "qpdf --check a.pdf"}, |
| 3729 | + {$td->FILE => "$base.$n$osuf.check", | ||
| 3730 | + $td->EXIT_STATUS => 0}, | ||
| 3757 | $td->NORMALIZE_NEWLINES); | 3731 | $td->NORMALIZE_NEWLINES); |
| 3758 | 3732 | ||
| 3759 | $td->runtest("check with C API", | 3733 | $td->runtest("check with C API", |
qtest/module/TestDriver.pm
| @@ -107,7 +107,7 @@ my $color_emph = ""; | @@ -107,7 +107,7 @@ my $color_emph = ""; | ||
| 107 | # MSWin32 support | 107 | # MSWin32 support |
| 108 | my $in_windows = 0; | 108 | my $in_windows = 0; |
| 109 | my $winbin = undef; | 109 | my $winbin = undef; |
| 110 | -if ($^O eq 'MSWin32') | 110 | +if (($^O eq 'MSWin32') || ($^O eq 'msys')) |
| 111 | { | 111 | { |
| 112 | $in_windows = 1; | 112 | $in_windows = 1; |
| 113 | } | 113 | } |
| @@ -784,6 +784,10 @@ sub runtest | @@ -784,6 +784,10 @@ sub runtest | ||
| 784 | binmode F; | 784 | binmode F; |
| 785 | while (<$in>) | 785 | while (<$in>) |
| 786 | { | 786 | { |
| 787 | + if ($flags & $rep->NORMALIZE_NEWLINES) | ||
| 788 | + { | ||
| 789 | + s/\r$//; | ||
| 790 | + } | ||
| 787 | print F; | 791 | print F; |
| 788 | } | 792 | } |
| 789 | $in->close(); | 793 | $in->close(); |