import re
import sys
import subprocess
REPLACEMENTS = {
'ok': '.',
'FAILED': 'F',
'ignored': 'I',
}
TEST_RESULT_RE = re.compile(
r'^test .* \.\.\. ({0})$'.format('|'.join(REPLACEMENTS.keys())))
def main(args):
process = subprocess.Popen(args, stdout=subprocess.PIPE)
while True:
line = process.stdout.readline()
if len(line) is 0:
return process.wait()
match = TEST_RESULT_RE.match(line)
if match:
sys.stdout.write(REPLACEMENTS[match.group(1)])
else:
sys.stdout.write(line)
sys.stdout.flush()
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))