mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
Make it possible to run a subset of unit tests from the command line using standard wildcards
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@75820 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
17
build.py
17
build.py
@@ -161,6 +161,11 @@ def main(args):
|
||||
elif 'cmd_'+cmd in globals():
|
||||
function = globals()['cmd_'+cmd]
|
||||
function(options, args)
|
||||
if cmd == 'test':
|
||||
# Any additional cmd-line args are assumed to be tests, which
|
||||
# will have already been taken care of, so bail out of the
|
||||
# loop.
|
||||
break
|
||||
else:
|
||||
print('*** Unknown command: ' + cmd)
|
||||
usage()
|
||||
@@ -954,18 +959,26 @@ def cmd_touch(options, args):
|
||||
cmdTimer = CommandTimer('touch')
|
||||
pwd = pushDir(phoenixDir())
|
||||
runcmd('touch etg/*.py')
|
||||
|
||||
|
||||
|
||||
|
||||
def cmd_test(options, args):
|
||||
cmdTimer = CommandTimer('test')
|
||||
pwd = pushDir(phoenixDir())
|
||||
runcmd('"%s" unittests/runtests.py %s' % (PYTHON, '-v' if options.verbose else ''), fatal=False)
|
||||
cmd = '"%s" unittests/runtests.py %s ' % (PYTHON, '-v' if options.verbose else '')
|
||||
if len(args) > 1:
|
||||
if options.verbose:
|
||||
args.remove('--verbose')
|
||||
cmd += ' '.join(args[1:])
|
||||
runcmd(cmd, fatal=False)
|
||||
|
||||
|
||||
|
||||
def testOne(name, options, args):
|
||||
cmdTimer = CommandTimer('test %s:' % name)
|
||||
pwd = pushDir(phoenixDir())
|
||||
runcmd('"%s" unittests/%s.py %s' % (PYTHON, name, '-v' if options.verbose else ''), fatal=False)
|
||||
|
||||
|
||||
|
||||
def cmd_build(options, args):
|
||||
|
||||
@@ -144,20 +144,21 @@ if __name__ == '__main__':
|
||||
|
||||
else:
|
||||
# The discover option doesn't use my my custom loader or suite
|
||||
# classes, so we'll do the finding of the test files in this case.
|
||||
#names = ['test_gdicmn', 'test_panel', 'test_msgdlg', 'test_uiaction']
|
||||
names = glob.glob(os.path.join('unittests', 'test_*.py'))
|
||||
# classes, so we'll do the finding of the test files in this case. If
|
||||
# there aren't already some in argv then get all of them in unittests
|
||||
# folder.
|
||||
for arg in sys.argv[1:]:
|
||||
if arg.startswith('unittests'):
|
||||
names = sys.argv[1:]
|
||||
sys.argv = sys.argv[:1]
|
||||
break
|
||||
else:
|
||||
names = glob.glob(os.path.join('unittests', 'test_*.py'))
|
||||
|
||||
names = [os.path.splitext(os.path.basename(n))[0] for n in names]
|
||||
args = sys.argv + names
|
||||
|
||||
unittest.main(argv=args, module=None,
|
||||
testRunner=MyTestRunner, testLoader=MyTestLoader())
|
||||
|
||||
|
||||
|
||||
#loader = MyTestLoader()
|
||||
#suite = unittest.TestSuite()
|
||||
#for name in ['test_panel', 'test_msgdlg']:
|
||||
# suite.addTests(loader.loadTestsFromName(name))
|
||||
#runner = MyTestRunner()
|
||||
#runner.run(suite)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user