annotate tests/test-check-module-imports.t @ 29212:8005e0e0eb33

tests: enable import checker for all **.py files Several known-bad files are excluded as they couldn't be trivially fixed. That's the same as 99a2bdad0fda.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 14 May 2016 14:16:43 +0900
parents cba8bc11ed10
children 3c9066ed557c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23894
f388ceae2250 test-module-imports: use test-repo requirement
Matt Mackall <mpm@selenic.com>
parents: 22947
diff changeset
1 #require test-repo
f388ceae2250 test-module-imports: use test-repo requirement
Matt Mackall <mpm@selenic.com>
parents: 22947
diff changeset
2
20039
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
3 $ import_checker="$TESTDIR"/../contrib/import-checker.py
23894
f388ceae2250 test-module-imports: use test-repo requirement
Matt Mackall <mpm@selenic.com>
parents: 22947
diff changeset
4
20039
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
5 Run the doctests from the import checker, and make sure
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
6 it's working correctly.
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
7 $ TERM=dumb
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
8 $ export TERM
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
9 $ python -m doctest $import_checker
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
10
25703
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
11 Run additional tests for the import checker
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
12
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
13 $ mkdir testpackage
29206
0ec8501af800 import-checker: fix test to make a real package
Yuya Nishihara <yuya@tcha.org>
parents: 28923
diff changeset
14 $ touch testpackage/__init__.py
25703
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
15
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
16 $ cat > testpackage/multiple.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
17 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
18 > import os, sys
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
19 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
20
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
21 $ cat > testpackage/unsorted.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
22 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
23 > import sys
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
24 > import os
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
25 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
26
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
27 $ cat > testpackage/stdafterlocal.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
28 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
29 > from . import unsorted
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
30 > import os
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
31 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
32
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
33 $ cat > testpackage/requirerelative.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
34 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
35 > import testpackage.unsorted
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
36 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
37
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
38 $ cat > testpackage/importalias.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
39 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
40 > import ui
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
41 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
42
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
43 $ cat > testpackage/relativestdlib.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
44 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
45 > from .. import os
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
46 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
47
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
48 $ cat > testpackage/symbolimport.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
49 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
50 > from .unsorted import foo
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
51 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
52
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
53 $ cat > testpackage/latesymbolimport.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
54 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
55 > from . import unsorted
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
56 > from mercurial.node import hex
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
57 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
58
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
59 $ cat > testpackage/multiplegroups.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
60 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
61 > from . import unsorted
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
62 > from . import more
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
63 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
64
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
65 $ mkdir testpackage/subpackage
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
66 $ cat > testpackage/subpackage/levelpriority.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
67 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
68 > from . import foo
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
69 > from .. import parent
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
70 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
71
26964
5abba2c92da3 import-checker: allow import of child modules from package root
Yuya Nishihara <yuya@tcha.org>
parents: 26956
diff changeset
72 $ touch testpackage/subpackage/foo.py
5abba2c92da3 import-checker: allow import of child modules from package root
Yuya Nishihara <yuya@tcha.org>
parents: 26956
diff changeset
73 $ cat > testpackage/subpackage/__init__.py << EOF
5abba2c92da3 import-checker: allow import of child modules from package root
Yuya Nishihara <yuya@tcha.org>
parents: 26956
diff changeset
74 > from __future__ import absolute_import
5abba2c92da3 import-checker: allow import of child modules from package root
Yuya Nishihara <yuya@tcha.org>
parents: 26956
diff changeset
75 > from . import levelpriority # should not cause cycle
5abba2c92da3 import-checker: allow import of child modules from package root
Yuya Nishihara <yuya@tcha.org>
parents: 26956
diff changeset
76 > EOF
5abba2c92da3 import-checker: allow import of child modules from package root
Yuya Nishihara <yuya@tcha.org>
parents: 26956
diff changeset
77
26965
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
78 $ cat > testpackage/subpackage/localimport.py << EOF
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
79 > from __future__ import absolute_import
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
80 > from . import foo
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
81 > def bar():
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
82 > # should not cause "higher-level import should come first"
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
83 > from .. import unsorted
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
84 > # but other errors should be detected
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
85 > from .. import more
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
86 > import testpackage.subpackage.levelpriority
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
87 > EOF
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
88
27272
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
89 $ cat > testpackage/importmodulefromsub.py << EOF
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
90 > from __future__ import absolute_import
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
91 > from .subpackage import foo # not a "direct symbol import"
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
92 > EOF
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
93
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
94 $ cat > testpackage/importsymbolfromsub.py << EOF
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
95 > from __future__ import absolute_import
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
96 > from .subpackage import foo, nonmodule
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
97 > EOF
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
98
25703
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
99 $ cat > testpackage/sortedentries.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
100 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
101 > from . import (
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
102 > foo,
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
103 > bar,
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
104 > )
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
105 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
106
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
107 $ cat > testpackage/importfromalias.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
108 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
109 > from . import ui
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
110 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
111
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
112 $ cat > testpackage/importfromrelative.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
113 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
114 > from testpackage.unsorted import foo
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
115 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
116
29208
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
117 $ mkdir testpackage2
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
118 $ touch testpackage2/__init__.py
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
119
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
120 $ cat > testpackage2/latesymbolimport.py << EOF
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
121 > from __future__ import absolute_import
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
122 > from testpackage import unsorted
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
123 > from mercurial.node import hex
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
124 > EOF
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
125
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
126 $ python "$import_checker" testpackage*/*.py testpackage/subpackage/*.py
26956
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
127 testpackage/importalias.py:2: ui module must be "as" aliased to uimod
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
128 testpackage/importfromalias.py:2: ui from testpackage must be "as" aliased to uimod
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
129 testpackage/importfromrelative.py:2: import should be relative: testpackage.unsorted
27273
5d5b98346fc2 import-checker: tell which symbol causes "direct symbol import"
Yuya Nishihara <yuya@tcha.org>
parents: 27272
diff changeset
130 testpackage/importfromrelative.py:2: direct symbol import foo from testpackage.unsorted
5d5b98346fc2 import-checker: tell which symbol causes "direct symbol import"
Yuya Nishihara <yuya@tcha.org>
parents: 27272
diff changeset
131 testpackage/importsymbolfromsub.py:2: direct symbol import nonmodule from testpackage.subpackage
26956
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
132 testpackage/latesymbolimport.py:3: symbol import follows non-symbol import: mercurial.node
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
133 testpackage/multiple.py:2: multiple imported names: os, sys
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
134 testpackage/multiplegroups.py:3: multiple "from . import" statements
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
135 testpackage/relativestdlib.py:2: relative import of stdlib module
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
136 testpackage/requirerelative.py:2: import should be relative: testpackage.unsorted
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
137 testpackage/sortedentries.py:2: imports from testpackage not lexically sorted: bar < foo
28330
f3fb24e36d61 import-checker: report local with stdlib late warning
timeless <timeless@mozdev.org>
parents: 28275
diff changeset
138 testpackage/stdafterlocal.py:3: stdlib import "os" follows local import: testpackage
26956
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
139 testpackage/subpackage/levelpriority.py:3: higher-level import should come first: testpackage
26965
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
140 testpackage/subpackage/localimport.py:7: multiple "from .. import" statements
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
141 testpackage/subpackage/localimport.py:8: import should be relative: testpackage.subpackage.levelpriority
27273
5d5b98346fc2 import-checker: tell which symbol causes "direct symbol import"
Yuya Nishihara <yuya@tcha.org>
parents: 27272
diff changeset
142 testpackage/symbolimport.py:2: direct symbol import foo from testpackage.unsorted
26956
4b56214ebb7a import-checker: include lineno in warning message
Yuya Nishihara <yuya@tcha.org>
parents: 25989
diff changeset
143 testpackage/unsorted.py:3: imports not lexically sorted: os < sys
29208
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
144 testpackage2/latesymbolimport.py:3: symbol import follows non-symbol import: mercurial.node
25731
cd1daab5d036 import-checker.py: exit with code 0 if no error is detected
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25703
diff changeset
145 [1]
25703
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
146
20039
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
147 $ cd "$TESTDIR"/..
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
148
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
149 There are a handful of cases here that require renaming a module so it
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
150 doesn't overlap with a stdlib module name. There are also some cycles
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
151 here that we should still endeavor to fix, and some cycles will be
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
152 hidden by deduplication algorithm in the cycle detector, so fixing
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
153 these may expose other cycles.
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
154
28844
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
155 Known-bad files are excluded by -X as some of them would produce unstable
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
156 outputs, which should be fixed later.
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
157
29212
8005e0e0eb33 tests: enable import checker for all **.py files
Yuya Nishihara <yuya@tcha.org>
parents: 29208
diff changeset
158 $ hg locate '**.py' \
28923
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
159 > 'tests/**.t' \
29212
8005e0e0eb33 tests: enable import checker for all **.py files
Yuya Nishihara <yuya@tcha.org>
parents: 29208
diff changeset
160 > -X contrib/debugshell.py \
8005e0e0eb33 tests: enable import checker for all **.py files
Yuya Nishihara <yuya@tcha.org>
parents: 29208
diff changeset
161 > -X contrib/win32/hgwebdir_wsgi.py \
8005e0e0eb33 tests: enable import checker for all **.py files
Yuya Nishihara <yuya@tcha.org>
parents: 29208
diff changeset
162 > -X doc/gendoc.py \
8005e0e0eb33 tests: enable import checker for all **.py files
Yuya Nishihara <yuya@tcha.org>
parents: 29208
diff changeset
163 > -X doc/hgmanpage.py \
28844
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
164 > -X tests/test-hgweb-auth.py \
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
165 > -X tests/hypothesishelpers.py \
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
166 > -X tests/test-ctxmanager.py \
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
167 > -X tests/test-lock.py \
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
168 > -X tests/test-verify-repo-operations.py \
28923
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
169 > -X tests/test-hook.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
170 > -X tests/test-import.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
171 > -X tests/test-check-module-imports.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
172 > -X tests/test-commit-interactive.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
173 > -X tests/test-contrib-check-code.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
174 > -X tests/test-extension.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
175 > -X tests/test-hghave.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
176 > -X tests/test-hgweb-no-path-info.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
177 > -X tests/test-hgweb-no-request-uri.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
178 > -X tests/test-hgweb-non-interactive.t \
28844
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
179 > | sed 's-\\-/-g' | python "$import_checker" -
25176
665a9deae8dd tests: check import cycles in hgext/**.py, too
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25174
diff changeset
180 Import cycle: hgext.largefiles.basestore -> hgext.largefiles.localstore -> hgext.largefiles.basestore
25731
cd1daab5d036 import-checker.py: exit with code 0 if no error is detected
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25703
diff changeset
181 [1]