def main(context, dry_run, log_level, target, target_glob, target_skip_glob, no_log_timestamps, root, internal_inside_unshare, chip_tool): # Ensures somewhat pretty logging of what is going on log_fmt = '%(asctime)s.%(msecs)03d %(levelname)-7s %(message)s' if no_log_timestamps: log_fmt = '%(levelname)-7s %(message)s' coloredlogs.install(level=__LOG_LEVELS__[log_level], fmt=log_fmt) if chip_tool is None: chip_tool = FindBinaryPath('chip-tool') # Figures out selected test that match the given name(s) all_tests = [test for test in chiptest.AllTests(chip_tool)] # Default to only non-manual tests unless explicit targets are specified. tests = list(filter(lambda test: not test.is_manual, all_tests)) if 'all' not in target: tests = [] for name in target: targeted = [ test for test in all_tests if test.name.lower() == name.lower() ] if len(targeted) == 0: logging.error("Unknown target: %s" % name) tests.extend(targeted) if target_glob: matcher = GlobMatcher(target_glob.lower()) # Globs ignore manual tests, because it's too easy to mess up otherwise. tests = [test for test in tests if matcher.matches(test.name.lower())] if len(tests) == 0: logging.error("No targets match, exiting.") logging.error("Valid targets are (case-insensitive): %s" % (", ".join(test.name for test in all_tests))) exit(1) if target_skip_glob: matcher = GlobMatcher(target_skip_glob.lower()) tests = [ test for test in tests if not matcher.matches(test.name.lower()) ] tests.sort(key=lambda x: x.name) context.obj = RunContext(root=root, tests=tests, in_unshare=internal_inside_unshare, chip_tool=chip_tool, dry_run=dry_run)
def main(context, log_level, target, target_glob, target_skip_glob, no_log_timestamps, root, internal_inside_unshare, chip_tool): # Ensures somewhat pretty logging of what is going on log_fmt = '%(asctime)s.%(msecs)03d %(levelname)-7s %(message)s' if no_log_timestamps: log_fmt = '%(levelname)-7s %(message)s' coloredlogs.install(level=__LOG_LEVELS__[log_level], fmt=log_fmt) # Figures out selected test that match the given name(s) all_tests = [test for test in chiptest.AllTests(chip_tool)] tests = all_tests if 'all' not in target: tests = [] for name in target: targeted = [ test for test in all_tests if test.name.lower() == name.lower() ] if len(targeted) == 0: logging.error("Unknown target: %s" % name) tests.extend(targeted) if target_glob: matcher = GlobMatcher(target_glob.lower()) tests = [test for test in tests if matcher.matches(test.name.lower())] if len(tests) == 0: logging.error("No targets match, exiting.") logging.error("Valid targets are (case-insensitive): %s" % (", ".join(test.name for test in all_tests))) exit(1) if target_skip_glob: matcher = GlobMatcher(target_skip_glob.lower()) tests = [ test for test in tests if not matcher.matches(test.name.lower()) ] tests.sort(key=lambda x: x.name) context.obj = RunContext(root=root, tests=tests, in_unshare=internal_inside_unshare, chip_tool=chip_tool)