annotate tests/test-check-module-imports.t @ 29914:770128405002

debugrevspec: deprecate --optimize option This option has been superseded by '--show-stage NAME', and will cause confusion in future patches.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 21 Aug 2016 12:36:23 +0900
parents 814076f4ace3
children b86a448a2965
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
29219
3c9066ed557c tests: silence test-repo obsolete warning
timeless <timeless@mozdev.org>
parents: 29212
diff changeset
3 $ . "$TESTDIR/helpers-testrepo.sh"
20039
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
4 $ 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
5
20039
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
6 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
7 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
8 $ TERM=dumb
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
9 $ export TERM
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
10 $ 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
11
25703
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
12 Run additional tests for the import checker
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
13
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
14 $ mkdir testpackage
29206
0ec8501af800 import-checker: fix test to make a real package
Yuya Nishihara <yuya@tcha.org>
parents: 28923
diff changeset
15 $ touch testpackage/__init__.py
25703
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
16
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
17 $ cat > testpackage/multiple.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
18 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
19 > import os, sys
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
20 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
21
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
22 $ cat > testpackage/unsorted.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
23 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
24 > import sys
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
25 > import os
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
26 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
27
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
28 $ cat > testpackage/stdafterlocal.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
29 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
30 > from . import unsorted
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
31 > import os
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
32 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
33
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
34 $ cat > testpackage/requirerelative.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
35 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
36 > import testpackage.unsorted
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
37 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
38
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
39 $ cat > testpackage/importalias.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
40 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
41 > import ui
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
42 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
43
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
44 $ cat > testpackage/relativestdlib.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
45 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
46 > from .. import os
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
47 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
48
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
49 $ cat > testpackage/symbolimport.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
50 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
51 > from .unsorted import foo
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
52 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
53
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
54 $ cat > testpackage/latesymbolimport.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
55 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
56 > from . import unsorted
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
57 > from mercurial.node import hex
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
58 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
59
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
60 $ cat > testpackage/multiplegroups.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
61 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
62 > from . import unsorted
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
63 > from . import more
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
64 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
65
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
66 $ mkdir testpackage/subpackage
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
67 $ cat > testpackage/subpackage/levelpriority.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
68 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
69 > from . import foo
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
70 > from .. import parent
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
71 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
72
26964
5abba2c92da3 import-checker: allow import of child modules from package root
Yuya Nishihara <yuya@tcha.org>
parents: 26956
diff changeset
73 $ 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
74 $ 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
75 > 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
76 > 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
77 > EOF
5abba2c92da3 import-checker: allow import of child modules from package root
Yuya Nishihara <yuya@tcha.org>
parents: 26956
diff changeset
78
26965
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
79 $ 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
80 > 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
81 > from . import foo
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
82 > def bar():
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
83 > # 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
84 > from .. import unsorted
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
85 > # 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
86 > from .. import more
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
87 > import testpackage.subpackage.levelpriority
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
88 > EOF
1fa66d3ad28d import-checker: reset context to verify convention in function scope
Yuya Nishihara <yuya@tcha.org>
parents: 26964
diff changeset
89
27272
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
90 $ 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
91 > 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
92 > 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
93 > EOF
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
94
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
95 $ 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
96 > 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
97 > 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
98 > EOF
69308357ecd1 import-checker: allow absolute imports of sub modules from local packages
Yuya Nishihara <yuya@tcha.org>
parents: 26965
diff changeset
99
25703
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
100 $ cat > testpackage/sortedentries.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
101 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
102 > from . import (
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
103 > foo,
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
104 > bar,
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
105 > )
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
106 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
107
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
108 $ cat > testpackage/importfromalias.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
109 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
110 > from . import ui
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
111 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
112
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
113 $ cat > testpackage/importfromrelative.py << EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
114 > from __future__ import absolute_import
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
115 > from testpackage.unsorted import foo
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
116 > EOF
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
117
29208
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
118 $ mkdir testpackage2
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
119 $ 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
120
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
121 $ 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
122 > 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
123 > 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
124 > 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
125 > EOF
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
126
cba8bc11ed10 import-checker: extend check of symbol-import order to all local modules
Yuya Nishihara <yuya@tcha.org>
parents: 29206
diff changeset
127 $ 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
128 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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 [1]
25703
1a6a117d0b95 import-checker: establish modern import convention
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25498
diff changeset
147
20039
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
148 $ cd "$TESTDIR"/..
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
149
05626e87489c test-module-imports.t: new test to use the import cycle detector
Augie Fackler <raf@durin42.com>
parents:
diff changeset
150 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
151 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
152 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
153 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
154 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
155
28844
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
156 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
157 outputs, which should be fixed later.
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
158
29234
393aef802535 tests: enable import checker for all python files (including no .py files)
Yuya Nishihara <yuya@tcha.org>
parents: 29219
diff changeset
159 $ hg locate 'set:**.py or grep(r"^#!.*?python")' \
28923
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
160 > 'tests/**.t' \
29212
8005e0e0eb33 tests: enable import checker for all **.py files
Yuya Nishihara <yuya@tcha.org>
parents: 29208
diff changeset
161 > -X contrib/debugshell.py \
8005e0e0eb33 tests: enable import checker for all **.py files
Yuya Nishihara <yuya@tcha.org>
parents: 29208
diff changeset
162 > -X contrib/win32/hgwebdir_wsgi.py \
8005e0e0eb33 tests: enable import checker for all **.py files
Yuya Nishihara <yuya@tcha.org>
parents: 29208
diff changeset
163 > -X doc/gendoc.py \
8005e0e0eb33 tests: enable import checker for all **.py files
Yuya Nishihara <yuya@tcha.org>
parents: 29208
diff changeset
164 > -X doc/hgmanpage.py \
29234
393aef802535 tests: enable import checker for all python files (including no .py files)
Yuya Nishihara <yuya@tcha.org>
parents: 29219
diff changeset
165 > -X i18n/posplit \
28844
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
166 > -X tests/test-hgweb-auth.py \
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
167 > -X tests/hypothesishelpers.py \
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
168 > -X tests/test-ctxmanager.py \
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
169 > -X tests/test-lock.py \
99a2bdad0fda tests: enable import checker for tests/**.py files
Yuya Nishihara <yuya@tcha.org>
parents: 28330
diff changeset
170 > -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
171 > -X tests/test-hook.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
172 > -X tests/test-import.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
173 > -X tests/test-check-module-imports.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
174 > -X tests/test-commit-interactive.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
175 > -X tests/test-contrib-check-code.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
176 > -X tests/test-extension.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
177 > -X tests/test-hghave.t \
531dea16f4f7 tests: run import-checker with tests .t files
timeless <timeless@mozdev.org>
parents: 28844
diff changeset
178 > -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
179 > -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
180 > -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
181 > | sed 's-\\-/-g' | python "$import_checker" -