Skip to content
Open
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 easybuild/framework/easyconfig/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2327,7 +2327,7 @@ def process_easyconfig(path, build_specs=None, validate=True, parse_only=False,
# only cache when no build specifications are involved (since those can't be part of a dict key)
cache_key = None
if not build_specs:
cache_key = (path, validate, hidden, parse_only)
cache_key = (str(path), validate, hidden, parse_only)
if cache_key in _easyconfigs_cache:
# Note: This does NOT copy EasyConfig instances but the dict containing an instance in the 'ec' key.
# So modifications to the `EasyConfig` instance will be shared.
Expand Down
3 changes: 2 additions & 1 deletion easybuild/tools/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import zlib
from functools import partial
from html.parser import HTMLParser
from pathlib import Path
import urllib.request as std_urllib

from easybuild.base import fancylogger
Expand Down Expand Up @@ -2747,7 +2748,7 @@ def copy(paths, target_path, force_in_dry_run=False, **kwargs):
:param force_in_dry_run: force running the command during dry run
:param kwargs: additional named arguments to pass down to copy_dir
"""
if isinstance(paths, str):
if isinstance(paths, (str, Path)):
paths = [paths]

_log.info("Copying %d files & directories to %s", len(paths), target_path)
Expand Down
10 changes: 10 additions & 0 deletions test/framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@

@author: Toon Willems (Ghent University)
"""

from pathlib import Path
from easybuild.tools.filetools import read_file

TEST_DIR = Path(__file__).parent
REPO_ROOT = TEST_DIR.parent.parent
TEST_MODULES_DIR = TEST_DIR / 'modules'
TEST_ECS_DIR = TEST_DIR / 'easyconfigs' / 'test_ecs'
TOY_EC = TEST_ECS_DIR / 't' / 'toy' / 'toy-0.0.eb'
TOY_EC_TXT: str = read_file(TOY_EC)
7 changes: 3 additions & 4 deletions test/framework/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import sys
import tempfile
from importlib import reload
from test.framework import TEST_DIR
from test.framework.utilities import EnhancedTestCase, TestLoaderFiltered, init_config
from unittest import TextTestRunner

Expand Down Expand Up @@ -264,8 +265,7 @@ def test_generaloption_config_file(self):
tmpdir = tempfile.mkdtemp(prefix='easybuild-easyconfigs-pkg-install-path')
mkdir(os.path.join(tmpdir, 'easybuild'), parents=True)

test_ecs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs')
copy_dir(test_ecs_dir, os.path.join(tmpdir, 'easybuild', 'easyconfigs'))
copy_dir(os.path.join(TEST_DIR, 'easyconfigs'), os.path.join(tmpdir, 'easybuild', 'easyconfigs'))

orig_sys_path = sys.path[:]
sys.path.insert(0, tmpdir) # prepend to give it preference over possible other installed easyconfigs pkgs
Expand Down Expand Up @@ -498,9 +498,8 @@ def test_flex_robot_paths(self):
# to check whether easyconfigs install path is auto-included in robot path
tmpdir = tempfile.mkdtemp(prefix='easybuild-easyconfigs-pkg-install-path')
mkdir(os.path.join(tmpdir, 'easybuild'), parents=True)
test_ecs_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs')
tmp_ecs_dir = os.path.join(tmpdir, 'easybuild', 'easyconfigs')
copy_dir(test_ecs_path, tmp_ecs_dir)
copy_dir(os.path.join(TEST_DIR, 'easyconfigs'), tmp_ecs_dir)

# prepend path to test easyconfigs into Python search path, so it gets picked up as --robot-paths default
orig_sys_path = sys.path[:]
Expand Down
23 changes: 6 additions & 17 deletions test/framework/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import re
import stat
import sys
from test.framework import TEST_ECS_DIR, TOY_EC
from test.framework.utilities import EnhancedTestCase, TestLoaderFiltered
from unittest import TextTestRunner

Expand Down Expand Up @@ -92,9 +93,6 @@ def check_regexs(self, regexs, stdout):

def test_end2end_singularity_recipe_config(self):
"""End-to-end test for --containerize (recipe only), using --container-config."""
test_ecs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')

containerpath = os.path.join(self.test_prefix, 'containers')
os.environ['EASYBUILD_CONTAINERPATH'] = containerpath
# --containerpath must be an existing directory (this is done to avoid misconfiguration)
Expand All @@ -103,7 +101,7 @@ def test_end2end_singularity_recipe_config(self):
test_container_recipe = os.path.join(self.test_prefix, 'containers', 'Singularity.toy-0.0')

args = [
toy_ec,
TOY_EC,
'--containerize',
'--experimental',
]
Expand Down Expand Up @@ -260,9 +258,6 @@ def test_end2end_singularity_recipe_config(self):

def test_end2end_singularity_image(self):
"""End-to-end test for --containerize (recipe + image)."""
topdir = os.path.dirname(os.path.abspath(__file__))
toy_ec = os.path.join(topdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb')

containerpath = os.path.join(self.test_prefix, 'containers')
os.environ['EASYBUILD_CONTAINERPATH'] = containerpath
# --containerpath must be an existing directory (this is done to avoid misconfiguration)
Expand All @@ -272,7 +267,7 @@ def test_end2end_singularity_image(self):
write_file(test_img, '')

args = [
toy_ec,
TOY_EC,
'-C', # equivalent with --containerize
'--experimental',
'--container-config=bootstrap=localimage,from=%s' % test_img,
Expand Down Expand Up @@ -364,16 +359,13 @@ def test_end2end_singularity_image(self):
self.check_regexs(regexs, stdout)

def test_end2end_dockerfile(self):
test_ecs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')

containerpath = os.path.join(self.test_prefix, 'containers')
os.environ['EASYBUILD_CONTAINERPATH'] = containerpath
# --containerpath must be an existing directory (this is done to avoid misconfiguration)
mkdir(containerpath)

base_args = [
toy_ec,
TOY_EC,
'--containerize',
'--container-type=docker',
'--experimental',
Expand Down Expand Up @@ -405,7 +397,7 @@ def test_end2end_dockerfile(self):

remove_file(os.path.join(self.test_prefix, 'containers', 'Dockerfile.toy-0.0'))

base_args.insert(1, os.path.join(test_ecs, 'g', 'GCC', 'GCC-4.9.2.eb'))
base_args.insert(1, os.path.join(TEST_ECS_DIR, 'g', 'GCC', 'GCC-4.9.2.eb'))
self.run_main(base_args + ['--container-config=ubuntu:20.04'])
def_file = read_file(os.path.join(self.test_prefix, 'containers', 'Dockerfile.toy-0.0'))
regexs = [
Expand All @@ -422,16 +414,13 @@ def test_end2end_dockerfile(self):

def test_end2end_docker_image(self):

topdir = os.path.dirname(os.path.abspath(__file__))
toy_ec = os.path.join(topdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb')

containerpath = os.path.join(self.test_prefix, 'containers')
os.environ['EASYBUILD_CONTAINERPATH'] = containerpath
# --containerpath must be an existing directory (this is done to avoid misconfiguration)
mkdir(containerpath)

args = [
toy_ec,
TOY_EC,
'-C', # equivalent with --containerize
'--experimental',
'--container-type=docker',
Expand Down
8 changes: 4 additions & 4 deletions test/framework/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from easybuild.tools.options import EasyBuildOptions
from easybuild.tools.utilities import mk_md_table, mk_rst_table
from test.framework.utilities import EnhancedTestCase, TestLoaderFiltered, init_config
from test.framework import TEST_DIR, TEST_ECS_DIR


LIST_EASYBLOCKS_SIMPLE_TXT = """EasyBlock
Expand Down Expand Up @@ -869,8 +870,7 @@ def test_list_easyblocks(self):
"""
Tests for list_easyblocks function
"""
topdir = os.path.dirname(os.path.abspath(__file__))
topdir_easyblocks = os.path.join(topdir, 'sandbox', 'easybuild', 'easyblocks')
topdir_easyblocks = os.path.join(TEST_DIR, 'sandbox', 'easybuild', 'easyblocks')

txt = list_easyblocks()
self.assertEqual(txt, LIST_EASYBLOCKS_SIMPLE_TXT)
Expand Down Expand Up @@ -899,7 +899,7 @@ def test_list_easyblocks(self):
def test_list_software(self):
"""Test list_software* functions."""
build_options = {
'robot_path': [os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'v1.0')],
'robot_path': [os.path.join(TEST_DIR, 'easyconfigs', 'v1.0')],
'silent': True,
'valid_module_classes': module_classes(),
}
Expand Down Expand Up @@ -933,7 +933,7 @@ def test_list_software(self):

# check for specific patterns in output for larger set of test easyconfigs
build_options = {
'robot_path': [os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')],
'robot_path': [TEST_ECS_DIR],
'silent': True,
'valid_module_classes': module_classes(),
}
Expand Down
Loading
Loading