~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to buildout-templates/bin/test.in

  • Committer: Bjorn Tillenius
  • Date: 2009-09-16 07:09:57 UTC
  • mfrom: (9230.1.6 bug-429375)
  • mto: This revision was merged to the branch mainline in revision 9499.
  • Revision ID: bjorn@canonical.com-20090916070957-r0a7w2zr46pvr22f
MergeĀ lp:~bjornt/launchpad/bug-429375.

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
from zope.testing import testrunner
135
135
from zope.testing.testrunner import options
136
136
 
137
 
defaults = [
 
137
defaults = {
138
138
    # Find tests in the tests and ftests directories
139
 
    '--tests-pattern=^f?tests$',
140
 
    '--test-path=${buildout:directory}/lib',
141
 
    '--package=canonical',
142
 
    '--package=lp',
143
 
    '--package=devscripts',
144
 
    # XXX: Add this back before landing this branch.
145
 
    #'--layer=!(MailmanLayer|WindmillLayer)',
146
 
    ]
 
139
    'tests_pattern': '^f?tests$',
 
140
    'test_path': ['${buildout:directory}/lib'],
 
141
    'package': ['canonical', 'lp', 'devscripts'],
 
142
    'layer': ['!(MailmanLayer|WindmillLayer)'],
 
143
    }
147
144
 
148
145
# Monkey-patch os.listdir to randomise the results
149
146
original_listdir = os.listdir
204
201
    options.parser.add_option(
205
202
        '--subunit', action='callback', callback=use_subunit)
206
203
 
207
 
    local_options = options.get_options(args=args, defaults=defaults)
 
204
    local_options = options.get_options(args=args)
 
205
    # Set our default options, if the options aren't specified.
 
206
    for name, value in defaults.items():
 
207
        parsed_option = getattr(local_options, name)
 
208
        if ((parsed_option == []) or
 
209
            (parsed_option == options.parser.defaults.get(name))):
 
210
            # The option probably wasn't specified on the command line,
 
211
            # let's replace it with our default value. It could be that
 
212
            # the real default (as specified in
 
213
            # zope.testing.testrunner.options) was specified, and we
 
214
            # shouldn't replace it with our default, but it's such and
 
215
            # edge case, so we don't have to care about it.
 
216
            options.parser.defaults[name] = value
208
217
 
209
218
    # Turn on Layer profiling if requested.
210
219
    from canonical.testing import profiled
218
227
    try:
219
228
        there = os.getcwd()
220
229
        os.chdir('${buildout:directory}')
221
 
        result = testrunner.run(defaults)
 
230
        result = testrunner.run([])
222
231
    finally:
223
232
        os.chdir(there)
224
233
    # Cribbed from sourcecode/zope/test.py - avoid spurious error during exit.