Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
Signed-off-by: Cuong Nguyen <[email protected]>
  • Loading branch information
can-anyscale committed Apr 19, 2023
1 parent 567b5e9 commit e6ea463
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 71 deletions.
3 changes: 1 addition & 2 deletions release/ray_release/scripts/ray_bisect.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def main(test_name: str, passing_commit: str, failing_commit: str) -> None:
logger.info(f"Blamed commit found for test {test_name}: {blamed_commit}")


def _bisect(test_name: str, commit_list: List[str]) -> str:
test = _get_test(test_name)
def _bisect(test: Test, commit_list: List[str]) -> str:
while len(commit_list) > 2:
logger.info(
f"Bisecting between {len(commit_list)} commits: "
Expand Down
81 changes: 12 additions & 69 deletions release/ray_release/tests/test_bisect.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
from unittest import mock
from typing import List, Dict
from ray_release.scripts.ray_bisect import _bisect
from ray_release.config import Test


def test_bisect():
test_cases = {
"c3": {
"c0": True,
"c1": True,
"c3": False,
"c4": False,
"c0": "passed",
"c1": "passed",
"c3": "hard_failed",
"c4": "soft_failed",
},
"c1": {
"c0": True,
"c1": False,
"c0": "passed",
"c1": "hard_failed",
},
}

Expand Down Expand Up @@ -43,66 +44,8 @@ def test_bisect():
def _mock_run_test(test_name: str, commit: str) -> bool:
return commit_to_test_result[commit]

with mock.patch(
"ray_release.scripts.ray_bisect._run_test",
side_effect=_mock_run_test,
):
blamed_commit = _bisect("test", list(commit_to_test_result.keys()))
assert blamed_commit == "c3"

def test_bisect():
commit_to_test_result = {
"c0": True,
"c1": True,
"c2": True,
"c3": False,
"c4": False,
}

def _mock_run_test(test_name: str, commit: str) -> bool:
return commit_to_test_result[commit]

with mock.patch(
"ray_release.scripts.ray_bisect._run_test",
side_effect=_mock_run_test,
):
blamed_commit = _bisect("test", list(commit_to_test_result.keys()))
assert blamed_commit == "c3"

def test_bisect():
commit_to_test_result = {
"c0": True,
"c1": True,
"c2": True,
"c3": False,
"c4": False,
}

def _mock_run_test(test_name: str, commit: str) -> bool:
return commit_to_test_result[commit]

with mock.patch(
"ray_release.scripts.ray_bisect._run_test",
side_effect=_mock_run_test,
):
blamed_commit = _bisect("test", list(commit_to_test_result.keys()))
assert blamed_commit == "c3"

def test_bisect():
commit_to_test_result = {
"c0": "passed",
"c1": "passed",
"c2": "passed",
"c3": "hard_failed",
"c4": "soft_failed",
}

def _mock_run_test(test_name: str, commit: List[str]) -> Dict[str, str]:
return commit_to_test_result

with mock.patch(
"ray_release.scripts.ray_bisect._run_test",
side_effect=_mock_run_test,
):
blamed_commit = _bisect({}, list(commit_to_test_result.keys()))
assert blamed_commit == "c3"
with mock.patch(
"ray_release.scripts.ray_bisect._run_test",
side_effect=_mock_run_test,
):
assert _bisect({}, list(input.keys())) == output

0 comments on commit e6ea463

Please sign in to comment.