Skip to content

Commit 4a05be6

Browse files
committed
Add tests for Benchable
1 parent c35cdc1 commit 4a05be6

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed

t/benchable.t

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#!/usr/bin/env perl6
2+
BEGIN %*ENV<PERL6_TEST_DIE_ON_FAIL> = 1;
3+
%*ENV<TESTABLE> = 1;
4+
5+
use Test;
6+
use lib t/lib;
7+
use Testable;
8+
9+
my $t = Testable.new(bot => ./Benchable.p6);
10+
11+
# Help messages
12+
13+
$t.test(help message,
14+
{$t.bot-nick}, helP,
15+
{$t.our-nick}, Like this: {$t.bot-nick}: f583f22,HEAD ~ q|my $a = "a" x 2**16;for ^1000 {my $b = $a.chop($_)}|);
16+
17+
$t.test(help message,
18+
{$t.bot-nick}, HElp? ,
19+
{$t.our-nick}, Like this: {$t.bot-nick}: f583f22,HEAD ~ q|my $a = "a" x 2**16;for ^1000 {my $b = $a.chop($_)}|);
20+
21+
$t.test(source link,
22+
{$t.bot-nick}: Source ,
23+
{$t.our-nick}, https://github.com/perl6/whateverable);
24+
25+
$t.test(source link,
26+
{$t.bot-nick}: sourcE? ,
27+
{$t.our-nick}, https://github.com/perl6/whateverable);
28+
29+
$t.test(source link,
30+
{$t.bot-nick}: URl ,
31+
{$t.our-nick}, https://github.com/perl6/whateverable);
32+
33+
$t.test(source link,
34+
{$t.bot-nick}: urL? ,
35+
{$t.our-nick}, https://github.com/perl6/whateverable);
36+
37+
# Basics
38+
39+
$t.test(basic “nick:” query,
40+
{$t.bot-nick}: HEAD say ‘hello’,
41+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
42+
/^ <{$t.our-nick}> “, ¦«HEAD»:” \d+\.\d+ $/);
43+
44+
$t.test(basic “nick,” query,
45+
{$t.bot-nick}, HEAD say ‘hello’,
46+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
47+
/^ <{$t.our-nick}> “, ¦«HEAD»:” \d+\.\d+ $/);
48+
49+
$t.test(“bench:” shortcut,
50+
bench: HEAD say ‘hello’,
51+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
52+
/^ <{$t.our-nick}> “, ¦«HEAD»:” \d+\.\d+ $/);
53+
54+
$t.test(“bench,” shortcut,
55+
bench, HEAD say ‘hello’,
56+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
57+
/^ <{$t.our-nick}> “, ¦«HEAD»:” \d+\.\d+ $/);
58+
59+
$t.test(“bench6:” shortcut,
60+
bench6: HEAD say ‘hello’,
61+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
62+
/^ <{$t.our-nick}> “, ¦«HEAD»:” \d+\.\d+ $/);
63+
64+
$t.test(“bench6,” shortcut,
65+
bench6, HEAD say ‘hello’,
66+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
67+
/^ <{$t.our-nick}> “, ¦«HEAD»:” \d+\.\d+ $/);
68+
69+
$t.test(“bench” shortcut does not work,
70+
bench HEAD say ‘hello’);
71+
72+
$t.test(“bench6” shortcut does not work,
73+
bench6 HEAD say ‘hello’);
74+
75+
$t.test(specific commit,
76+
bench: f583f22 say $*PERL.compiler.version,
77+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
78+
/^ <{$t.our-nick}> “, ¦«f583f22»:” \d+\.\d+ $/);
79+
80+
$t.test(the benchmark time makes sense,
81+
bench: HEAD sleep 2,
82+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
83+
/^ <{$t.our-nick}> “, ¦«HEAD»:” (\d+)\.\d+ <?{ $0 >= 2 }> $/,
84+
:30timeout);
85+
86+
$t.test(“compare” query,
87+
bench: compare HEAD say "hi" ||| say "bye",
88+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
89+
{$t.our-nick}, https://whatever.able/fakeupload);
90+
91+
# Ranges and multiple commits
92+
93+
$t.test(“releases” query,
94+
bench: releases say $*PERL,
95+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
96+
{$t.our-nick}, benchmarked the given commits, now zooming in on performance differences,
97+
{$t.our-nick}, https://whatever.able/fakeupload,
98+
:240timeout);
99+
100+
$t.test(“v6c” query,
101+
bench: v6c say $*PERL,
102+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
103+
{$t.our-nick}, benchmarked the given commits, now zooming in on performance differences,
104+
{$t.our-nick}, https://whatever.able/fakeupload,
105+
:240timeout);
106+
107+
$t.test(multiple commits separated by comma (three consecutive commits, so zooming in on performance differences will not create a graph,
108+
bench: b1f77c8,87bba04,79bb867 say ‘hello’,
109+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
110+
{$t.our-nick}, benchmarked the given commits, now zooming in on performance differences,
111+
/^ <{$t.our-nick}> “, ¦«b1f77c8»:” \d+\.\d+ “␤¦«87bba04»:” \d+\.\d+ “␤¦«79bb867»:” \d+\.\d+ $/,
112+
:20timeout);
113+
114+
$t.test(commit~num syntax,
115+
bench: 2016.10~1 say $*PERL.compiler.version,
116+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
117+
/^ <{$t.our-nick}> “, ¦«2016.10~1»:” \d+\.\d+ $/);
118+
119+
$t.test(commit^^^ syntax,
120+
bench: 2016.10^^ say $*PERL.compiler.version,
121+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
122+
/^ <{$t.our-nick}> “, ¦«2016.10^^»:” \d+\.\d+ $/);
123+
124+
$t.test(commit..commit range syntax,
125+
bench: 79bb867..b1f77c8 say ‘a’ x 9999999999999999999,
126+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
127+
/^ <{$t.our-nick}> “, ¦«b1f77c8»:” \d+\.\d+ “␤¦«87bba04»:” \d+\.\d+ “␤¦«79bb867»:” \d+\.\d+ $/,
128+
:20timeout);
129+
130+
# URLs
131+
132+
$t.test(fetching code from urls,
133+
bench: HEAD https://gist.githubusercontent.com/AlexDaniel/147bfa34b5a1b7d1ebc50ddc32f95f86/raw/9e90da9f0d95ae8c1c3bae24313fb10a7b766595/test.p6,
134+
{$t.our-nick}, Successfully fetched the code from the provided URL.,
135+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
136+
/^ <{$t.our-nick}> “, ¦«HEAD»:” \d+\.\d+ $/);
137+
138+
$t.test(wrong url,
139+
bench: HEAD http://github.org/sntoheausnteoahuseoau,
140+
{$t.our-nick}, It looks like a URL, but for some reason I cannot download it (HTTP status line is 404 Not Found).);
141+
142+
$t.test(wrong mime type,
143+
bench: HEAD https://www.wikipedia.org/,
144+
{$t.our-nick}, It looks like a URL, but mime type is ‘text/html’ while I was expecting something with ‘text/plain’ or ‘perl’ in it. I can only understand raw links, sorry.);
145+
146+
# Extra tests
147+
148+
$t.test(last basic query, just in case, # keep it last in this file
149+
{$t.bot-nick}: HEAD say ‘hello’,
150+
/^ <{$t.our-nick}> “, starting to benchmark the ” \d+ “ given commit” ‘s’? $/,
151+
/^ <{$t.our-nick}> “, ¦«HEAD»:” \d+\.\d+ $/);
152+
153+
END {
154+
$t.end;
155+
sleep 1;
156+
}
157+
158+
done-testing;
159+
160+
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)