150
150
logfile = open(LOGFILENAME, 'wt', buffering=1)
153
"""Run a test involving creating a plugin to load,
154
and making sure it is seen properly.
156
orig_help = backtick('bzr help commands') # No plugins yet
158
f = open(os.path.join('plugin_test', 'myplug.py'), 'wb')
159
f.write("""import bzrlib, bzrlib.commands
160
class cmd_myplug(bzrlib.commands.Command):
161
'''Just a simple test plugin.'''
164
print 'Hello from my plugin'
168
os.environ['BZRPLUGINPATH'] = os.path.abspath('plugin_test')
169
help = backtick('bzr help commands')
170
assert help.find('myplug') != -1
171
assert help.find('Just a simple test plugin.') != -1
174
assert backtick('bzr myplug') == 'Hello from my plugin\n'
175
assert backtick('bzr mplg') == 'Hello from my plugin\n'
177
f = open(os.path.join('plugin_test', 'override.py'), 'wb')
178
f.write("""import bzrlib, bzrlib.commands
179
class cmd_commit(bzrlib.commands.cmd_commit):
180
'''Commit changes into a new revision.'''
181
def run(self, *args, **kwargs):
182
print "I'm sorry dave, you can't do that"
184
class cmd_help(bzrlib.commands.cmd_help):
185
'''Show help on a command or other topic.'''
186
def run(self, *args, **kwargs):
187
print "You have been overridden"
188
bzrlib.commands.cmd_help.run(self, *args, **kwargs)
193
newhelp = backtick('bzr help commands')
194
assert newhelp.startswith('You have been overridden\n')
195
# We added a line, but the rest should work
196
assert newhelp[25:] == help
198
assert backtick('bzr commit -m test') == "I'm sorry dave, you can't do that\n"
200
shutil.rmtree('plugin_test')
203
153
from getopt import getopt
204
154
opts, args = getopt(sys.argv[1:], 'p:')
240
190
progress("internal tests")
241
191
runcmd("bzr selftest")
243
progress("user identity")
244
# this should always identify something, if only "john@localhost"
246
runcmd("bzr whoami --email")
247
assert backtick("bzr whoami --email").count('@') == 1
249
193
progress("invalid commands")
250
194
runcmd("bzr pants", retcode=1)
251
195
runcmd("bzr --pants off", retcode=1)