Collect a list of all tests found in root_dir that are matching the filter_regex and tags. A test script needs to be named test_*.py to be detected.
(root_dir, filter_regex, tags)
| 529 | print(f' {test.name}') |
| 530 | |
| 531 | def collect_tests(root_dir, filter_regex, tags)->list[Test]: |
| 532 | ''' |
| 533 | Collect a list of all tests found in root_dir that are matching the filter_regex and tags. |
| 534 | A test script needs to be named test_*.py to be detected. |
| 535 | ''' |
| 536 | # Find all script files. |
| 537 | script_files = list(root_dir.glob('**/test_*.py')) |
| 538 | |
| 539 | # Create tests. |
| 540 | tests = [] |
| 541 | for script_file in script_files: |
| 542 | try: |
| 543 | header = read_header(script_file) |
| 544 | except Exception as e: |
| 545 | print(e) |
| 546 | sys.exit(1) |
| 547 | |
| 548 | # Check if test is enabled for current platform. |
| 549 | platforms = header.get("platforms", config.DEFAULT_PLATFORMS) |
| 550 | if not config.PLATFORM in platforms: |
| 551 | continue |
| 552 | |
| 553 | # For now we default to d3d12 as we bring in image tests on vulkan. |
| 554 | # We should later switch this default to ["d3d12", "vulkan"]. |
| 555 | device_types = header.get("device_types", ["d3d12"]) |
| 556 | device_types = [d for d in device_types if d in config.SUPPORTED_DEVICE_TYPES] |
| 557 | for device_type in device_types: |
| 558 | tests.append(Test(script_file, root_dir, device_type, header)) |
| 559 | |
| 560 | # Filter using regex. |
| 561 | if filter_regex != '': |
| 562 | regex = re.compile(filter_regex or '') |
| 563 | tests = list(filter(lambda t: regex.search(t.name) != None, tests)) |
| 564 | |
| 565 | # Filter using tags. |
| 566 | tags = tags.split(',') |
| 567 | tests = list(filter(lambda t: t.matches_tags(tags), tests)) |
| 568 | tests = sorted(tests, key=lambda t: t.name) |
| 569 | |
| 570 | return tests |
| 571 | |
| 572 | def push_refs(ref_dir, remote_ref_dir): |
| 573 | ''' |
no test coverage detected