Skip to content

Commit 74a5bf9

Browse files
projectgusdpgeorge
authored andcommitted
tools/gen-cpydiff.py: Fail CPython diff generation if output matches.
Previously this information was recorded in a "status" field of the result, but nothing ever parsed this result which led to non-differences not being removed. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
1 parent e9a80fc commit 74a5bf9

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

tools/gen-cpydiff.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"code",
7070
"output_cpy",
7171
"output_upy",
72-
"status",
7372
],
7473
)
7574

@@ -98,7 +97,7 @@ def readfiles():
9897
if not re.match(r"\s*# fmt: (on|off)\s*", x)
9998
)
10099

101-
output = Output(test, class_, desc, cause, workaround, code, "", "", "")
100+
output = Output(test, class_, desc, cause, workaround, code, "", "")
102101
files.append(output)
103102
except IndexError:
104103
print("Incorrect format in file " + test_fullpath)
@@ -108,6 +107,7 @@ def readfiles():
108107

109108
def run_tests(tests):
110109
"""executes all tests"""
110+
same_results = False
111111
results = []
112112
for test in tests:
113113
test_fullpath = os.path.join(TESTPATH, test.name)
@@ -133,23 +133,26 @@ def run_tests(tests):
133133
output_upy = [com.decode("utf8") for com in process.communicate(input_py)]
134134

135135
if output_cpy[0] == output_upy[0] and output_cpy[1] == output_upy[1]:
136-
status = "Supported"
137-
print("Supported operation!\nFile: " + test_fullpath)
136+
print("Error: Test has same output in CPython vs MicroPython: " + test_fullpath)
137+
same_results = True
138138
else:
139-
status = "Unsupported"
140-
141-
output = Output(
142-
test.name,
143-
test.class_,
144-
test.desc,
145-
test.cause,
146-
test.workaround,
147-
test.code,
148-
output_cpy,
149-
output_upy,
150-
status,
139+
output = Output(
140+
test.name,
141+
test.class_,
142+
test.desc,
143+
test.cause,
144+
test.workaround,
145+
test.code,
146+
output_cpy,
147+
output_upy,
148+
)
149+
results.append(output)
150+
151+
if same_results:
152+
raise SystemExit(
153+
"Failing due to non-differences in results. If MicroPython behaviour has changed "
154+
"to match CPython, please remove the file(s) mentioned above."
151155
)
152-
results.append(output)
153156

154157
results.sort(key=lambda x: x.class_)
155158
return results

0 commit comments

Comments
 (0)