()
| 619 | |
| 620 | |
| 621 | def main(): |
| 622 | global M, P, FIXTURE_DIR |
| 623 | arguments = argparse.ArgumentParser(description=__doc__) |
| 624 | default_module = Path(__file__).resolve().parents[1] / "scripts/test-impact/profile_map_v2.py" |
| 625 | arguments.add_argument("--module", type=Path, default=default_module) |
| 626 | arguments.add_argument("--parser", type=Path, |
| 627 | help="real unchanged parser; default profile_text_parser.py beside --module") |
| 628 | arguments.add_argument("--fixtures", type=Path, default=FIXTURE_DIR, |
| 629 | help="shared golden directory; default fixtures/profile_map_v2 beside this test") |
| 630 | selected = arguments.parse_args() |
| 631 | FIXTURE_DIR = selected.fixtures.resolve() |
| 632 | module_path = selected.module.resolve() |
| 633 | parser_path = (selected.parser or module_path.with_name("profile_text_parser.py")).resolve() |
| 634 | if not module_path.is_file() or not parser_path.is_file(): |
| 635 | arguments.error("--module and --parser must name existing source files") |
| 636 | sys.dont_write_bytecode = True |
| 637 | # Freeze the actual dependency before importing the chosen producer; both |
| 638 | # baseline and implementation use this real parser, never a fake grammar. |
| 639 | P = load_module("profile_text_parser", parser_path) |
| 640 | M = load_module("profile_map_v2_under_test", module_path) |
| 641 | suite = unittest.TestSuite((unittest.defaultTestLoader.loadTestsFromTestCase(DependencyControl), |
| 642 | unittest.defaultTestLoader.loadTestsFromTestCase(ProfileMapV2Tests))) |
| 643 | return 0 if unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful() else 1 |
| 644 | |
| 645 | |
| 646 | if __name__ == "__main__": |
no test coverage detected