@@ -118,22 +118,23 @@ def fail(str, code = fail_code):
118118 if should_not_translate :
119119 return fail ('expected translation-fail but cpp2rust succeeded' )
120120
121- expected_file = self .getExpectedFile (filepath , model , fname )
122- if not os .path .exists (expected_file ) and not replace_expected :
123- return fail ('no expected file' )
121+ if not should_not_compile :
122+ expected_file = self .getExpectedFile (filepath , model , fname )
123+ if not os .path .exists (expected_file ) and not replace_expected :
124+ return fail ('no expected file' )
124125
125- if replace_expected :
126- self .updateExpected (generated , expected_file )
126+ if replace_expected :
127+ self .updateExpected (generated , expected_file )
127128
128- with open (expected_file , 'r' ) as f :
129- expected = f .read ()
129+ with open (expected_file , 'r' ) as f :
130+ expected = f .read ()
130131
131- if generated != expected :
132- diff = '' .join (difflib .unified_diff (
133- expected .splitlines (keepends = True ),
134- generated .splitlines (keepends = True ),
135- fromfile = 'expected' , tofile = 'generated' ))
136- return fail ('different output\n ' + diff )
132+ if generated != expected :
133+ diff = '' .join (difflib .unified_diff (
134+ expected .splitlines (keepends = True ),
135+ generated .splitlines (keepends = True ),
136+ fromfile = 'expected' , tofile = 'generated' ))
137+ return fail ('different output\n ' + diff )
137138
138139 pkg_name = "test_" + re .sub (r'[^a-zA-Z0-9_]' , '_' , os .path .basename (tmp_dir ))
139140
@@ -163,7 +164,7 @@ def fail(str, code = fail_code):
163164 if should_not_compile :
164165 if returncode != 0 :
165166 shutil .rmtree (tmp_dir , True )
166- return lit .Test .PASS , ''
167+ return lit .Test .XFAIL , ''
167168 return fail ('expected no-compile but compiled successfully' )
168169 if returncode != 0 :
169170 return fail ('cargo failed\n ' + err )
0 commit comments