Belle II Software development
test_validationfunctions.py
1#!/usr/bin/env python3
2
3
10
11import unittest
12import os
13import validationfunctions
14import tempfile
15
16call_iteration = 0
17
18
19class ValidationFunctionstTest(unittest.TestCase):
20
21 """
22 Various test cases for the validation utility functions
23 """
24
25 def test_git_hash(self):
26 """
27 Test if the extraction of the git hash works and if not, if the
28 functions returns the expected result
29 """
30
31 # fixme: disabled for now
32 # test disabled for now, until a way to run this properly on the
33 # build bot can be found
34 return
35 # noinspection PyUnreachableCode
36
37 cwd = os.getcwd()
38
39 with tempfile.TemporaryDirectory() as td:
40 # switch to this folder
41 os.chdir(str(td))
43 self.assertTrue(ret is None)
44
45 os.chdir(cwd)
46
47 # in the source folder, we should get a sensible output
48 local_dir = os.environ.get("BELLE2_LOCAL_DIR", None)
49 if local_dir:
51 self.assertTrue(ret is not None)
52 print(f"This source code has git hash {ret}")
53
54
55if __name__ == "__main__":
56 unittest.main()
Optional[str] get_compact_git_hash(str repo_folder)