Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 72 lines (60 sloc) 3.63 KB
#!/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'),
('NYNYYYYYYYYYY', '-b do -p linux,linux64,macosx,macosx64,win32,android-r7,maemo5-gtk,maemo5-qt -u all -t all'),
('NYNNNYYYNNNYY', '-b do -p macosx,macosx64,win32 -u all -t all'),
('NYNNNNNNNYYYY', '-b do -p maemo5-gtk,maemo5-qt -u all -t all'),
('NYNNNNNNYNYYY', '-b do -p android-r7,maemo5-qt -u all -t all'),
('NYNNNNNNYYNYY', '-b do -p android-r7,maemo5-gtk -u all -t all'),
('NYNNNNNNNNYYY', '-b do -p maemo5-qt -u all -t all'),
('NYNNNNNNYNNYY', '-b do -p android-r7 -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 = [
('NYNNNNNNNNNYY', ": 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)
print "Pass [" + input + "]: '" + expected + "'"
Something went wrong with that request. Please try again.