Skip to content

Commit c920e05

Browse files
committed
Make tests parallelizable
See issue #205. It is not entirely perfect because bots still lock each other when using same builds (especially on HEAD), but this makes the test suite go from 22 minutes to β‰ˆ11 minutes.
1 parent 558b932 commit c920e05

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

β€ŽSakefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ task any(β€˜debug:’ X~ @botsΒ».extension(β€˜β€™)Β».basenameΒ».lc), sub {
3232

3333
task β€˜start-all’, { start-stop β€˜start-all’ }
3434
task β€˜stop-all’, { start-stop β€˜stop-all’ }
35-
task β€˜test’, { run β€˜prove’, β€˜--exec’, β€˜perl6’, β€˜t’ }
35+
task β€˜test’, { run β€˜prove’, β€˜-j’, β€˜4’,
36+
β€˜--rules=par=t/bloatable.t’,
37+
β€˜--rules=par=t/coverable.t’,
38+
β€˜--rules=par=t/greppable.t’,
39+
β€˜--rules=par=t/nativecallable.t’,
40+
β€˜--rules=par=t/releasable.t’,
41+
β€˜--rules=par=t/statisfiable.t’,
42+
β€˜--rules=seq=**’,
43+
β€˜--exec’, β€˜perl6’, β€˜t’ }
3644

3745
task β€˜upgrade’ => β€˜stop-all’, { run β€˜rakudobrew’, β€˜build’, β€˜moar’ }
3846

β€Žlib/Whateverable.pm6

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ multi method filter($text is copy) {
439439

440440
method upload(%files is copy, :$description = β€˜β€™, Bool :$public = True) {
441441
if %*ENV<TESTABLE> {
442-
my $gists-path = β€œ{BUILDS-LOCATION}/tist”;
442+
my $nick = $.irc.servers.values[0].current-nick;
443+
my $gists-path = β€œ{BUILDS-LOCATION}/tist/$nick”;
443444
rmtree $gists-path if $gists-path.IO ~~ :d;
444445
mkdir $gists-path;
445446
spurt β€œ$gists-path/{.key}”, .value for %files;
@@ -463,7 +464,11 @@ method selfrun($nick is copy, @alias?) {
463464
:@alias
464465
# IPv4 address of chat.freenode.net is hardcoded so that we can double the limit ↓
465466
:host(%*ENV<TESTABLE> ?? β€˜127.0.0.1’ !! (β€˜chat.freenode.net’, β€˜185.30.166.38’).pick)
466-
:channels(%*ENV<DEBUGGABLE> ?? <#whateverable> !! <#perl6 #perl6-dev #whateverable #zofbot #moarvm>)
467+
:channels(%*ENV<DEBUGGABLE>
468+
?? β€˜#whateverable’
469+
!! %*ENV<TESTABLE>
470+
?? β€œ#whateverable_$nick”
471+
!! <#perl6 #perl6-dev #whateverable #zofbot #moarvm>)
467472
:debug(?%*ENV<DEBUGGABLE>)
468473
:plugins(self)
469474
:filters( -> |c { self.filter(|c) } )

β€Žt/evalable.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ $t.test(β€˜β€˜m:’ is not even needed’,
171171
$t.test(β€˜autodetection is smart enough’,
172172
β€˜say you actually start your message with β€œsay”’);
173173

174-
my $camelia = IRC::Client.new(:nick(β€˜camelia’) :host<127.0.0.1> :channels<#whateverable>);
174+
my $camelia = IRC::Client.new(:nick(β€˜camelia’) :host<127.0.0.1>
175+
:channels<#whateverable_evalable6>);
175176
start $camelia.run;
176177
sleep 1;
177178

β€Žt/lib/Testable.pm6

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ class Testable {
1616

1717
has $!first-test;
1818

19-
submethod BUILD(:$bot, :$!our-nick = β€˜testable’) {
19+
submethod BUILD(:$bot, :$our-nick = β€˜testable’) {
2020
$!bot = $bot;
2121
my $ready = Channel.new;
2222
$!messages = Channel.new;
2323

2424
my $self = self;
2525
$!irc-client = IRC::Client.new(
26-
:nick($!our-nick) :host<127.0.0.1> :channels<#whateverable>
26+
:nick($our-nick ~ (^999999 .pick))
27+
:host<127.0.0.1>
28+
:channels(β€œ#whateverable_{$bot.lc}6”)
2729
:plugins(
2830
class {
2931
method irc-privmsg-channel($m) {
@@ -43,19 +45,21 @@ class Testable {
4345

4446
start { sleep 20; $ready.send: False }
4547
$!bot-nick = $ready.receive;
46-
ok ?$!bot-nick, β€˜bot joined the channel’
48+
$!our-nick = $!irc-client.servers.values[0].current-nick;
49+
ok ?$!bot-nick, β€˜bot joined the channel’;
50+
is $!bot-nick, β€œ{$bot.lc}6”, β€˜bot nickname is expected’
4751
}
4852

4953
method test(|c ($description, $command, *@expected, :$timeout = 11, :$delay = 0.5)) {
5054
$!first-test = c without $!first-test;
5155

52-
my $gists-path = β€œ/tmp/whateverable/tist/”;
56+
my $gists-path = β€œ/tmp/whateverable/tist/$!bot-nick”;
5357
rmtree $gists-path if $gists-path.IO ~~ :d;
5458

5559
my @got;
5660
my $start = now;
5761

58-
$!irc-client.send: :where<#whateverable> :text($command);
62+
$!irc-client.send: :where(β€œ#whateverable_$!bot-nick”) :text($command);
5963
sleep $delay if @expected == 0; # make it possible to check for no replies
6064
for ^@expected {
6165
my $message = $!messages.poll;
@@ -74,7 +78,7 @@ class Testable {
7478

7579
method test-gist($description, %files) {
7680
for %files.kv -> $file, $tests {
77-
my $path = β€œ/tmp/whateverable/tist/$file”;
81+
my $path = β€œ/tmp/whateverable/tist/$!bot-nick/$file”;
7882
ok $path.IO ~~ :f, β€œgist file $file exists”;
7983
cmp-ok slurp($path), &[~~], $_, β€œgist file {$file}: $description” for @$tests;
8084
}

β€Žt/unicodable.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ $t.test(β€˜Answers on β€˜.u’ when yoleaux is not around’,
146146
β€˜.u γŠ·β€™,
147147
/^ <me($t)>β€˜, U+32B7 CIRCLED NUMBER FORTY TWO [No] (㊷)’ $/);
148148

149-
my $yoleaux = IRC::Client.new(:nick(β€˜yoleaux’) :host<127.0.0.1> :channels<#whateverable>);
149+
my $yoleaux = IRC::Client.new(:nick(β€˜yoleaux’) :host<127.0.0.1>
150+
:channels<#whateverable_unicodable6>);
150151
start $yoleaux.run;
151152
sleep 1;
152153

0 commit comments

Comments
Β (0)