2014-01-13 19:37:33 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import os
|
|
|
|
import socket
|
|
|
|
import sys
|
|
|
|
import codecs
|
|
|
|
|
|
|
|
|
2014-08-02 19:02:26 +02:00
|
|
|
test_type = sys.argv[1]
|
|
|
|
shell = sys.argv[2]
|
|
|
|
fname = os.path.join('tests', 'shell', shell + '.' + test_type + '.full.log')
|
|
|
|
new_fname = os.path.join('tests', 'shell', shell + '.' + test_type + '.log')
|
2014-01-26 18:30:01 +01:00
|
|
|
pid_fname = os.path.join('tests', 'shell', '3rd', 'pid')
|
2014-01-13 19:37:33 +01:00
|
|
|
|
2014-01-23 04:36:54 +01:00
|
|
|
|
2014-01-13 19:37:33 +01:00
|
|
|
with open(pid_fname, 'r') as P:
|
|
|
|
pid = P.read().strip()
|
|
|
|
hostname = socket.gethostname()
|
|
|
|
user = os.environ['USER']
|
|
|
|
|
|
|
|
with codecs.open(fname, 'r', encoding='utf-8') as R:
|
|
|
|
with codecs.open(new_fname, 'w', encoding='utf-8') as W:
|
|
|
|
found_cd = False
|
2014-01-23 04:45:35 +01:00
|
|
|
for line in (R if shell != 'fish' else R.read().split('\n')):
|
2014-01-13 19:37:33 +01:00
|
|
|
if not found_cd:
|
|
|
|
found_cd = ('cd tests/shell/3rd' in line)
|
|
|
|
continue
|
2014-01-17 22:59:19 +01:00
|
|
|
if 'true is the last line' in line:
|
|
|
|
break
|
2014-01-17 18:34:18 +01:00
|
|
|
line = line.translate({
|
|
|
|
ord('\r'): None
|
|
|
|
})
|
2014-01-13 19:37:33 +01:00
|
|
|
line = line.replace(hostname, 'HOSTNAME')
|
|
|
|
line = line.replace(user, 'USER')
|
2014-01-19 14:26:31 +01:00
|
|
|
line = line.replace(pid, 'PID')
|
2014-01-23 04:36:54 +01:00
|
|
|
if shell == 'fish':
|
|
|
|
try:
|
|
|
|
start = line.index('\033[0;')
|
|
|
|
end = line.index('\033[0m', start)
|
2014-02-26 05:49:25 +01:00
|
|
|
line = line[start:end + 4] + '\n'
|
2014-01-23 04:36:54 +01:00
|
|
|
except ValueError:
|
|
|
|
line = ''
|
2014-01-26 21:22:38 +01:00
|
|
|
elif shell == 'tcsh':
|
|
|
|
try:
|
|
|
|
start = line.index('\033[0;')
|
|
|
|
end = line.index(' ', start)
|
2014-02-26 05:49:25 +01:00
|
|
|
line = line[start:end] + '\033[0m\n'
|
2014-01-26 21:22:38 +01:00
|
|
|
except ValueError:
|
|
|
|
line = ''
|
2014-07-20 00:00:56 +02:00
|
|
|
elif shell == 'mksh':
|
|
|
|
# Output is different in travis: on my machine I see full
|
|
|
|
# command, in travis it is truncated just after `true`.
|
|
|
|
if line.startswith('[1] + Terminated'):
|
|
|
|
line = '[1] + Terminated bash -c ...\n'
|
2014-01-13 19:37:33 +01:00
|
|
|
W.write(line)
|