forked from pbiggar/trychooser
-
Notifications
You must be signed in to change notification settings - Fork 2
/
trychooser_test
executable file
·67 lines (56 loc) · 4.12 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
#!/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'),
('NYNYYYYYYYYYYYYY', '-b do -p linux,linux64,macosx64,win32,win64,android,android-armv6,android-noion,ics_armv7a_gecko,panda,unagi -u all -t all'),
('NYNNNYYNNNNNNNYY', '-b do -p macosx64,win32 -u all -t all'),
('NYNNNNNNYNNNNNYYY', '-b do -p android -u all -t all'),
('NYYNNY', '-b do -p all -u none -t all'),
('NYYNYYYYYYYYYYYYYYYYYYYYYYYYYNYYYYYYYYYYYY', '-b do -p all -u reftest,reftest-1,reftest-2,reftest-3,reftest-4,reftest-5,reftest-6,reftest-ipc,reftest-no-accel,crashtest,crashtest-1,crashtest-2,crashtest-3,crashtest-ipc,xpcshell,jsreftest,jsreftest-1,jsreftest-2,jsreftest-3,jetpack,marionette,marionette-webapi,mozmill,robocop,mochitest-1,mochitest-2,mochitest-3,mochitest-4,mochitest-5,mochitest-6,mochitest-7,mochitest-8,mochitest-bc,mochitest-o -t all'),
('NYYNYYYYYYYYYYYYYYYYYYYYYYYYYNYYYYYNNNNNNY', '-b do -p all -u reftest,reftest-1,reftest-2,reftest-3,reftest-4,reftest-5,reftest-6,reftest-ipc,reftest-no-accel,crashtest,crashtest-1,crashtest-2,crashtest-3,crashtest-ipc,xpcshell,jsreftest,jsreftest-1,jsreftest-2,jsreftest-3,jetpack,marionette,marionette-webapi,mozmill,robocop,mochitest-1,mochitest-2,mochitest-3,mochitest-4 -t all'),
('NYYNYYYYYYYYYYYYYYYYYYYYYYYYYNYYYNNYNNNYYY', '-b do -p all -u reftest,reftest-1,reftest-2,reftest-3,reftest-4,reftest-5,reftest-6,reftest-ipc,reftest-no-accel,crashtest,crashtest-1,crashtest-2,crashtest-3,crashtest-ipc,xpcshell,jsreftest,jsreftest-1,jsreftest-2,jsreftest-3,jetpack,marionette,marionette-webapi,mozmill,robocop,mochitest-1,mochitest-2,mochitest-5,mochitest-bc,mochitest-o -t all'),
('NYYNYNNNNNNNNNNNNNNYYNNNNYYNNNYYYYYYNNNYYY', '-b do -p all -u xpcshell,jsreftest,marionette,marionette-webapi,mochitest-1,mochitest-2,mochitest-3,mochitest-4,mochitest-5,mochitest-bc,mochitest-o -t all'),
('NYYNYYNNNNNNNNYNNNNYYNNNNYYNNYYY', '-b do -p all -u reftest,crashtest,xpcshell,jsreftest,marionette,marionette-webapi,mochitests -t all'),
('NYYYNNNN', '-b do -p all -u all -t none'),
('NYYYNYYYYYYYYYYYYY', '-b do -p all -u all -t tpn,nochromer,other,dirtypaint,svgr,dromaeojs,xperf,remote-ts,remote-tdhtml,remote-tsvg,remote-tpan,remote-trobopan,remote-trobocheck,remote-troboprovider,remote-trobocheck2,remote-trobocheck3,remote-tp4m_nochrome'),
('NYYYNYNNYYYYYNYYYYYYYYYYY', '-b do -p all -u all -t other,dirtypaint,svgr,dromaeojs,xperf,remote-ts,remote-tdhtml,remote-tsvg,remote-tpan,remote-trobopan,remote-trobocheck,remote-trobocheck2,remote-trobocheck3,remote-troboprovider,remote-tp4m_nochrome'),
('NYYYNYYYYYYNYNYNNNNNNNNYN', '-b do -p all -u all -t tpn,nochromer,other,dirtypaint,svgr,xperf,remote-troboprovider'),
('NYYNYNNNNNNNNNNNNNNNNNNNNNNNNYNN', '-b do -p all -u mochitests -t none'),
]
invalid_tests = [
('NYNNNNNNNNNNNNYY', ": try: -b do -p -u all -t all"), # No platforms
('NNNNYYY', ""), # No builds
('NYYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN', ": try: -b do -p all -u -t none"), # Wanted unittests, none picked
('NYYYNYNNNNNNNNYNNNNNNNNNN', ": 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 + "'"