@@ -45,23 +45,21 @@ def create_script(target_test):
4545)
4646print(result.stdout)
4747
48- if f"PASSED { target_test } " in result.stdout:
49- print("test passed ")
50- exit(0 )
51- elif len( result.stderr) > 0:
48+ if f"FAILED { target_test } " in result.stdout:
49+ print("test failed ")
50+ exit(2 )
51+ elif result.returncode != 0:
5252 if "ERROR: file or directory not found: " in result.stderr:
5353 print("test file or directory not found in this commit")
5454 exit(0)
5555 elif "ERROR: not found: " in result.stderr:
5656 print("test not found in this commit")
5757 exit(0)
5858 else:
59- print(f"pytest failed to run : {{result.stderr}}")
59+ print(f"pytest gets unknown error : {{result.stderr}}")
6060 exit(-1)
61- elif f"FAILED { target_test } " in result.stdout:
62- print("test failed")
63- exit(2)
6461
62+ print(f"pytest runs successfully.")
6563exit(0)
6664"""
6765
@@ -103,22 +101,11 @@ def find_bad_commit(target_test, start_commit, end_commit):
103101 )
104102 print (result .stdout )
105103
104+ # This happens if running the script gives exit code < 0 or other issues
106105 if "error: bisect run failed" in result .stderr :
107- index = result .stderr .find ("error: bisect run failed" )
108- bash_error = result .stderr [index :]
109-
110- error_msg = f"Error when running git bisect:\n bash error: { bash_error } "
111-
112- pattern = "pytest failed to run: .+"
113- pytest_errors = re .findall (pattern , result .stdout )
114- if len (pytest_errors ) > 0 :
115- pytest_error = pytest_errors [0 ]
116- index = pytest_error .find ("pytest failed to run: " )
117- index += len ("pytest failed to run: " )
118- pytest_error = pytest_error [index :]
119- error_msg += f"pytest error: { pytest_error } "
120-
121- raise ValueError (error_msg )
106+ error_msg = f"Error when running git bisect:\n bash error: { result .stderr } \n bash output:\n { result .stdout } \n set `bad_commit` to `None`."
107+ print (error_msg )
108+ return None
122109
123110 pattern = r"(.+) is the first bad commit"
124111 commits = re .findall (pattern , result .stdout )
@@ -135,6 +122,9 @@ def find_bad_commit(target_test, start_commit, end_commit):
135122
136123def get_commit_info (commit ):
137124 """Get information for a commit via `api.github.com`."""
125+ if commit is None :
126+ return {"commit" : None , "pr_number" : None , "author" : None , "merged_by" : None }
127+
138128 pr_number = None
139129 author = None
140130 merged_author = None
0 commit comments