Skip to content

Commit

Permalink
Merge branch 'vara-dev' into f-PatchHyteg
Browse files Browse the repository at this point in the history
  • Loading branch information
vulder authored Nov 27, 2023
2 parents 34ede35 + 0623e92 commit be78cf5
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Patch with a regression severity
path: bug.patch
project_name: FeaturePerfCSCollection
shortname: regression-severity
regression_severity: 1000
39 changes: 31 additions & 8 deletions tests/provider/test_patch_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
FeaturePerfCSCollection,
)
from varats.provider.patch.patch_provider import PatchProvider, Patch, PatchSet
from varats.utils.git_util import ShortCommitHash
from varats.utils.git_util import (
ShortCommitHash,
get_all_revisions_between,
get_initial_commit,
)


class TestPatchProvider(unittest.TestCase):
Expand All @@ -35,6 +39,25 @@ def test_get_patch_by_shortname(self):
patch = provider.get_by_shortname("dummy-patch")
self.assertIsNone(patch)

def test_parse_regression_severity(self):
regression_patch = Patch.from_yaml(
Path(
TEST_INPUTS_DIR /
'patch_configs/FeaturePerfCSCollection/regression-severity.info'
)
)

other_patch = Patch.from_yaml(
Path(
TEST_INPUTS_DIR /
'patch_configs/FeaturePerfCSCollection/unrestricted-range.info'
)
)

self.assertIsNotNone(regression_patch.regression_severity)
self.assertEqual(1000, regression_patch.regression_severity)
self.assertIsNone(other_patch.regression_severity)


class TestPatchRevisionRanges(unittest.TestCase):

Expand All @@ -53,14 +76,14 @@ def setUpClass(cls) -> None:

project_git_source.fetch()

repo_git = _get_git_for_path(
target_prefix() + "/FeaturePerfCSCollection"
)
repo_git_path = Path(target_prefix() + "/FeaturePerfCSCollection")

cls.all_revisions = {
ShortCommitHash(h) for h in
repo_git('log', '--pretty=%H', '--first-parent').strip().split()
}
cls.all_revisions = set(
get_all_revisions_between(
get_initial_commit(repo_git_path).hash, "", ShortCommitHash,
repo_git_path
)
)

def __test_patch_revisions(
self, shortname: str, expected_revisions: set[ShortCommitHash]
Expand Down
23 changes: 21 additions & 2 deletions varats-core/varats/provider/patch/patch_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,20 @@ def __init__(
path: Path,
valid_revisions: tp.Optional[tp.Set[CommitHash]] = None,
tags: tp.Optional[tp.Set[str]] = None,
feature_tags: tp.Optional[tp.Set[str]] = None
feature_tags: tp.Optional[tp.Set[str]] = None,
regression_severity: tp.Optional[int] = None
):
"""
Args:
project_name: Project name that this patch belongs to
shortname: Short name to uniquely identify a patch
description: Textual description of the patch
path: Path to the patch file
valid_revisions: List of revisions that the patch is applicable to
tags: Tags of the patch
feature_tags: Feature specific tags of a patch (Used for PatchConfiguration)
regression_severity: Regression severity in milliseconds (If applicable)
"""
self.project_name: str = project_name
self.shortname: str = shortname
self.description: str = description
Expand All @@ -49,6 +61,7 @@ def __init__(
CommitHash] = valid_revisions if valid_revisions else set()
self.tags: tp.Optional[tp.Set[str]] = tags
self.feature_tags: tp.Optional[tp.Set[str]] = feature_tags
self.regression_severity: tp.Optional[int] = regression_severity

@staticmethod
def from_yaml(yaml_path: Path) -> 'Patch':
Expand Down Expand Up @@ -119,9 +132,15 @@ def parse_revisions(
parse_revisions(yaml_dict["exclude_revisions"])
)

regression_severity: tp.Optional[int]
if "regression_severity" in yaml_dict:
regression_severity = yaml_dict["regression_severity"]
else:
regression_severity = None

return Patch(
project_name, shortname, description, path, include_revisions, tags,
feature_tags
feature_tags, regression_severity
)

def __repr__(self) -> str:
Expand Down

0 comments on commit be78cf5

Please sign in to comment.