Skip to content

Commit

Permalink
* Added support for SingleRevision for only_valid_in parameter of Rev…
Browse files Browse the repository at this point in the history
…isionBinaryMap
  • Loading branch information
Lukas Abelt committed Sep 15, 2023
1 parent 04bfd56 commit 29a14a9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 12 additions & 1 deletion tests/utils/test_git_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest
from pathlib import Path

from benchbuild.utils.revision_ranges import RevisionRange
from benchbuild.utils.revision_ranges import RevisionRange, SingleRevision

from varats.project.project_util import (
get_local_project_git,
Expand Down Expand Up @@ -568,6 +568,17 @@ def test_specification_validity_range_multiple_binaries(self) -> None:
self.assertIn("SingleLocalMultipleRegions", self.rv_map)
self.assertIn("SingleLocalSimple", self.rv_map)

def test_specification_single_revision(self) -> None:
"""Check if we can add binaries that are only valid with a single
revision."""
self.rv_map.specify_binary(
"build/bin/SingleLocalMultipleRegions",
BinaryType.EXECUTABLE,
only_valid_in=SingleRevision("162db88346")
)

self.assertIn("SingleLocalMultipleRegions", self.rv_map)

def test_specification_binaries_with_special_name(self) -> None:
"""Check if we can add binaries that have a special name."""
self.rv_map.specify_binary(
Expand Down
10 changes: 5 additions & 5 deletions varats-core/varats/utils/git_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,9 @@ def specify_binary(
override_entry_point = kwargs.get("override_entry_point", None)
if override_entry_point:
override_entry_point = Path(override_entry_point)
validity_range = kwargs.get("only_valid_in", None)
validity_range: AbstractRevisionRange = kwargs.get(
"only_valid_in", None
)
valid_exit_codes = kwargs.get("valid_exit_codes", None)

wrapped_binary = ProjectBinaryWrapper(
Expand All @@ -1072,6 +1074,7 @@ def specify_binary(
)

if validity_range:
validity_range.init_cache(self.__repo_location)
self.__revision_specific_mappings[validity_range].append(
wrapped_binary
)
Expand All @@ -1087,10 +1090,7 @@ def __getitem__(self,

for validity_range, wrapped_binaries \
in self.__revision_specific_mappings.items():
if revision in get_all_revisions_between(
validity_range.id_start, validity_range.id_end, ShortCommitHash,
self.__repo_location
):
if revision in map(ShortCommitHash, validity_range):
revision_specific_binaries.extend(wrapped_binaries)

revision_specific_binaries.extend(self.__always_valid_mappings)
Expand Down

0 comments on commit 29a14a9

Please sign in to comment.