Skip to content

Commit a1ddc4c

Browse files
committed
Don't check generated != expected in no-compile mode
1 parent c5797fa commit a1ddc4c

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

tests/lit/lit/formats/Cpp2RustTest.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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')
124-
125-
if replace_expected:
126-
self.updateExpected(generated, expected_file)
127-
128-
with open(expected_file, 'r') as f:
129-
expected = f.read()
130-
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)
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')
125+
126+
if replace_expected:
127+
self.updateExpected(generated, expected_file)
128+
129+
with open(expected_file, 'r') as f:
130+
expected = f.read()
131+
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

0 commit comments

Comments
 (0)