@@ -26,6 +26,7 @@ def __init__(self):
2626 self .regex_xfail = re .compile (r"//\s*XFAIL:\s*(.*)" )
2727 self .regex_panic = re .compile (r"//\s*panic\s*(?::\s*(.*))?$" , re .MULTILINE )
2828 self .regex_nocompile = re .compile (r"//\s*no-compile\s*(?::\s*(.*))?$" , re .MULTILINE )
29+ self .regex_translation_fail = re .compile (r"//\s*translation-fail\s*(?::\s*(.*))?$" , re .MULTILINE )
2930 self .regex_nondet_result = re .compile (r"//\s*nondet-result\s*(?::\s*(.*))?$" , re .MULTILINE )
3031 self .rust_version = read_rust_version ()
3132 os .environ ['RUSTFLAGS' ] = '-Awarnings -A dangerous-implicit-autorefs'
@@ -83,6 +84,7 @@ def matches_model(match, model):
8384
8485 should_panic = matches_model (self .regex_panic .search (text ), model )
8586 should_not_compile = matches_model (self .regex_nocompile .search (text ), model )
87+ should_not_translate = matches_model (self .regex_translation_fail .search (text ), model )
8688 is_nondet_result = matches_model (self .regex_nondet_result .search (text ), model )
8789
8890 tmp_dir = "tmp/" + fname + "-" + model + "_" + format (random .getrandbits (64 ), "x" )
@@ -94,10 +96,6 @@ def fail(str, code = fail_code):
9496 shutil .rmtree (tmp_dir , True )
9597 return code , str
9698
97- expected_file = self .getExpectedFile (filepath , model , fname )
98- if not os .path .exists (expected_file ) and not replace_expected :
99- return fail ('no expected file' )
100-
10199 cmd = ['./cpp2rust/cpp2rust' , '-file' , cc_input , '-model' , model ,
102100 '-o' , rs_file ]
103101
@@ -113,8 +111,14 @@ def fail(str, code = fail_code):
113111 generated = f .read ()
114112
115113 if returncode != 0 :
114+ if should_not_translate :
115+ return lit .Test .XFAIL , ''
116116 return fail ('cpp2rust failed\n ' + err )
117117
118+ expected_file = self .getExpectedFile (filepath , model , fname )
119+ if not os .path .exists (expected_file ) and not replace_expected :
120+ return fail ('no expected file' )
121+
118122 if replace_expected :
119123 self .updateExpected (generated , expected_file )
120124
0 commit comments