def run_tests(): # Build the arguments for running main() args = {} if FLAGS.no_skip: args["skip"] = lambda dt: False elif FLAGS.skip is not None: if "=" in FLAGS.skip: k, v = FLAGS.skip.split("=", 1) args["skip"] = lambda dt: getattr(dt, k, None) == v else: args["skip"] = lambda dt: hasattr(dt, FLAGS.skip) # Set up maximum number of threads if FLAGS.max_threads is not None: args["maxth"] = FLAGS.max_threads # Are we doing a dry run? if FLAGS.dry_run: args["dryrun"] = True # Are we in debug mode? if FLAGS.debug: args["debug"] = True # Dumping the dependency graph? if FLAGS.dot is not None: args["dotpath"] = FLAGS.dot # Finally, consider the directory if FLAGS.directory is not None: args["directory"] = FLAGS.directory # Run the integration tests return dtest.main(**args)
import sys import dtest import base if __name__ == '__main__': # First, pull in the DTest options opts = dtest.optparser(usage="%prog [options]") # Add on backfire-specific options base.add_opts(opts) # Process command-line arguments (options, args) = opts.parse_args() # Extract the backfire-specific options into storage everything # can get to; also handles some defaults base.extract_opts(options) # Obtain the arguments for dtest.main() kwargs = dtest.opts_to_args(options) # If --stress is given, activate the stress tests if options.stress: kwargs['skip'] = lambda dt: not getattr(dt, 'stress', False) # Run the tests sys.exit(not dtest.main(**kwargs))
help="The username to use to access Keystone.") opts.add_option("-p", "--password", action="store", type="string", dest="password", help="The password to use to access Keystone.") opts.add_option("-k", "--keystone", action="store", type="string", dest="keystone", help="The URL to use to access Keystone.") return opts if __name__ == '__main__': # Obtain the options opts = add_opts(dtest.optparser(usage="%prog [options]")) # Process command-line arguments, saving them so tests can get to # them (base.options, args) = opts.parse_args() # Ensure required options are present if (not base.options.username or not base.options.password or not base.options.keystone): print >>sys.stderr, "Missing required options" print >>sys.stderr, ("At a minimum, --username, --password, and " "--keystone must be specified.") opts.print_help(sys.stderr) sys.exit(1) # Execute the test suite sys.exit(dtest.main(**dtest.opts_to_args(base.options)))