Skip to content

Commit e5a6b52

Browse files
arthaudmeta-codesync[bot]
authored andcommitted
Show type errors in integration tests when using pyrefly
Summary: Type errors can be the reason for integration test failures, so it's usually better to show them. Also, this enables using `reveal_type(expr)` in tests to get the type of an expression. Reviewed By: yangdanny97 Differential Revision: D108026716 fbshipit-source-id: 3a44341aba781170d23da8cbb9f86930ff1a4764
1 parent b39a89b commit e5a6b52

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

stubs/integration_test/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"--require-pyre-env",
2222
"--check-invariants",
2323
"--skip-model-verification-with-pyrefly",
24-
"--typeshed", "../typeshed/typeshed",
24+
"--typeshed=../typeshed/typeshed",
25+
"--show-type-errors",
2526
]
2627
+ sys.argv[1:],
2728
)

tools/pysa_integration_tests/run.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def main(
4040
ignore_positions: bool,
4141
write_actual_results_on_failure: bool,
4242
use_pyrefly: bool,
43+
show_type_errors: bool,
4344
) -> None:
4445
"""
4546
Entry point function to run a full end-to-end integration test.
@@ -73,6 +74,7 @@ def main(
7374
check_invariants=check_invariants,
7475
use_pyrefly=use_pyrefly,
7576
working_directory=working_directory,
77+
show_type_errors=show_type_errors,
7678
)
7779

7880
test_result_directory = (
@@ -171,6 +173,12 @@ def main(
171173
default=False,
172174
help="Use pyrefly as the type checker, instead of pyre1",
173175
)
176+
parser.add_argument(
177+
"--show-type-errors",
178+
action="store_true",
179+
default=False,
180+
help="Show type errors from Pyrefly",
181+
)
174182

175183
parsed: argparse.Namespace = parser.parse_args()
176184
run_from = test_runner_lib.RunFrom(parsed.run_from)
@@ -193,4 +201,5 @@ def main(
193201
ignore_positions=parsed.ignore_positions,
194202
write_actual_results_on_failure=parsed.write_actual_results_on_failure,
195203
use_pyrefly=parsed.use_pyrefly,
204+
show_type_errors=parsed.show_type_errors,
196205
)

tools/pysa_integration_tests/runner_lib.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ def run_pysa(
229229
error_help: Optional[str] = None,
230230
use_pyrefly: bool = False,
231231
skip_buck_dependencies: bool = False,
232+
show_type_errors: bool = False,
232233
) -> str:
233234
"""Run pysa for the given test and produce a list of errors in JSON."""
234235
if run_from == RunFrom.PYRE_IN_PATH:
@@ -279,6 +280,9 @@ def run_pysa(
279280
if use_pyrefly:
280281
command.append("--use-pyrefly")
281282

283+
if show_type_errors:
284+
command.append("--show-type-errors")
285+
282286
if skip_buck_dependencies:
283287
command.append("--skip-buck-dependencies")
284288

0 commit comments

Comments
 (0)