def run(all_tests, all_groups, configure, args): """ The main entry point all_tests: A tree of all the tests all_groups: A dict of named groups configure: a function that takes a list of requirements and returns a configuration args: arguments parsed using argparser """ if args.groups and not args.list: list_groups_mode(all_groups, args.filter, args.verbose) return filter = TestFilter.parse(args.filter, all_groups) if args.load or args.tree or args.examine: old_tests_mode(all_tests, args.load, filter, args.verbose, args.list, args.only_failed, args.tree, args.examine, args.html_report) return tests = all_tests.filter(filter) reqs = tests.requirements() conf = configure(reqs) if args.print_config: for k in conf: print(k, '=', conf[k]) tests = tests.configure(conf) filter.check_use() if args.list: list_tests_mode(tests, args.verbose, args.groups and all_groups) return if not args.dry_run: testrunner = TestRunner(tests, conf, tasks=args.jobs, timeout=args.timeout, output_dir=args.output_dir, run_dir=args.run_dir, verbose=args.verbose, repeat=args.repeat, kontinue=args.kontinue, abort_fast=args.abort_fast) testrunner.run() if args.html_report: test_report.gen_report(testrunner.dir, load_test_results_as_tests(testrunner.dir)) if testrunner.failed(): return 'FAILED'
def old_tests_mode(all_tests, load, filter, verbose, list_tests, only_failed, tree, examine, html_report): if isinstance(load, "".__class__): load_path = load else: all_dirs = [ join(default_test_results_dir, d) for d in os.listdir(default_test_results_dir) ] load_path = max([d for d in all_dirs if os.path.isdir(d)], key=getmtime) print("Loading tests from", load_path) tests = load_test_results_as_tests(load_path).filter(filter) filter.check_use() if only_failed: tests = tests.filter(PredicateFilter(lambda test: not test.passed())) if html_report: test_report.gen_report(load_path, tests) return if list_tests: list_tests_mode(tests, verbose, False) return view = TextView() for name, test in tests: if not test.passed(): status = 'FAILED' elif test.killed(): status = 'KILLED' else: status = 'SUCCESS' if verbose: test.dump_log() view.tell(status, name) if tree: for name in test.list_files(): if tree: print(" " + name) if examine: for glob in examine: for name in test.list_files(glob): print() print('===', name, '===') test.dump_file(name)
def run(all_tests, all_groups, configure, args): """ The main entry point all_tests: A tree of all the tests all_groups: A dict of named groups configure: a function that takes a list of requirements and returns a configuration args: arguments parsed using argparser """ if args.groups and not args.list: list_groups_mode(all_groups, args.filter, args.verbose) return filter = TestFilter.parse(args.filter, all_groups) if args.load or args.tree or args.examine: old_tests_mode(all_tests, args.load, filter, args.verbose, args.list, args.only_failed, args.tree, args.examine, args.html_report) return tests = all_tests.filter(filter) reqs = tests.requirements() conf = configure(reqs) if args.print_config: for k in conf: print(k, '=', conf[k]) tests = tests.configure(conf) filter.check_use() if args.list: list_tests_mode(tests, args.verbose, args.groups and all_groups) return if not args.dry_run: testrunner = TestRunner( tests, conf, tasks=args.jobs, timeout=args.timeout, output_dir=args.output_dir, run_dir=args.run_dir, verbose=args.verbose, repeat=args.repeat, kontinue=args.kontinue, abort_fast=args.abort_fast) testrunner.run() if args.html_report: test_report.gen_report(testrunner.dir, load_test_results_as_tests(testrunner.dir)) if testrunner.failed(): return 'FAILED'
def old_tests_mode(all_tests, load, filter, verbose, list_tests, only_failed, tree, examine, html_report): if isinstance(load, "".__class__): load_path = load else: all_dirs = [join(default_test_results_dir, d) for d in os.listdir(default_test_results_dir)] load_path = max([d for d in all_dirs if os.path.isdir(d)], key=getmtime) print "Loading tests from", load_path tests = load_test_results_as_tests(load_path).filter(filter) filter.check_use() if only_failed: tests = tests.filter(PredicateFilter(lambda test: not test.passed())) if html_report: test_report.gen_report(load_path, tests) return if list_tests: list_tests_mode(tests, verbose) return view = TextView() for name, test in tests: if not test.passed(): status = 'FAILED' elif test.killed(): status = 'KILLED' else: status = 'SUCCESS' if verbose: test.dump_log() view.tell(status, name) if tree: for name in test.list_files(): if tree: print " " + name if examine: for glob in examine: for name in test.list_files(glob): print print '===', name, '===' test.dump_file(name)