Skip to content

Commit

Permalink
Skip test that requires git when it’s not available
Browse files Browse the repository at this point in the history
- also fix name of the class

Signed-off-by: Stefan Marr <git@stefan-marr.de>
  • Loading branch information
smarr committed Feb 12, 2023
1 parent f13bd23 commit 4ce96dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 8 additions & 0 deletions rebench/environment.py
Expand Up @@ -41,6 +41,14 @@ def extract_base(branch_or_tag):
return branch_or_tag.replace('HEAD -> ', '')


def git_not_available():
return _exec(['git', '--version']) is None


def git_repo_not_initialized():
return _exec(['git', 'rev-parse']) is None


def determine_source_details(configurator):
global _source # pylint: disable=global-statement
if _source:
Expand Down
8 changes: 5 additions & 3 deletions rebench/tests/environment_test.py
@@ -1,13 +1,15 @@
from unittest import TestCase
from unittest import TestCase, skipIf

from ..denoise import DenoiseResult
from ..environment import determine_source_details, determine_environment,\
init_environment, extract_base
init_environment, extract_base, git_not_available, git_repo_not_initialized
from ..ui import TestDummyUI


class ReBenchTestCase(TestCase):
class EnvironmentTest(TestCase):

@skipIf(git_not_available() or git_repo_not_initialized(),
"git seems not to be installed, or on the path, or the .git dir is missing")
def test_source_details(self):
details = determine_source_details(None)
self.assertEqual(len(details['commitId']), 40)
Expand Down

0 comments on commit 4ce96dd

Please sign in to comment.