Skip to content

Commit 0d5f039

Browse files
r-barnesmeta-codesync[bot]
authored andcommitted
fbcode_builder: fix dead retry loop in ctest test runner
Summary: The ctest retry loop in BuilderBase test_results_for_retry was calling self._check_cmd(args, allow_fail=True) and capturing its return code, but _check_cmd raises RuntimeError whenever its inner _run_cmd returns non-zero — independently of allow_fail (which is only forwarded to _run_cmd to suppress the lower-level raise). On the first ctest failure the loop therefore raised out before ever reaching the --rerun-failed retry path: the retry was dead code. Switch the call to _run_cmd so a non-zero exit is returned and the retry loop actually runs. This also lets us drop the int|None typing dance (retcode could only ever be None when a never-thrown exception ate the assignment) and the corresponding 'is not None' guard. The FIXME asking what the loop accomplishes is removed: the answer is 'rerun failed tests up to retry times', which is now what it does. Reviewed By: bigfootjon Differential Revision: D103767928 fbshipit-source-id: 466cb4ce598acbb2458fe4327e5d322fe12cffbd
1 parent 1149ac5 commit 0d5f039

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

build/fbcode_builder/getdeps/builder.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,10 +1330,9 @@ def list_tests() -> list[dict[str, object]]:
13301330
args += ["--timeout", str(timeout)]
13311331

13321332
count: int = 0
1333-
retcode: int | None = -1
1333+
retcode: int = -1
13341334
while count <= retry:
1335-
# FIXME: What is this trying to accomplish? Should it fail on first or >=1 errors?
1336-
retcode = self._check_cmd(
1335+
retcode = self._run_cmd(
13371336
args, env=env, use_cmd_prefix=use_cmd_prefix, allow_fail=True
13381337
)
13391338

@@ -1343,7 +1342,7 @@ def list_tests() -> list[dict[str, object]]:
13431342
# Only add this option in the second run.
13441343
args += ["--rerun-failed"]
13451344
count += 1
1346-
if retcode is not None and retcode != 0:
1345+
if retcode != 0:
13471346
# Allow except clause in getdeps.main to catch and exit gracefully
13481347
# This allows non-testpilot runs to fail through the same logic as failed testpilot runs, which may become handy in case if post test processing is needed in the future
13491348
raise subprocess.CalledProcessError(retcode, args)

0 commit comments

Comments
 (0)