|
35 | 35 | import sys |
36 | 36 | import tempfile |
37 | 37 | from inspect import cleandoc |
| 38 | +from test.framework.github import requires_github_access |
38 | 39 | from test.framework.utilities import EnhancedTestCase, TestLoaderFiltered, init_config |
39 | 40 | from unittest import TextTestRunner |
40 | 41 |
|
@@ -1618,6 +1619,40 @@ def test_fetch_sources(self): |
1618 | 1619 | error_pattern = "Found one or more unexpected keys in 'sources' specification: {'nosuchkey': 'foobar'}" |
1619 | 1620 | self.assertErrorRegex(EasyBuildError, error_pattern, eb.fetch_sources, sources, checksums=[]) |
1620 | 1621 |
|
| 1622 | + @requires_github_access() |
| 1623 | + def test_fetch_sources_git(self): |
| 1624 | + """Test fetch_sources method from git repo.""" |
| 1625 | + testdir = os.path.abspath(os.path.dirname(__file__)) |
| 1626 | + ec = process_easyconfig(os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb'))[0] |
| 1627 | + eb = get_easyblock_instance(ec) |
| 1628 | + eb.src = [] |
| 1629 | + sources = [ |
| 1630 | + { |
| 1631 | + 'filename': 'testrepository.tar.xz', |
| 1632 | + 'git_config': { |
| 1633 | + 'repo_name': 'testrepository', |
| 1634 | + 'url': 'https://github.com/easybuilders', |
| 1635 | + 'tag': 'branch_tag_for_test', |
| 1636 | + } |
| 1637 | + } |
| 1638 | + ] |
| 1639 | + checksums = ["00000000"] |
| 1640 | + with self.mocked_stdout_stderr(): |
| 1641 | + eb.fetch_sources(sources, checksums=checksums) |
| 1642 | + |
| 1643 | + self.assertEqual(len(eb.src), 1) |
| 1644 | + self.assertEqual(eb.src[0]['name'], "testrepository.tar.xz") |
| 1645 | + self.assertExists(eb.src[0]['path']) |
| 1646 | + self.assertEqual(eb.src[0]['cmd'], None) |
| 1647 | + |
| 1648 | + reference_checksum = "00000000" |
| 1649 | + if sys.version_info[0] >= 3 and sys.version_info[1] < 9: |
| 1650 | + # checksums of tarballs made by EB cannot be reliably checked prior to Python 3.9 |
| 1651 | + # due to changes introduced in python/cpython#90021 |
| 1652 | + reference_checksum = None |
| 1653 | + |
| 1654 | + self.assertEqual(eb.src[0]['checksum'], reference_checksum) |
| 1655 | + |
1621 | 1656 | def test_download_instructions(self): |
1622 | 1657 | """Test use of download_instructions easyconfig parameter.""" |
1623 | 1658 |
|
|
0 commit comments