diff options
| author | Stan Lo <stan.lo@shopify.com> | 2025-08-06 01:00:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-05 17:00:04 -0700 |
| commit | 9c0ebff2cded1b60d5d7c922d7cf8dbaa54ecfe2 (patch) | |
| tree | b6ef623b11c14d7934382eca338cb7fe82e7e0a4 | |
| parent | 4d26ccd2afaf33a813464d1abe4cf518950b2f2e (diff) | |
ZJIT: Avoid matching built-in iseq's HIR line numbers in tests (#14124)
ZJIT: Avoid matching built-in ISEQs' HIR line numbers in tests
Co-authored-by: Author: Takashi Kokubun <takashi.kokubun@shopify.com>
| -rw-r--r-- | zjit/src/hir.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs index 203be0661e..635120eb80 100644 --- a/zjit/src/hir.rs +++ b/zjit/src/hir.rs @@ -2242,6 +2242,12 @@ impl<'a> std::fmt::Display for FunctionPrinter<'a> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { let fun = &self.fun; let iseq_name = iseq_get_location(fun.iseq, 0); + // In tests, strip the line number for builtin ISEQs to make tests stable across line changes + let iseq_name = if cfg!(test) && iseq_name.contains("@<internal:") { + iseq_name[..iseq_name.rfind(':').unwrap()].to_string() + } else { + iseq_name + }; writeln!(f, "fn {iseq_name}:")?; for block_id in fun.rpo() { write!(f, "{block_id}(")?; @@ -5003,7 +5009,7 @@ mod tests { #[test] fn test_invokebuiltin_delegate_annotated() { assert_method_hir_with_opcode("Float", YARVINSN_opt_invokebuiltin_delegate_leave, expect![[r#" - fn Float@<internal:kernel>:197: + fn Float@<internal:kernel>: bb0(v0:BasicObject, v1:BasicObject, v2:BasicObject, v3:BasicObject): v6:Flonum = InvokeBuiltin rb_f_float, v0, v1, v2 Jump bb1(v0, v1, v2, v3, v6) @@ -5015,7 +5021,7 @@ mod tests { #[test] fn test_invokebuiltin_cexpr_annotated() { assert_method_hir_with_opcode("class", YARVINSN_opt_invokebuiltin_delegate_leave, expect