Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reframe/utility/os_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def git_repo_hash(branch='HEAD', short=True, wd=None):
completed = run_command('git rev-parse %s' % branch,
check=True, log=False)

except SpawnedProcessError:
except (SpawnedProcessError, FileNotFoundError):
return None

hash = completed.stdout.strip()
Expand Down
6 changes: 5 additions & 1 deletion unittests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,17 @@ def test_is_url():
assert not os_ext.is_url(repo_ssh)


def test_git_repo_hash():
def test_git_repo_hash(monkeypatch):
# A git branch hash consists of 8(short) or 40 characters.
assert len(os_ext.git_repo_hash()) == 8
assert len(os_ext.git_repo_hash(short=False)) == 40
assert os_ext.git_repo_hash(branch='invalid') is None
assert os_ext.git_repo_hash(branch='') is None

# Imitate a system with no git installed by emptying the PATH
monkeypatch.setenv('PATH', '')
assert os_ext.git_repo_hash() is None


def test_git_repo_exists():
assert os_ext.git_repo_exists('https://github.com/eth-cscs/reframe.git',
Expand Down