Skip to content

Commit a7f3f23

Browse files
committed
Turn off watchdog when done in tests
If you set a watchdog timer, you should clear it when its no longer needed. Otherwise it can go off, aborting your test script. In these twenty test files, it hasn't mostly been a problem because the script finishes before the timer goes off. But I bet that some heisenbugs have been the result of not clearing it. It actually shouldn't be necessary to clear the timer when that is the final statement in the test file, but we may want to add a porting test that makes sure watchdogs are cleared, and always adding a clear enables such a test to properly work.
1 parent e7a8320 commit a7f3f23

20 files changed

+33
-1
lines changed

ext/XS-APItest/t/keyword_plugin_threads.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ for my $t (1 .. 3) {
2626
})->join;
2727
}
2828
29+
watchdog(0);
30+
2931
print "all is well\n";
3032
----
3133
all is well

ext/re/t/re_funcs_u.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ if ('1234'=~/(?:(?<A>\d)|(?<C>!))(?<B>\d)(?<A>\d)(?<B>\d)/){
128128
# New tests go here ^^^
129129

130130
{ # Keep these tests last, as whole script will be interrupted if times out
131-
# Bug #72998; this can loop
131+
# Bug #72998; this can loop
132132
watchdog(10);
133133
eval '"\x{100}\x{FB00}" =~ /\x{100}\N{U+66}+/i';
134134
pass("Didn't loop");
@@ -137,6 +137,7 @@ if ('1234'=~/(?:(?<A>\d)|(?<C>!))(?<B>\d)(?<A>\d)(?<B>\d)/){
137137
no warnings; # Because the 8 may be warned on
138138
eval 'qr/\18/';
139139
pass(q"qr/\18/ didn't loop");
140+
watchdog(0);
140141
}
141142

142143
done_testing();

t/io/closepid.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ SKIP:
4242
kill $killsig, $pid;
4343
open STDIN, "<&", $savein;
4444
}
45+
46+
watchdog(0);

t/io/openpid.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,4 @@ print "# waiting for process $pid4 to exit\n";
102102
$reap_pid = waitpid $pid4, 0;
103103
is( $reap_pid, $pid4, 'fourth process reaped' );
104104

105+
watchdog(0);

t/mro/package_aliases.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ watchdog 3;
300300
*foo:: = \%::;
301301
*Acme::META::Acme:: = \*Acme::; # indirect self-reference
302302
pass("mro_package_moved and self-referential packages");
303+
watchdog 0;
303304

304305
# Deleting a glob whose name does not indicate its location in the symbol
305306
# table but which nonetheless *is* in the symbol table.

t/mro/package_aliases_utf8.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ watchdog 3;
368368
*ᕘ:: = \%::;
369369
*Aᶜme::Mῌ::Aᶜme:: = \*Aᶜme::; # indirect self-reference
370370
pass("mro_package_moved and self-referential packages");
371+
watchdog 0;
371372

372373
# Deleting a glob whose name does not indicate its location in the symbol
373374
# table but which nonetheless *is* in the symbol table.

t/op/sigdispatch.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,5 @@ like $@, qr/No such hook: __DIE__\\0whoops at/;
167167
is($int_called, 1);
168168
is($@, "died");
169169
}
170+
171+
watchdog(0);

t/op/signame_canonical.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,5 @@ foreach my $dupe (@duplicate_signals) {
7373
is( $SIG{$canonical_name}, undef, "The signal $canonical_name is cleared after local goes out of scope." );
7474
}
7575

76+
watchdog(0);
77+

t/op/study.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,5 @@ TODO: {
158158
push @got, $_ foreach $a =~ /[^x]d(?{$a .= ''})[^x]d/g;
159159
is("@got", 'ydyd ydyd', '#92696 $a .= \'\' inside (?{}), $a studied');
160160
}
161+
162+
watchdog(0);

t/op/threads.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ watchdog(180, "process");
149149
$_->join for @t;
150150
ok(1, '[perl #45053]');
151151
}
152+
watchdog(0);
152153

153154
sub matchit {
154155
is (ref $_[1], "Regexp");

0 commit comments

Comments
 (0)