1818PTR_RE = re .compile (r"0x[0-9a-fA-F]+" )
1919
2020RE_XFAIL = re .compile (r"//\s*XFAIL:\s*(.*)" )
21+ RE_PANIC_UB = re .compile (r"//\s*panic-ub\s*(?::\s*(.*))?$" , re .MULTILINE )
2122RE_PANIC = re .compile (r"//\s*panic\s*(?::\s*(.*))?$" , re .MULTILINE )
2223RE_NOCOMPILE = re .compile (r"//\s*no-compile\s*(?::\s*(.*))?$" , re .MULTILINE )
2324RE_TRANS_FAIL = re .compile (r"//\s*translation-fail\s*(?::\s*(.*))?$" , re .MULTILINE )
2728@dataclass
2829class TestExpectations :
2930 should_panic : bool = False
31+ should_panic_ub : bool = False
3032 should_not_compile : bool = False
3133 should_not_translate : bool = False
3234 is_nondet_result : bool = False
@@ -47,6 +49,7 @@ def matches(match):
4749 xfail = xfail_m is not None and model in re .split (r"\s*,\s*" , xfail_m .group (1 ))
4850 return cls (
4951 should_panic = matches (RE_PANIC .search (text )),
52+ should_panic_ub = matches (RE_PANIC_UB .search (text )),
5053 should_not_compile = matches (RE_NOCOMPILE .search (text )),
5154 should_not_translate = matches (RE_TRANS_FAIL .search (text )),
5255 is_nondet_result = matches (RE_NONDET .search (text )),
@@ -254,14 +257,22 @@ def run_rust(self):
254257 return None
255258 self .rust_result = RunResult (* lit .util .executeCommand (str (self .rust_bin )))
256259
257- if exp .should_panic :
260+ if exp .should_panic_ub :
258261 err = str (self .rust_result .stderr )
259262 if not re .search (
260263 r"thread 'main' \(\d+\) panicked at" , err
261264 ) or self .rust_result .returncode not in [- 6 , 101 ]:
262265 return (exp .fail_code , "expected panic\n " + err )
263266 return self .success_result ()
264267
268+ if exp .should_panic :
269+ err = str (self .rust_result .stderr )
270+ if not re .search (
271+ r"thread 'main' \(\d+\) panicked at" , err
272+ ) or self .rust_result .returncode not in [- 6 , 101 ]:
273+ return (exp .fail_code , "expected panic\n " + err )
274+ return (lit .Test .XFAIL , "" )
275+
265276 if exp .is_nondet_result :
266277 return self .success_result ()
267278 return None
0 commit comments