1 |
commit: 70a41bd4404cccc502a3eacf6335c8d2c9503129 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jan 30 22:53:50 2015 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Feb 1 09:06:41 2015 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=70a41bd4 |
7 |
|
8 |
test_compile_modules: skip files that require newer Python version |
9 |
|
10 |
Support skipping Python modules and scripts that require newer Python |
11 |
version than currently used during compile tests. Add a metadata db that |
12 |
can be used to store additional information about Python files, and |
13 |
store the required language version there. |
14 |
|
15 |
--- |
16 |
pym/portage/tests/lint/metadata.py | 11 +++++++++++ |
17 |
pym/portage/tests/lint/test_compile_modules.py | 13 +++++++++++++ |
18 |
2 files changed, 24 insertions(+) |
19 |
|
20 |
diff --git a/pym/portage/tests/lint/metadata.py b/pym/portage/tests/lint/metadata.py |
21 |
new file mode 100644 |
22 |
index 0000000..e3f90cb |
23 |
--- /dev/null |
24 |
+++ b/pym/portage/tests/lint/metadata.py |
25 |
@@ -0,0 +1,11 @@ |
26 |
+# Copyright 2015 Gentoo Foundation |
27 |
+# Distributed under the terms of the GNU General Public License v2 |
28 |
+ |
29 |
+module_metadata = { |
30 |
+} |
31 |
+ |
32 |
+script_metadata = { |
33 |
+ 'socks5-server.py': { |
34 |
+ 'required_python': '3.3', |
35 |
+ }, |
36 |
+} |
37 |
|
38 |
diff --git a/pym/portage/tests/lint/test_compile_modules.py b/pym/portage/tests/lint/test_compile_modules.py |
39 |
index 4826cad..51eb8cd 100644 |
40 |
--- a/pym/portage/tests/lint/test_compile_modules.py |
41 |
+++ b/pym/portage/tests/lint/test_compile_modules.py |
42 |
@@ -4,9 +4,11 @@ |
43 |
import errno |
44 |
import itertools |
45 |
import stat |
46 |
+import sys |
47 |
|
48 |
from portage.const import PORTAGE_BIN_PATH, PORTAGE_PYM_PATH, PORTAGE_PYM_PACKAGES |
49 |
from portage.tests import TestCase |
50 |
+from portage.tests.lint.metadata import module_metadata, script_metadata |
51 |
from portage import os |
52 |
from portage import _encodings |
53 |
from portage import _unicode_decode, _unicode_encode |
54 |
@@ -30,6 +32,17 @@ class CompileModulesTestCase(TestCase): |
55 |
st = os.lstat(x) |
56 |
if not stat.S_ISREG(st.st_mode): |
57 |
continue |
58 |
+ |
59 |
+ bin_path = os.path.relpath(x, PORTAGE_BIN_PATH) |
60 |
+ mod_path = os.path.relpath(x, PORTAGE_PYM_PATH) |
61 |
+ |
62 |
+ meta = module_metadata.get(mod_path) or script_metadata.get(bin_path) |
63 |
+ if meta: |
64 |
+ req_py = tuple(int(x) for x |
65 |
+ in meta.get('required_python', '0.0').split('.')) |
66 |
+ if sys.version_info < req_py: |
67 |
+ continue |
68 |
+ |
69 |
do_compile = False |
70 |
if x[-3:] == '.py': |
71 |
do_compile = True |