From 966fc427a9a0731efbae5c435f697fcfa2b4f074 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 17 Jan 2020 17:33:05 -0800 Subject: [PATCH] copy test data into './data' in test environment --- lib/spack/spack/package.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index e0178c9c0ff..5e60750725a 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -55,6 +55,8 @@ from spack.filesystem_view import YamlFilesystemView from spack.installer import \ install_args_docstring, PackageInstaller, InstallError +from spack.util.executable import which +from spack.util.prefix import Prefix from spack.stage import stage_prefix, Stage, ResourceStage, StageComposite from spack.util.package_hash import package_hash from spack.version import Version @@ -1610,11 +1612,18 @@ def test_process(): tty.set_debug(True) # setup test directory - alltestsdir = os.path.join(os.getcwd(), 'spack-tests') - testdir = os.path.join(alltestsdir, - self.spec.format('{name}-{hash}')) + alltestsdir = Prefix(os.getcwd()).join('spack-tests') + testdir = alltestsdir.join(self.spec.format('{name}-{hash}')) + if os.path.exists(testdir): + shutil.rmtree(testdir) + mkdirp(testdir) + + # copy test data into testdir/data + datadir = Prefix(self.package_dir).test + if os.path.isdir(datadir): + shutil.copytree(datadir, testdir.data) + try: - mkdirp(testdir) os.chdir(testdir) self.test() except Exception as e: