@@ -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# -----------------------------------------------------------------------------
@@ -150,8 +154,14 @@ def run_tests(swift_exec: str, args: argparse.Namespace) -> None:
150154 print ('Cleaning ' + tests )
151155 shutil .rmtree (tests , ignore_errors = True )
152156
153- cmd = [swift_exec , 'test' , '--parallel' , '--test-product' , 'IndexStoreDBPackageTests' ] + swiftpm_args
154- check_call (cmd , additional_env = additional_env , verbose = args .verbose )
157+ cmd = [swift_exec , 'test' , '--test-product' , 'IndexStoreDBPackageTests' ] + swiftpm_args
158+ try :
159+ check_call (cmd + ['--parallel' ], additional_env = additional_env , verbose = args .verbose )
160+ except :
161+ print ('--- Running tests in parallel failed. Re-running tests serially to capture more actionable output.' )
162+ check_call (cmd , additional_env = additional_env , verbose = args .verbose )
163+ # Return with non-zero exit code even if serial test execution succeeds.
164+ raise SystemExit (1 )
155165
156166
157167def handle_invocation (swift_exec : str , args : argparse .Namespace ) -> None :
0 commit comments