(self, testcase: DataDrivenTestCase)
| 47 | self.type_str_conv = TypeStrVisitor(self.id_mapper, options=Options()) |
| 48 | |
| 49 | def run_case(self, testcase: DataDrivenTestCase) -> None: |
| 50 | name = testcase.name |
| 51 | # We use the test case name to decide which data structures to dump. |
| 52 | # Dumping everything would result in very verbose test cases. |
| 53 | if name.endswith("_symtable"): |
| 54 | kind = SYMTABLE |
| 55 | elif name.endswith("_typeinfo"): |
| 56 | kind = TYPEINFO |
| 57 | elif name.endswith("_types"): |
| 58 | kind = TYPES |
| 59 | else: |
| 60 | kind = AST |
| 61 | |
| 62 | main_src = "\n".join(testcase.input) |
| 63 | result = self.build(main_src, testcase) |
| 64 | assert result is not None, "cases where CompileError occurred should not be run" |
| 65 | result.manager.fscache.flush() |
| 66 | fine_grained_manager = FineGrainedBuildManager(result) |
| 67 | |
| 68 | a = [] |
| 69 | if result.errors: |
| 70 | a.extend(result.errors) |
| 71 | |
| 72 | target_path = os.path.join(test_temp_dir, "target.py") |
| 73 | shutil.copy(os.path.join(test_temp_dir, "target.py.next"), target_path) |
| 74 | |
| 75 | a.extend(self.dump(fine_grained_manager, kind, testcase.test_modules)) |
| 76 | old_subexpr = get_subexpressions(result.manager.modules["target"]) |
| 77 | |
| 78 | a.append("==>") |
| 79 | |
| 80 | new_file, new_types = self.build_increment(fine_grained_manager, "target", target_path) |
| 81 | a.extend(self.dump(fine_grained_manager, kind, testcase.test_modules)) |
| 82 | |
| 83 | for expr in old_subexpr: |
| 84 | if isinstance(expr, TypeVarExpr): |
| 85 | # These are merged so we can't perform the check. |
| 86 | continue |
| 87 | # Verify that old AST nodes are removed from the expression type map. |
| 88 | assert expr not in new_types |
| 89 | |
| 90 | if testcase.normalize_output: |
| 91 | a = normalize_error_messages(a) |
| 92 | |
| 93 | assert_string_arrays_equal( |
| 94 | testcase.output, a, f"Invalid output ({testcase.file}, line {testcase.line})" |
| 95 | ) |
| 96 | |
| 97 | def build(self, source: str, testcase: DataDrivenTestCase) -> BuildResult | None: |
| 98 | options = parse_options(source, testcase, incremental_step=1) |
nothing calls this directly
no test coverage detected