Skip to content

Commit 5edbeb1

Browse files
committed
Skip tests that requires git when it’s not available
- also fix name of the class Signed-off-by: Stefan Marr <git@stefan-marr.de>
1 parent f13bd23 commit 5edbeb1

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

rebench/environment.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ def extract_base(branch_or_tag):
4141
return branch_or_tag.replace('HEAD -> ', '')
4242

4343

44+
def git_not_available():
45+
return _exec(['git', '--version']) is None
46+
47+
48+
def git_repo_not_initialized():
49+
return _exec(['git', 'rev-parse']) is None
50+
51+
4452
def determine_source_details(configurator):
4553
global _source # pylint: disable=global-statement
4654
if _source:

rebench/tests/environment_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
from unittest import TestCase
1+
from unittest import TestCase, skipIf
22

33
from ..denoise import DenoiseResult
44
from ..environment import determine_source_details, determine_environment,\
5-
init_environment, extract_base
5+
init_environment, extract_base, git_not_available, git_repo_not_initialized
66
from ..ui import TestDummyUI
77

88

9-
class ReBenchTestCase(TestCase):
9+
class EnvironmentTest(TestCase):
1010

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

rebench/tests/perf/issue_166_profiling_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from unittest import skipIf
12
from ..mock_http_server import MockHTTPServer
23
from ...configurator import Configurator, load_config
4+
from ...environment import git_not_available, git_repo_not_initialized
35
from ...executor import Executor
46
from ...model.profile_data import ProfileData
57
from ...persistence import DataStore
@@ -148,6 +150,8 @@ def test_execute_profiling_profile2(self):
148150
self.assertEqual(7, run_id.completed_invocations)
149151
self.assertEqual(7, run_id.get_number_of_data_points())
150152

153+
@skipIf(git_not_available() or git_repo_not_initialized(),
154+
"git source info not available, but needed for reporting to ReBenchDB")
151155
def test_send_to_rebench_db(self):
152156
server = MockHTTPServer()
153157
port = server.get_free_port()

rebench/tests/persistency_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1818
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1919
# IN THE SOFTWARE.
20+
from unittest import skipIf
2021
from .mock_http_server import MockHTTPServer
2122
from .rebench_test_case import ReBenchTestCase
2223

2324
from ..persistence import DataStore
2425

2526
from ..configurator import Configurator, load_config
27+
from ..environment import git_not_available, git_repo_not_initialized
2628
from ..executor import Executor
2729
from ..model.benchmark import Benchmark
2830
from ..model.benchmark_suite import BenchmarkSuite
@@ -115,6 +117,8 @@ def test_data_discarding(self):
115117

116118
self._assert_runs(cnf2, 1, 10, 10)
117119

120+
@skipIf(git_not_available() or git_repo_not_initialized(),
121+
"git source info not available, but needed for reporting to ReBenchDB")
118122
def test_rebench_db(self):
119123
option_parser = ReBench().shell_options()
120124
cmd_config = option_parser.parse_args(['--experiment=Test', 'persistency.conf'])

0 commit comments

Comments
 (0)