Skip to content

Commit a729fe0

Browse files
committed
Flush stdout before running subprocesses
Avoids interleaving of output
1 parent 2b97e9d commit a729fe0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Utilities/build-script-helper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def check_call(cmd: List[str], additional_env: Dict[str, str] = {}, verbose: boo
4141
if verbose:
4242
print_cmd(cmd=cmd, additional_env=additional_env)
4343

44+
sys.stdout.flush()
45+
sys.stderr.flush()
4446
subprocess.check_call(cmd, env=env_with_additional_env(additional_env), stderr=subprocess.STDOUT)
4547

4648

@@ -51,6 +53,8 @@ def check_output(cmd: List[str], additional_env: Dict[str, str] = {}, capture_st
5153
stderr = subprocess.STDOUT
5254
else:
5355
stderr = subprocess.DEVNULL
56+
sys.stdout.flush()
57+
sys.stderr.flush()
5458
return subprocess.check_output(cmd, env=env_with_additional_env(additional_env), stderr=stderr, encoding='utf-8')
5559

5660
# -----------------------------------------------------------------------------
@@ -155,7 +159,6 @@ def run_tests(swift_exec: str, args: argparse.Namespace) -> None:
155159
check_call(cmd + ['--parallel'], additional_env=additional_env, verbose=args.verbose)
156160
except:
157161
print('--- Running tests in parallel failed. Re-running tests serially to capture more actionable output.')
158-
sys.stdout.flush()
159162
check_call(cmd, additional_env=additional_env, verbose=args.verbose)
160163
# Return with non-zero exit code even if serial test execution succeeds.
161164
raise SystemExit(1)

0 commit comments

Comments
 (0)