146
146
logfile = open(LOGFILENAME, 'wt', buffering=1)
149
"""Run a test involving creating a plugin to load,
150
and making sure it is seen properly.
153
f = open(os.path.join('plugin_test', 'myplug.py'), 'wb')
154
f.write("""import bzrlib, bzrlib.commands
155
class cmd_myplug(bzrlib.commands.Command):
156
'''Just a simple test plugin.'''
159
print 'Hello from my plugin'
163
os.environ['BZRPLUGINPATH'] = os.path.abspath('plugin_test')
164
help = backtick('bzr help commands')
165
assert help.find('myplug') != -1
166
assert help.find('Just a simple test plugin.') != -1
169
assert backtick('bzr myplug') == 'Hello from my plugin\n'
170
assert backtick('bzr mplg') == 'Hello from my plugin\n'
172
f = open(os.path.join('plugin_test', 'override.py'), 'wb')
173
f.write("""import bzrlib, bzrlib.commands
174
class cmd_commit(bzrlib.commands.cmd_commit):
175
'''Commit changes into a new revision.'''
176
def run(self, *args, **kwargs):
177
print "I'm sorry dave, you can't do that"
179
class cmd_help(bzrlib.commands.cmd_help):
180
'''Show help on a command or other topic.'''
181
def run(self, *args, **kwargs):
182
print "You have been overridden"
183
bzrlib.commands.cmd_help.run(self, *args, **kwargs)
188
newhelp = backtick('bzr help commands')
189
assert newhelp.startswith('You have been overridden\n')
190
# We added a line, but the rest should work
191
assert newhelp[25:] == help
193
assert backtick('bzr commit -m test') == "I'm sorry dave, you can't do that\n"
195
shutil.rmtree('plugin_test')
150
198
from getopt import getopt
507
# Run any function in this
512
if k.startswith('test_') and callable(g[k]):
513
progress(k[5:].replace('_', ' '))
459
516
progress("all tests passed!")
460
517
except Exception, e:
461
518
sys.stderr.write('*' * 50 + '\n'