Skip to content

Commit

Permalink
Test timeouts
Browse files Browse the repository at this point in the history
Basic tests for #12.

No tests for Benchable yet, see #99.
  • Loading branch information
AlexDaniel committed Mar 10, 2017
1 parent f3bad83 commit 78f51a5
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Whateverable.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ method get-output(*@run-args, :$timeout = $!timeout, :$stdin) {

if not $promise.status ~~ Kept { # timed out
$proc.kill; # TODO sends HUP, but should kill the process tree instead
$out.send: «timed out after $timeout seconds, output»: ;
$out.send: «timed out after $timeout seconds»;
}
try sink await $promise; # wait until it is actually stopped
$out.close;
Expand Down
4 changes: 4 additions & 0 deletions t/benchable.t
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ $t.test(‘Both commits are wrong (did you mean … ?)’,
/^ <me($t)>‘, starting to benchmark the ’ \d+ ‘ given commit’ ‘s’? $/,
/^ <me($t)>‘, ¦2015.12^: «’ \d+\.\d+ ‘» ¦2015.13: «Cannot find this revision (did you mean “2015.12”?)» ¦69fecb5: «Cannot find this revision (did you mean “07fecb5”?)»’ $/);

# Timeouts

# TODO See issue #99

# Extra tests

$t.test(last basic query, just in case, # keep it last in this file
Expand Down
9 changes: 9 additions & 0 deletions t/bisectable.t
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ $t.test(‘Did you mean some commit? (old)’,
bisect: old=a7L479b49dbd1 say 42,
{$t.our-nick}, Cannot find revision “a7L479b49dbd1” (did you mean “a71479b”?));

# Timeouts

$t.test(:21timeout, timeout,
bisect: say ‘Zzzz…’; sleep ∞,
/^ <me($t)>‘, On both starting points (old=2015.12 new=9d7c0ab) the exit code is 0, exit signal is 1 (SIGHUP) and the output is identical as well’ $/,
{$t.our-nick}, Output on both points: «Zzzz…␤«timed out after 10 seconds»»);

# TODO test timeouts during bisection

# Extra tests

$t.test(another working query,
Expand Down
7 changes: 7 additions & 0 deletions t/committable.t
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ $t.test(‘Both commits are wrong (did you mean … ?)’,
commit: 2015.12^,2015.13,69fecb52eb2 say 42,
{$t.our-nick}, ¦2015.12^: «42» ¦2015.13: «Cannot find this revision (did you mean “2015.12”?)» ¦69fecb5: «Cannot find this revision (did you mean “07fecb5”?)»);

# Timeouts

$t.test(:21timeout, timeout,
commit: 2015.12,HEAD say ‘Zzzz…’; sleep ∞,
/^ <me($t)>‘, ¦2015.12,HEAD(’<sha>‘): «Zzzz…␤«timed out after 10 seconds» «exit signal = SIGHUP (1)»»’ $/);

# TODO test total timeout

# Extra tests

Expand Down
6 changes: 6 additions & 0 deletions t/evalable.t
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ $t.test(‘Answers on ‘m:’ when camelia is not around again’,
m: say ‘44’,
/^ <me($t)>‘, rakudo-moar ’<sha>‘: OUTPUT: «44»’ $/);

# Timeouts

$t.test(timeout,
eval: say ‘Zzzz…’; sleep ∞,
/^ <me($t)>‘, rakudo-moar ’<sha>‘: OUTPUT: «(signal SIGHUP) Zzzz…␤«timed out after 10 seconds»»’ $/);

# Extra tests

$t.test(last basic query, just in case, # keep it last in this file
Expand Down
2 changes: 1 addition & 1 deletion t/lib/Testable.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Testable {
ok ?$!bot-nick, bot joined the channel
}

method test($description, $command, *@expected, :$timeout = 10, :$delay = 3) {
method test($description, $command, *@expected, :$timeout = 11, :$delay = 3) {
my @got;
my $start = now;

Expand Down
6 changes: 6 additions & 0 deletions t/unicodable.t
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ $t.test(‘Answers on ‘.u’ when yoleaux is not around again’,
.u ㊹,
/^ <me($t)>‘, U+32B9 CIRCLED NUMBER FORTY FOUR [No] (㊹)’ $/);

# Timeouts

$t.test(:31timeout, timeout,
u: { sleep 1 },
{$t.our-nick}, «timed out after 30 seconds» «exit signal = SIGHUP (1)»);

# Extra tests

$t.test(last basic query, just in case, # keep it last in this file
Expand Down

0 comments on commit 78f51a5

Please sign in to comment.