summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2016-03-23 20:18:58 -0700
committerPeter Scheibel <scheibel1@llnl.gov>2016-03-23 20:18:58 -0700
commitdbfa6c925ec60c89004f6ccd88e985f71f650a69 (patch)
tree24ee71661d41b43cf10462fba6fb4607a85d148c /lib
parented0f6f75a7215c959431377ffe7e4faf09dc88d6 (diff)
downloadspack-dbfa6c925ec60c89004f6ccd88e985f71f650a69.tar.gz
spack-dbfa6c925ec60c89004f6ccd88e985f71f650a69.tar.bz2
spack-dbfa6c925ec60c89004f6ccd88e985f71f650a69.tar.xz
spack-dbfa6c925ec60c89004f6ccd88e985f71f650a69.zip
replace references to cache directory with references to new cache object. tests may assign a mock cache but by default it is None (this will avoid any implicit caching behavior confusing unit tests)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/filesystem.py9
-rw-r--r--lib/spack/spack/__init__.py5
-rw-r--r--lib/spack/spack/cmd/test.py4
-rw-r--r--lib/spack/spack/stage.py4
-rw-r--r--lib/spack/spack/test/mock_packages_test.py12
5 files changed, 24 insertions, 10 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index c4665c284c..7586d514d1 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -392,3 +392,12 @@ def remove_linked_tree(path):
os.unlink(path)
else:
shutil.rmtree(path, True)
+
+class FsCache(object):
+ def __init__(self, root):
+ self.root = os.path.abspath(root)
+
+ def store(self, copyCmd, relativeDst):
+ dst = join_path(self.root, relativeDst)
+ mkdirp(os.path.dirname(dst))
+ copyCmd(dst)
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
index 6fb472b15d..0041d50624 100644
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -47,7 +47,10 @@ stage_path = join_path(var_path, "stage")
repos_path = join_path(var_path, "repos")
share_path = join_path(spack_root, "share", "spack")
cache_path = join_path(var_path, "cache")
-mkdirp(cache_path)
+
+# TODO: i get a complaint if i dont qualify this, fix that
+import llnl.util.filesystem
+cache = llnl.util.filesystem.FsCache(cache_path)
prefix = spack_root
opt_path = join_path(prefix, "opt")
diff --git a/lib/spack/spack/cmd/test.py b/lib/spack/spack/cmd/test.py
index 233cd186f0..1a02521814 100644
--- a/lib/spack/spack/cmd/test.py
+++ b/lib/spack/spack/cmd/test.py
@@ -67,7 +67,5 @@ def test(parser, args):
if not os.path.exists(outputDir):
mkdirp(outputDir)
- spack.cache_path = join_path(spack.var_path, "test-cache")
- mkdirp(spack.cache_path)
+ spack.cache = None
spack.test.run(args.names, outputDir, args.verbose)
- shutil.rmtree(spack.cache_path, ignore_errors=True)
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index 54359bddce..780f391603 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -322,9 +322,7 @@ class Stage(object):
def cache_local(self):
- archiveDst = join_path(os.path.abspath(spack.cache_path), self.mirror_path)
- mkdirp(os.path.dirname(archiveDst))
- self.fetcher.archive(archiveDst)
+ spack.cache.store(self.fetcher.archive, self.mirror_path)
def expand_archive(self):
diff --git a/lib/spack/spack/test/mock_packages_test.py b/lib/spack/spack/test/mock_packages_test.py
index 85c15d4a6a..06d7e7d4e1 100644
--- a/lib/spack/spack/test/mock_packages_test.py
+++ b/lib/spack/spack/test/mock_packages_test.py
@@ -34,6 +34,8 @@ from ordereddict_backport import OrderedDict
from spack.repository import RepoPath
from spack.spec import Spec
+import llnl.util.tty as tty
+
mock_compiler_config = """\
compilers:
all:
@@ -130,11 +132,15 @@ class MockPackagesTest(unittest.TestCase):
def setUp(self):
- self.rm_cache()
- mkdirp(spack.cache_path)
+ spack.cache = MockCache()
self.initmock()
def tearDown(self):
- self.rm_cache()
+ spack.cache = None
self.cleanmock()
+
+class MockCache(object):
+ def store(self, copyCmd, relativeDst):
+ tty.warn("Copying " + str(relativeDst))
+ pass