##// END OF EJS Templates
tests: expand our coverage of errors in Python 3 for bad extensions...
Augie Fackler -
r40273:772c1145 default
parent child Browse files
Show More
@@ -1,142 +1,151 b''
1 ensure that failing ui.atexit handlers report sensibly
1 ensure that failing ui.atexit handlers report sensibly
2
2
3 $ cat > $TESTTMP/bailatexit.py <<EOF
3 $ cat > $TESTTMP/bailatexit.py <<EOF
4 > from mercurial import util
4 > from mercurial import util
5 > def bail():
5 > def bail():
6 > raise RuntimeError('ui.atexit handler exception')
6 > raise RuntimeError('ui.atexit handler exception')
7 >
7 >
8 > def extsetup(ui):
8 > def extsetup(ui):
9 > ui.atexit(bail)
9 > ui.atexit(bail)
10 > EOF
10 > EOF
11 $ hg -q --config extensions.bailatexit=$TESTTMP/bailatexit.py \
11 $ hg -q --config extensions.bailatexit=$TESTTMP/bailatexit.py \
12 > help help
12 > help help
13 hg help [-ecks] [TOPIC]
13 hg help [-ecks] [TOPIC]
14
14
15 show help for a given topic or a help overview
15 show help for a given topic or a help overview
16 error in exit handlers:
16 error in exit handlers:
17 Traceback (most recent call last):
17 Traceback (most recent call last):
18 File "*/mercurial/dispatch.py", line *, in _runexithandlers (glob)
18 File "*/mercurial/dispatch.py", line *, in _runexithandlers (glob)
19 func(*args, **kwargs)
19 func(*args, **kwargs)
20 File "$TESTTMP/bailatexit.py", line *, in bail (glob)
20 File "$TESTTMP/bailatexit.py", line *, in bail (glob)
21 raise RuntimeError('ui.atexit handler exception')
21 raise RuntimeError('ui.atexit handler exception')
22 RuntimeError: ui.atexit handler exception
22 RuntimeError: ui.atexit handler exception
23 [255]
23 [255]
24
24
25 $ rm $TESTTMP/bailatexit.py
25 $ rm $TESTTMP/bailatexit.py
26
26
27 another bad extension
27 another bad extension
28
28
29 $ echo 'raise Exception("bit bucket overflow")' > badext.py
29 $ echo 'raise Exception("bit bucket overflow")' > badext.py
30 $ abspathexc=`pwd`/badext.py
30 $ abspathexc=`pwd`/badext.py
31
31
32 $ cat >baddocext.py <<EOF
32 $ cat >baddocext.py <<EOF
33 > """
33 > """
34 > baddocext is bad
34 > baddocext is bad
35 > """
35 > """
36 > EOF
36 > EOF
37 $ abspathdoc=`pwd`/baddocext.py
37 $ abspathdoc=`pwd`/baddocext.py
38
38
39 $ cat <<EOF >> $HGRCPATH
39 $ cat <<EOF >> $HGRCPATH
40 > [extensions]
40 > [extensions]
41 > gpg =
41 > gpg =
42 > hgext.gpg =
42 > hgext.gpg =
43 > badext = $abspathexc
43 > badext = $abspathexc
44 > baddocext = $abspathdoc
44 > baddocext = $abspathdoc
45 > badext2 =
45 > badext2 =
46 > EOF
46 > EOF
47
47
48 $ hg -q help help 2>&1 |grep extension
48 $ hg -q help help 2>&1 |grep extension
49 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
49 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
50 *** failed to import extension badext2: No module named *badext2* (glob)
50 *** failed to import extension badext2: No module named *badext2* (glob)
51
51
52 show traceback
52 show traceback
53
53
54 $ hg -q help help --traceback 2>&1 | egrep ' extension|^Exception|Traceback|ImportError'
54 $ hg -q help help --traceback 2>&1 | egrep ' extension|^Exception|Traceback|ImportError|ModuleNotFound'
55 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
55 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
56 Traceback (most recent call last):
56 Traceback (most recent call last):
57 Exception: bit bucket overflow
57 Exception: bit bucket overflow
58 *** failed to import extension badext2: No module named *badext2* (glob)
58 *** failed to import extension badext2: No module named *badext2* (glob)
59 Traceback (most recent call last):
59 Traceback (most recent call last):
60 ImportError: No module named badext2 (no-py3k !)
60 ImportError: No module named badext2 (no-py3k !)
61 ModuleNotFoundError: No module named 'hgext.badext2' (py3k !)
61 Traceback (most recent call last): (py3k !)
62 Traceback (most recent call last): (py3k !)
63 ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3k !)
62 Traceback (most recent call last): (py3k !)
64 Traceback (most recent call last): (py3k !)
65 ModuleNotFoundError: No module named 'badext2' (py3k !)
63
66
64 names of extensions failed to load can be accessed via extensions.notloaded()
67 names of extensions failed to load can be accessed via extensions.notloaded()
65
68
66 $ cat <<EOF > showbadexts.py
69 $ cat <<EOF > showbadexts.py
67 > from mercurial import commands, extensions, registrar
70 > from mercurial import commands, extensions, registrar
68 > cmdtable = {}
71 > cmdtable = {}
69 > command = registrar.command(cmdtable)
72 > command = registrar.command(cmdtable)
70 > @command(b'showbadexts', norepo=True)
73 > @command(b'showbadexts', norepo=True)
71 > def showbadexts(ui, *pats, **opts):
74 > def showbadexts(ui, *pats, **opts):
72 > ui.write(b'BADEXTS: %s\n' % b' '.join(sorted(extensions.notloaded())))
75 > ui.write(b'BADEXTS: %s\n' % b' '.join(sorted(extensions.notloaded())))
73 > EOF
76 > EOF
74 $ hg --config extensions.badexts=showbadexts.py showbadexts 2>&1 | grep '^BADEXTS'
77 $ hg --config extensions.badexts=showbadexts.py showbadexts 2>&1 | grep '^BADEXTS'
75 BADEXTS: badext badext2
78 BADEXTS: badext badext2
76
79
77 #if no-extraextensions
80 #if no-extraextensions
78 show traceback for ImportError of hgext.name if devel.debug.extensions is set
81 show traceback for ImportError of hgext.name if devel.debug.extensions is set
79
82
80 $ (hg help help --traceback --debug --config devel.debug.extensions=yes 2>&1) \
83 $ (hg help help --traceback --debug --config devel.debug.extensions=yes 2>&1) \
81 > | grep -v '^ ' \
84 > | grep -v '^ ' \
82 > | egrep 'extension..[^p]|^Exception|Traceback|ImportError|not import'
85 > | egrep 'extension..[^p]|^Exception|Traceback|ImportError|not import|ModuleNotFound'
83 debug.extensions: loading extensions
86 debug.extensions: loading extensions
84 debug.extensions: - processing 5 entries
87 debug.extensions: - processing 5 entries
85 debug.extensions: - loading extension: 'gpg'
88 debug.extensions: - loading extension: 'gpg'
86 debug.extensions: > 'gpg' extension loaded in * (glob)
89 debug.extensions: > 'gpg' extension loaded in * (glob)
87 debug.extensions: - validating extension tables: 'gpg'
90 debug.extensions: - validating extension tables: 'gpg'
88 debug.extensions: - invoking registered callbacks: 'gpg'
91 debug.extensions: - invoking registered callbacks: 'gpg'
89 debug.extensions: > callbacks completed in * (glob)
92 debug.extensions: > callbacks completed in * (glob)
90 debug.extensions: - loading extension: 'badext'
93 debug.extensions: - loading extension: 'badext'
91 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
94 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
92 Traceback (most recent call last):
95 Traceback (most recent call last):
93 Exception: bit bucket overflow
96 Exception: bit bucket overflow
94 debug.extensions: - loading extension: 'baddocext'
97 debug.extensions: - loading extension: 'baddocext'
95 debug.extensions: > 'baddocext' extension loaded in * (glob)
98 debug.extensions: > 'baddocext' extension loaded in * (glob)
96 debug.extensions: - validating extension tables: 'baddocext'
99 debug.extensions: - validating extension tables: 'baddocext'
97 debug.extensions: - invoking registered callbacks: 'baddocext'
100 debug.extensions: - invoking registered callbacks: 'baddocext'
98 debug.extensions: > callbacks completed in * (glob)
101 debug.extensions: > callbacks completed in * (glob)
99 debug.extensions: - loading extension: 'badext2'
102 debug.extensions: - loading extension: 'badext2'
100 debug.extensions: - could not import hgext.badext2 (No module named *badext2*): trying hgext3rd.badext2 (glob)
103 debug.extensions: - could not import hgext.badext2 (No module named *badext2*): trying hgext3rd.badext2 (glob)
101 Traceback (most recent call last):
104 Traceback (most recent call last):
102 ImportError: No module named badext2 (no-py3k !)
105 ImportError: No module named badext2 (no-py3k !)
106 ModuleNotFoundError: No module named 'hgext.badext2' (py3k !)
103 debug.extensions: - could not import hgext3rd.badext2 (No module named *badext2*): trying badext2 (glob)
107 debug.extensions: - could not import hgext3rd.badext2 (No module named *badext2*): trying badext2 (glob)
104 Traceback (most recent call last):
108 Traceback (most recent call last):
105 ImportError: No module named badext2 (no-py3k !)
109 ImportError: No module named badext2 (no-py3k !)
110 ModuleNotFoundError: No module named 'hgext.badext2' (py3k !)
106 Traceback (most recent call last): (py3k !)
111 Traceback (most recent call last): (py3k !)
112 ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3k !)
107 *** failed to import extension badext2: No module named *badext2* (glob)
113 *** failed to import extension badext2: No module named *badext2* (glob)
108 Traceback (most recent call last):
114 Traceback (most recent call last):
115 ModuleNotFoundError: No module named 'hgext.badext2' (py3k !)
109 Traceback (most recent call last): (py3k !)
116 Traceback (most recent call last): (py3k !)
117 ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3k !)
110 Traceback (most recent call last): (py3k !)
118 Traceback (most recent call last): (py3k !)
119 ModuleNotFoundError: No module named 'badext2' (py3k !)
111 ImportError: No module named badext2 (no-py3k !)
120 ImportError: No module named badext2 (no-py3k !)
112 debug.extensions: > loaded 2 extensions, total time * (glob)
121 debug.extensions: > loaded 2 extensions, total time * (glob)
113 debug.extensions: - loading configtable attributes
122 debug.extensions: - loading configtable attributes
114 debug.extensions: - executing uisetup hooks
123 debug.extensions: - executing uisetup hooks
115 debug.extensions: - running uisetup for 'gpg'
124 debug.extensions: - running uisetup for 'gpg'
116 debug.extensions: > uisetup for 'gpg' took * (glob)
125 debug.extensions: > uisetup for 'gpg' took * (glob)
117 debug.extensions: - running uisetup for 'baddocext'
126 debug.extensions: - running uisetup for 'baddocext'
118 debug.extensions: > uisetup for 'baddocext' took * (glob)
127 debug.extensions: > uisetup for 'baddocext' took * (glob)
119 debug.extensions: > all uisetup took * (glob)
128 debug.extensions: > all uisetup took * (glob)
120 debug.extensions: - executing extsetup hooks
129 debug.extensions: - executing extsetup hooks
121 debug.extensions: - running extsetup for 'gpg'
130 debug.extensions: - running extsetup for 'gpg'
122 debug.extensions: > extsetup for 'gpg' took * (glob)
131 debug.extensions: > extsetup for 'gpg' took * (glob)
123 debug.extensions: - running extsetup for 'baddocext'
132 debug.extensions: - running extsetup for 'baddocext'
124 debug.extensions: > extsetup for 'baddocext' took * (glob)
133 debug.extensions: > extsetup for 'baddocext' took * (glob)
125 debug.extensions: > all extsetup took * (glob)
134 debug.extensions: > all extsetup took * (glob)
126 debug.extensions: - executing remaining aftercallbacks
135 debug.extensions: - executing remaining aftercallbacks
127 debug.extensions: > remaining aftercallbacks completed in * (glob)
136 debug.extensions: > remaining aftercallbacks completed in * (glob)
128 debug.extensions: - loading extension registration objects
137 debug.extensions: - loading extension registration objects
129 debug.extensions: > extension registration object loading took * (glob)
138 debug.extensions: > extension registration object loading took * (glob)
130 debug.extensions: > extension baddocext take a total of * to load (glob)
139 debug.extensions: > extension baddocext take a total of * to load (glob)
131 debug.extensions: > extension gpg take a total of * to load (glob)
140 debug.extensions: > extension gpg take a total of * to load (glob)
132 debug.extensions: extension loading complete
141 debug.extensions: extension loading complete
133 #endif
142 #endif
134
143
135 confirm that there's no crash when an extension's documentation is bad
144 confirm that there's no crash when an extension's documentation is bad
136
145
137 $ hg help --keyword baddocext
146 $ hg help --keyword baddocext
138 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
147 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
139 *** failed to import extension badext2: No module named *badext2* (glob)
148 *** failed to import extension badext2: No module named *badext2* (glob)
140 Topics:
149 Topics:
141
150
142 extensions Using Additional Features
151 extensions Using Additional Features
General Comments 0
You need to be logged in to leave comments. Login now