-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·58 lines (46 loc) · 1.33 KB
/
test.py
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
#!/usr/bin/env python
import sys
import pexpect
PASSED = 'PASSED:'
FAILED = 'FAILED:'
timeout = 1000
# end_stmt = u'[-]*RESULTS[-]*'
end_stmt = '---------------------RESULTS----------------------'
cmd = 'meteor npm run coverage-app-unit'
proc_fork = pexpect.spawnu(cmd)
# proc_fork.logfile = sys.stdout
proc_fork.expect(u'')
# index = proc_fork.expect([end_stmt, pexpect.EOF, pexpect.TIMEOUT],
# timeout=None)
lines = proc_fork.read_nonblocking(timeout=timeout, size=1000)
while end_stmt not in lines:
lines = lines.rstrip()
if len(lines) > 0:
print(lines)
try:
lines = proc_fork.read_nonblocking(timeout=timeout, size=1000)
except Exception:
pass
while PASSED not in lines:
if len(lines) > 0:
print(lines)
try:
lines = proc_fork.read_nonblocking(timeout=timeout, size=1000)
except Exception:
pass
idx = lines.find(PASSED)
num_passed = int(lines[idx:idx + len(PASSED) + 2][-1])
while FAILED not in lines:
if len(lines) > 0:
print(lines)
try:
lines = proc_fork.read_nonblocking(timeout=timeout, size=1000)
except Exception:
pass
print(lines)
idx = lines.find(FAILED)
num_failed = int(lines[idx:idx + len(FAILED) + 2][-1])
proc_fork.expect(u'Phantom[:][:]exit[(][)] called')
proc_fork.close()
if num_failed > 0:
sys.exit(num_failed)