diff --git a/build.py b/build.py index 70e0f622..a1918255 100755 --- a/build.py +++ b/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): diff --git a/unittests/runtests.py b/unittests/runtests.py index 9009389d..38977528 100755 --- a/unittests/runtests.py +++ b/unittests/runtests.py @@ -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) -