forked from pbiggar/trychooser
/
trychooser_test
executable file
·71 lines (60 loc) · 3.77 KB
/
trychooser_test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
import subprocess
import sys
import re
def run (input):
proc = subprocess.Popen("./trychooser", stdin=subprocess.PIPE, stdout=subprocess.PIPE)
(stdout, _) = proc.communicate(input)
return (stdout.split("\n")[-2], stdout)
tests = [
('Y', '-b do -p all -u all -t all'),
('NYYYYY', '-b do -p all -u all -t all'),
('NNYYYY', '-b o -p all -u all -t all'),
('NNNYYYY', '-b d -p all -u all -t all'),
('NYNYYYYYYYYYYYYYY', '-b do -p linux,linux64,macosx,macosx64,win32,linux-android,linux-android-debug,linux-maemo5-gtk,linux-maemo5-qt,linux-mobile,macosx-mobile,win32-mobile -u all -t all'),
('NYNNNYYYNNNNNNNYY', '-b do -p macosx,macosx64,win32 -u all -t all'),
('NYNNNNNNNNYYNNNYY', '-b do -p linux-maemo5-gtk,linux-maemo5-qt -u all -t all'),
('NYNNNNNNYNNYNNNYY', '-b do -p linux-android,linux-maemo5-qt -u all -t all'),
('NYNNNNNNYNYNNNNYY', '-b do -p linux-android,linux-maemo5-gtk -u all -t all'),
('NYNNNNNNNNNYNNNYY', '-b do -p linux-maemo5-qt -u all -t all'),
('NYNNNNNNYNNNNNNYY', '-b do -p linux-android -u all -t all'),
('NYYNNY', '-b do -p all -u none -t all'),
('NYYNYYYYYYYYYYYNYYYYYYYY', '-b do -p all -u reftest,reftest-ipc,reftest-no-accel,crashtest,crashtest-ipc,xpcshell,jsreftest,jetpack,mozmill-all,opengl,mochitest-1,mochitest-2,mochitest-3,mochitest-4,mochitest-5,mochitest-o -t all'),
('NYYNYYYYYYYYYYYNYYYYYNNY', '-b do -p all -u reftest,reftest-ipc,reftest-no-accel,crashtest,crashtest-ipc,xpcshell,jsreftest,jetpack,mozmill-all,opengl,mochitest-1,mochitest-2,mochitest-3,mochitest-4 -t all'),
('NYYNYYYYYYYYYYYNYYYNNYYY', '-b do -p all -u reftest,reftest-ipc,reftest-no-accel,crashtest,crashtest-ipc,xpcshell,jsreftest,jetpack,mozmill-all,opengl,mochitest-1,mochitest-2,mochitest-5,mochitest-o -t all'),
('NYYNYNNNNNYYNNYNYYYYYYYY', '-b do -p all -u xpcshell,jsreftest,opengl,mochitest-1,mochitest-2,mochitest-3,mochitest-4,mochitest-5,mochitest-o -t all'),
('NYYNYYNNYNYYNNYYY', '-b do -p all -u reftest,crashtest,xpcshell,jsreftest,opengl,mochitests -t all'),
('NYYYNNNN', '-b do -p all -u all -t none'),
('NYYYNYYYYYYYYYYYYY', '-b do -p all -u all -t nochrome,dromaeo,a11y,svg,chrome,tp,tp4,dirty,scroll,cold,v8,remote-ts,remote-tdhtml,remote-tsvg,remote-tsspider,remote-tpan,remote-tp4m,remote-tp4m_nochrome,remote-twinopen,remote-tzoom'),
('NYYYNYNNYYYYYYYYYNYYYYYYYYYY', '-b do -p all -u all -t a11y,svg,chrome,tp,tp4,dirty,scroll,cold,v8,remote-tsvg,remote-tp4m_nochrome,remote-tp4m,remote-ts,remote-tdhtml,remote-tsspider,remote-tpan,remote-twinopen,remote-tzoom'),
('NYYYNYYYYYYYNYYNNNYNNNNYNNNY', '-b do -p all -u all -t nochrome,dromaeo,a11y,svg,chrome,tp,dirty,scroll,remote-tdhtml,remote-tzoom'),
('NYYNYNNNNNNNNNNYNN', '-b do -p all -u mochitests -t none'),
]
invalid_tests = [
('NYNNNNNNNNNNNNNYY', ": try: -b do -p -u all -t all"), # No platforms
('NNNNYYY', ""), # No builds
('NYYNYNNNNNNNNNNNNNNY', ": try: -b do -p all -u -t none"), # Wanted unittests, none picked
('NYYYNYNNNNNNNNNNNNYNNNNNNNNN', ": try: -b do -p all -u all -t"), # Wanted talos, none picked
]
tests = [(a, 'try: ' + b) for (a,b) in tests]
tests += [(a, 'Invalid selection' + b) for (a,b) in invalid_tests]
def combine(output, input):
result = ""
matches = re.findall('.*?\[Ynh\?\]', output, re.M | re.S)
assert matches != None
# assert len(matches) == len(input)
i = 0
for match in matches:
result += match
if len(input) > i:
result += " " + input[i]
i += 1
return result
for (input, expected) in tests:
(output, full_output) = run("\n".join(input))
if output != expected:
print "Fail:\n\texpected:\n\t\t" + expected + "\n\tgot:\n\t\t" + output
print combine(full_output, input)
sys.exit(-1)
else:
print "Pass [" + input + "]: '" + expected + "'"