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)
This commit is contained in:
parent
ed0f6f75a7
commit
dbfa6c925e
@ -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)
|
||||
|
@ -47,7 +47,10 @@
|
||||
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")
|
||||
|
@ -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)
|
||||
|
@ -322,9 +322,7 @@ def check(self):
|
||||
|
||||
|
||||
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):
|
||||
|
@ -34,6 +34,8 @@
|
||||
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 @@ def rm_cache(self):
|
||||
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user