]>
git.proxmox.com Git - mirror_xterm.js.git/blob - test/escape_sequence_files/run_tests.py
7 BASE_DIR
= os
.path
.dirname(os
.path
.abspath(__file__
))
10 def enable_echo(fd
, enabled
):
11 (iflag
, oflag
, cflag
, lflag
, ispeed
, ospeed
, cc
) = termios
.tcgetattr(fd
)
15 lflag
&= ~termios
.ECHO
16 new_attr
= [iflag
, oflag
, cflag
, lflag
, ispeed
, ospeed
, cc
]
17 termios
.tcsetattr(fd
, termios
.TCSANOW
, new_attr
)
19 atexit
.register(enable_echo
, sys
.stdin
.fileno(), True)
24 def log(append
=False, *s
):
26 output
[-1] += ' ' + ' '.join(str(part
) for part
in s
)
28 output
.append(' '.join(str(part
) for part
in s
))
32 sys
.stdout
.write('\x1bc\x1b[H')
39 for i
, testfile
in enumerate(sorted(glob(os
.path
.join(BASE_DIR
, '*.in')))):
41 log(False, os
.path
.basename(testfile
))
43 with
open(testfile
) as test
:
44 sys
.stdout
.write('\x1b]0;%s\x07' % os
.path
.basename(testfile
))
45 sys
.stdout
.write(test
.read()+'\x1bt')
47 with
open(os
.path
.join(os
.path
.dirname(testfile
),
48 os
.path
.basename(testfile
).split('.')[0]+'.text')) as expected
:
49 terminal_output
= sys
.stdin
.read()
50 if not terminal_output
:
53 if terminal_output
!= expected
.read():
54 log(True, '\x1b[31merror\x1b[0m')
55 with
open(os
.path
.join(os
.path
.dirname(testfile
), 'output',
56 os
.path
.basename(testfile
)), 'w') as t_out
:
57 t_out
.write(terminal_output
)
60 log(True, '\x1b[32mpass\x1b[0m')
64 if __name__
== '__main__':
65 enable_echo(sys
.stdin
.fileno(), False)
66 count
, passed
= test()
67 enable_echo(sys
.stdin
.fileno(), True)
69 for i
in range(len(output
)/2+1):
72 print ''.join(i
.ljust(40) for i
in output
[i
*2:i
*2+2])
73 print '\x1b[33mcoverage: %s/%s (%d%%) tests passed.\x1b[0m' % (passed
, count
, passed
*100/count
)