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)
|
os.unlink(path)
|
||||||
else:
|
else:
|
||||||
shutil.rmtree(path, True)
|
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")
|
repos_path = join_path(var_path, "repos")
|
||||||
share_path = join_path(spack_root, "share", "spack")
|
share_path = join_path(spack_root, "share", "spack")
|
||||||
cache_path = join_path(var_path, "cache")
|
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
|
prefix = spack_root
|
||||||
opt_path = join_path(prefix, "opt")
|
opt_path = join_path(prefix, "opt")
|
||||||
|
@ -67,7 +67,5 @@ def test(parser, args):
|
|||||||
|
|
||||||
if not os.path.exists(outputDir):
|
if not os.path.exists(outputDir):
|
||||||
mkdirp(outputDir)
|
mkdirp(outputDir)
|
||||||
spack.cache_path = join_path(spack.var_path, "test-cache")
|
spack.cache = None
|
||||||
mkdirp(spack.cache_path)
|
|
||||||
spack.test.run(args.names, outputDir, args.verbose)
|
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):
|
def cache_local(self):
|
||||||
archiveDst = join_path(os.path.abspath(spack.cache_path), self.mirror_path)
|
spack.cache.store(self.fetcher.archive, self.mirror_path)
|
||||||
mkdirp(os.path.dirname(archiveDst))
|
|
||||||
self.fetcher.archive(archiveDst)
|
|
||||||
|
|
||||||
|
|
||||||
def expand_archive(self):
|
def expand_archive(self):
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
from spack.repository import RepoPath
|
from spack.repository import RepoPath
|
||||||
from spack.spec import Spec
|
from spack.spec import Spec
|
||||||
|
|
||||||
|
import llnl.util.tty as tty
|
||||||
|
|
||||||
mock_compiler_config = """\
|
mock_compiler_config = """\
|
||||||
compilers:
|
compilers:
|
||||||
all:
|
all:
|
||||||
@ -130,11 +132,15 @@ def rm_cache(self):
|
|||||||
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.rm_cache()
|
spack.cache = MockCache()
|
||||||
mkdirp(spack.cache_path)
|
|
||||||
self.initmock()
|
self.initmock()
|
||||||
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.rm_cache()
|
spack.cache = None
|
||||||
self.cleanmock()
|
self.cleanmock()
|
||||||
|
|
||||||
|
class MockCache(object):
|
||||||
|
def store(self, copyCmd, relativeDst):
|
||||||
|
tty.warn("Copying " + str(relativeDst))
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user