Testing: use spack.store.use_store everywhere (#21656)

Keep spack.store.store and spack.store.db consistent in unit tests

* Remove calls to monkeypatch for spack.store.store and spack.store.db:
  tests that used these called one or the other, which lead to
  inconsistencies (the tests passed regardless but were fragile as a
  result)
* Fixtures making use of monkeypatch with mock_store now use the
  updated use_store function, which sets store.store and store.db
  consistently
* subprocess_context.TestState now transfers the serializes and
  restores spack.store.store (without the monkeypatch changes this
  would have created inconsistencies)
This commit is contained in:
Massimiliano Culpo
2021-02-18 22:22:49 +01:00
committed by GitHub
parent cbcf8d208b
commit f2e3edf6db
11 changed files with 178 additions and 176 deletions

View File

@@ -2,10 +2,11 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import spack.paths
import spack.store
class OldSbang(Package):
"""Toy package for testing the old sbang replacement problem"""
@@ -22,12 +23,12 @@ def install(self, spec, prefix):
#!/usr/bin/env python
{1}
'''.format(spack.paths.prefix, prefix.bin)
'''.format(spack.paths.prefix, prefix.bin)
sbang_style_2 = '''#!/bin/sh {0}/bin/sbang
#!/usr/bin/env python
{1}
'''.format(spack.store.unpadded_root, prefix.bin)
'''.format(spack.store.unpadded_root, prefix.bin)
with open('%s/sbang-style-1.sh' % self.prefix.bin, 'w') as f:
f.write(sbang_style_1)