1 |
commit: aa7558a93d42d73ad916eecd2c3e8c6c294fe735 |
2 |
Author: Sergei Trofimovich <siarheit <AT> google <DOT> com> |
3 |
AuthorDate: Sat Mar 19 21:29:32 2016 +0000 |
4 |
Commit: Alexander Berntsen <bernalex <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Mar 29 10:10:36 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=aa7558a9 |
7 |
|
8 |
runtests: fix output for skipped pythons |
9 |
|
10 |
I have Pythons 2.7 and 3.4 installed. |
11 |
|
12 |
Before the patch I had the following output: |
13 |
|
14 |
$ ./runtests pym/portage/tests/resolver/test_blocker.py |
15 |
Testing with Python 2.7... |
16 |
Testing with Python 3.4... |
17 |
|
18 |
Summary: |
19 |
| Version | Status |
20 |
|-------------------- |
21 |
| 2.7 | PASS |
22 |
| 3.3 | PASS |
23 |
|
24 |
After the patch: |
25 |
|
26 |
$ ./runtests pym/portage/tests/resolver/test_blocker.py |
27 |
|
28 |
Testing with Python 2.7... |
29 |
Skip Python 3.3... |
30 |
Testing with Python 3.4... |
31 |
Skip Python pypy... |
32 |
Skip Python 3.5... |
33 |
|
34 |
Summary: |
35 |
| Version | Status |
36 |
|-------------------- |
37 |
| 2.7 | PASS |
38 |
| 3.4 | PASS |
39 |
|
40 |
Signed-off-by: Sergei Trofimovich <siarheit <AT> google.com> |
41 |
Signed-off-by: Alexander Berntsen <bernalex <AT> gentoo.org> |
42 |
Reviewed-by: Alexander Berntsen <bernalex <AT> gentoo.org> |
43 |
|
44 |
runtests | 16 +++++++++++----- |
45 |
1 file changed, 11 insertions(+), 5 deletions(-) |
46 |
|
47 |
diff --git a/runtests b/runtests |
48 |
index d492bc8..9135768 100755 |
49 |
--- a/runtests |
50 |
+++ b/runtests |
51 |
@@ -42,7 +42,7 @@ class Colors(object): |
52 |
_COLORS_YES = ('y', 'yes', 'true') |
53 |
_COLORS_NO = ('n', 'no', 'false') |
54 |
|
55 |
- GOOD = BAD = NORMAL = '' |
56 |
+ WARN = GOOD = BAD = NORMAL = '' |
57 |
|
58 |
def __init__(self, colorize=None): |
59 |
if colorize is None: |
60 |
@@ -63,6 +63,7 @@ class Colors(object): |
61 |
raise ValueError('--colors is invalid: %s' % colorize) |
62 |
|
63 |
if colorize: |
64 |
+ self.WARN = '\033[1;33m' |
65 |
self.GOOD = '\033[1;32m' |
66 |
self.BAD = '\033[1;31m' |
67 |
self.NORMAL = '\033[0m' |
68 |
@@ -135,11 +136,14 @@ def main(argv): |
69 |
if os.access(prog, os.X_OK): |
70 |
print('%sTesting with Python %s...%s' % |
71 |
(colors.GOOD, ver, colors.NORMAL)) |
72 |
- statuses.append(subprocess.call(cmd)) |
73 |
+ statuses.append((ver, subprocess.call(cmd))) |
74 |
elif not ignore_missing: |
75 |
print('%sCould not find requested Python %s%s' % |
76 |
(colors.BAD, ver, colors.NORMAL)) |
77 |
- statuses.append(1) |
78 |
+ statuses.append((ver, 1)) |
79 |
+ else: |
80 |
+ print('%sSkip Python %s...%s' % |
81 |
+ (colors.WARN, ver, colors.NORMAL)) |
82 |
print() |
83 |
finally: |
84 |
if tempdir is not None: |
85 |
@@ -154,7 +158,9 @@ def main(argv): |
86 |
width = 10 |
87 |
header = '| %-*s | %s' % (width, 'Version', 'Status') |
88 |
print('%s\n|%s' % (header, '-' * (len(header) - 1))) |
89 |
- for ver, status in zip(pyversions, statuses): |
90 |
+ exit_status = 0 |
91 |
+ for ver, status in statuses: |
92 |
+ exit_status += status |
93 |
if status: |
94 |
color = colors.BAD |
95 |
msg = 'FAIL' |
96 |
@@ -163,7 +169,7 @@ def main(argv): |
97 |
msg = 'PASS' |
98 |
print('| %s%-*s%s | %s%s%s' % |
99 |
(color, width, ver, colors.NORMAL, color, msg, colors.NORMAL)) |
100 |
- exit(sum(statuses)) |
101 |
+ exit(exit_status) |
102 |
|
103 |
|
104 |
if __name__ == '__main__': |