Debian Codegraph @

tests/test-bad-extension.t

raw
1 #require no-chg
2 $ filterlog () {
3 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!'
4 > }
5
6 ensure that failing ui.atexit handlers report sensibly
7
8 $ cat > $TESTTMP/bailatexit.py <<EOF
9 > from mercurial import util
10 > def bail():
11 > raise RuntimeError('ui.atexit handler exception')
12 >
13 > def extsetup(ui):
14 > ui.atexit(bail)
15 > EOF
16 $ hg -q --config extensions.bailatexit=$TESTTMP/bailatexit.py \
17 > help help
18 hg help [-eck] [-s PLATFORM] [TOPIC]
19
20 show help for a given topic or a help overview
21 error in exit handlers:
22 Traceback (most recent call last):
23 File "*/mercurial/main_script/__init__.py", line *, in _runexithandlers (glob) (no-pyoxidizer !)
24 File "mercurial/main_script/__init__.py", line *, in _runexithandlers (glob) (pyoxidizer !)
25 func(*args, **kwargs)
26 ~~~~^^^^^^^^^^^^^^^^^ (py313 !)
27 File "$TESTTMP/bailatexit.py", line *, in bail (glob)
28 raise RuntimeError('ui.atexit handler exception')
29 RuntimeError: ui.atexit handler exception
30 [255]
31
32 $ rm $TESTTMP/bailatexit.py
33
34 another bad extension
35
36 $ echo 'raise Exception("bit bucket overflow")' > badext.py
37 $ abspathexc=`pwd`/badext.py
38
39 $ cat >baddocext.py <<EOF
40 > """
41 > baddocext is bad
42 > """
43 > EOF
44 $ abspathdoc=`pwd`/baddocext.py
45
46 $ cat <<EOF >> $HGRCPATH
47 > [extensions]
48 > gpg =
49 > hgext.gpg =
50 > badext = $abspathexc
51 > baddocext = $abspathdoc
52 > badext2 =
53 > EOF
54
55 $ hg -q help help 2>&1 |grep extension
56 *** failed to import extension "badext" from $TESTTMP/badext.py: bit bucket overflow
57 *** failed to import extension "badext2": No module named 'badext2'
58
59 show traceback
60
61 $ hg -q help help --traceback 2>&1 | "$PYTHON" "$TESTDIR/filtertraceback.py"
62 *** failed to import extension "badext" from $TESTTMP/badext.py: bit bucket overflow
63 Traceback (most recent call last):
64 Exception: bit bucket overflow
65 *** failed to import extension "badext2": No module named 'badext2'
66 Traceback (most recent call last):
67 ModuleNotFoundError: No module named 'hgext.badext2'
68
69 During handling of the above exception, another exception occurred:
70
71 Traceback (most recent call last):
72 ModuleNotFoundError: No module named 'hgext3rd.badext2'
73
74 During handling of the above exception, another exception occurred:
75
76 Traceback (most recent call last):
77 ModuleNotFoundError: No module named 'badext2'
78 hg help [-eck] [-s PLATFORM] [TOPIC]
79
80 show help for a given topic or a help overview
81
82 names of extensions failed to load can be accessed via extensions.notloaded()
83
84 $ cat <<EOF > showbadexts.py
85 > from mercurial import commands, extensions, registrar
86 > cmdtable = {}
87 > command = registrar.command(cmdtable)
88 > @command(b'showbadexts', norepo=True)
89 > def showbadexts(ui, *pats, **opts):
90 > ui.write(b'BADEXTS: %s\n' % b' '.join(sorted(extensions.notloaded())))
91 > EOF
92 $ hg --config extensions.badexts=showbadexts.py showbadexts 2>&1 | grep '^BADEXTS'
93 BADEXTS: badext badext2
94
95 #if no-extraextensions
96 show traceback for ImportError of hgext.name if devel.debug.extensions is set
97
98 $ (hg help help --traceback --debug --config devel.debug.extensions=yes 2>&1) \
99 > | grep -v '^ ' \
100 > | filterlog \
101 > | "$PYTHON" "$TESTDIR/filtertraceback.py"
102 YYYY/MM/DD HH:MM:SS (PID)> loading extensions
103 YYYY/MM/DD HH:MM:SS (PID)> - processing 5 entries
104 YYYY/MM/DD HH:MM:SS (PID)> - loading extension: gpg
105 YYYY/MM/DD HH:MM:SS (PID)> > gpg extension loaded in * (glob)
106 YYYY/MM/DD HH:MM:SS (PID)> - validating extension tables: gpg
107 YYYY/MM/DD HH:MM:SS (PID)> - invoking registered callbacks: gpg
108 YYYY/MM/DD HH:MM:SS (PID)> > callbacks completed in * (glob)
109 YYYY/MM/DD HH:MM:SS (PID)> - loading extension: badext
110 *** failed to import extension "badext" from $TESTTMP/badext.py: bit bucket overflow
111 Traceback (most recent call last):
112 Exception: bit bucket overflow
113 YYYY/MM/DD HH:MM:SS (PID)> - loading extension: baddocext
114 YYYY/MM/DD HH:MM:SS (PID)> > baddocext extension loaded in * (glob)
115 YYYY/MM/DD HH:MM:SS (PID)> - validating extension tables: baddocext
116 YYYY/MM/DD HH:MM:SS (PID)> - invoking registered callbacks: baddocext
117 YYYY/MM/DD HH:MM:SS (PID)> > callbacks completed in * (glob)
118 YYYY/MM/DD HH:MM:SS (PID)> - loading extension: badext2
119 YYYY/MM/DD HH:MM:SS (PID)> - could not import hgext.badext2 (No module named *badext2*): trying hgext3rd.badext2 (glob)
120 Traceback (most recent call last):
121 ModuleNotFoundError: No module named 'hgext.badext2'
122 YYYY/MM/DD HH:MM:SS (PID)> - could not import hgext3rd.badext2 (No module named *badext2*): trying badext2 (glob)
123 Traceback (most recent call last):
124 ModuleNotFoundError: No module named 'hgext.badext2'
125
126 During handling of the above exception, another exception occurred:
127
128 Traceback (most recent call last):
129 ModuleNotFoundError: No module named 'hgext3rd.badext2'
130 *** failed to import extension "badext2": No module named 'badext2'
131 Traceback (most recent call last):
132 ModuleNotFoundError: No module named 'hgext.badext2'
133
134 During handling of the above exception, another exception occurred:
135
136 Traceback (most recent call last):
137 ModuleNotFoundError: No module named 'hgext3rd.badext2'
138
139 During handling of the above exception, another exception occurred:
140
141 Traceback (most recent call last):
142 ModuleNotFoundError: No module named 'badext2'
143 YYYY/MM/DD HH:MM:SS (PID)> > loaded 2 extensions, total time * (glob)
144 YYYY/MM/DD HH:MM:SS (PID)> - loading configtable attributes
145 YYYY/MM/DD HH:MM:SS (PID)> - executing uisetup hooks
146 YYYY/MM/DD HH:MM:SS (PID)> - running uisetup for gpg
147 YYYY/MM/DD HH:MM:SS (PID)> > uisetup for gpg took * (glob)
148 YYYY/MM/DD HH:MM:SS (PID)> - running uisetup for baddocext
149 YYYY/MM/DD HH:MM:SS (PID)> > uisetup for baddocext took * (glob)
150 YYYY/MM/DD HH:MM:SS (PID)> > all uisetup took * (glob)
151 YYYY/MM/DD HH:MM:SS (PID)> - executing extsetup hooks
152 YYYY/MM/DD HH:MM:SS (PID)> - running extsetup for gpg
153 YYYY/MM/DD HH:MM:SS (PID)> > extsetup for gpg took * (glob)
154 YYYY/MM/DD HH:MM:SS (PID)> - running extsetup for baddocext
155 YYYY/MM/DD HH:MM:SS (PID)> > extsetup for baddocext took * (glob)
156 YYYY/MM/DD HH:MM:SS (PID)> > all extsetup took * (glob)
157 YYYY/MM/DD HH:MM:SS (PID)> - executing remaining aftercallbacks
158 YYYY/MM/DD HH:MM:SS (PID)> > remaining aftercallbacks completed in * (glob)
159 YYYY/MM/DD HH:MM:SS (PID)> - loading extension registration objects
160 YYYY/MM/DD HH:MM:SS (PID)> > extension registration object loading took * (glob)
161 YYYY/MM/DD HH:MM:SS (PID)> > extension baddocext take a total of * to load (glob)
162 YYYY/MM/DD HH:MM:SS (PID)> > extension gpg take a total of * to load (glob)
163 YYYY/MM/DD HH:MM:SS (PID)> extension loading complete
164 hg help [-eck] [-s PLATFORM] [TOPIC]
165
166 show help for a given topic or a help overview
167
168 With no arguments, print a list of commands with short help messages.
169
170 Given a topic, extension, or command name, print help for that topic.
171
172 Returns 0 if successful.
173
174 options ([+] can be repeated):
175
176
177 global options ([+] can be repeated):
178
179 #endif
180
181 confirm that there's no crash when an extension's documentation is bad
182
183 $ hg help --keyword baddocext
184 *** failed to import extension "badext" from $TESTTMP/badext.py: bit bucket overflow
185 *** failed to import extension "badext2": No module named 'badext2'
186 Topics:
187
188 extensions Using Additional Features