From 26f0659c046c69a001c1ff456f12904b1e8f730c Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sun, 25 Oct 2020 12:20:53 +0100 Subject: [PATCH] don't change directory in download_repo function --- easybuild/tools/github.py | 3 +-- test/framework/github.py | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/easybuild/tools/github.py b/easybuild/tools/github.py index d1d9df5290..4d80344d29 100644 --- a/easybuild/tools/github.py +++ b/easybuild/tools/github.py @@ -50,7 +50,7 @@ from easybuild.framework.easyconfig.parser import EasyConfigParser from easybuild.tools.build_log import EasyBuildError, print_msg, print_warning from easybuild.tools.config import build_option -from easybuild.tools.filetools import apply_patch, change_dir, copy_dir, copy_easyblocks, copy_framework_files +from easybuild.tools.filetools import apply_patch, copy_dir, copy_easyblocks, copy_framework_files from easybuild.tools.filetools import det_patched_files, download_file, extract_file from easybuild.tools.filetools import get_easyblock_class_name, mkdir, read_file, symlink, which, write_file from easybuild.tools.py2vs3 import HTTPError, URLError, ascii_letters, urlopen @@ -364,7 +364,6 @@ def download_repo(repo=GITHUB_EASYCONFIGS_REPO, branch='master', account=GITHUB_ _log.debug("%s downloaded to %s, extracting now" % (base_name, path)) base_dir = extract_file(target_path, path, forced=True, change_into_dir=False) - change_dir(base_dir) extracted_path = os.path.join(base_dir, extracted_dir_name) # check if extracted_path exists diff --git a/test/framework/github.py b/test/framework/github.py index 46cb79c514..80e86ac76d 100644 --- a/test/framework/github.py +++ b/test/framework/github.py @@ -345,6 +345,8 @@ def test_download_repo(self): print("Skipping test_download_repo, no GitHub token available?") return + cwd = os.getcwd() + # default: download tarball for master branch of easybuilders/easybuild-easyconfigs repo path = gh.download_repo(path=self.test_prefix, github_user=GITHUB_TEST_ACCOUNT) repodir = os.path.join(self.test_prefix, 'easybuilders', 'easybuild-easyconfigs-master') @@ -354,6 +356,9 @@ def test_download_repo(self): self.assertTrue(re.match('^[0-9a-f]{40}$', read_file(shafile))) self.assertTrue(os.path.exists(os.path.join(repodir, 'easybuild', 'easyconfigs', 'f', 'foss', 'foss-2019b.eb'))) + # current directory should not have changed after calling download_repo + self.assertTrue(os.path.samefile(cwd, os.getcwd())) + # existing downloaded repo is not reperformed, except if SHA is different account, repo, branch = 'boegel', 'easybuild-easyblocks', 'develop' repodir = os.path.join(self.test_prefix, account, '%s-%s' % (repo, branch))