Make tests use mock compiler configuration.

- makes sure tests don't fail on systems that don't have some compilers (e.g. clang).
- more control over specific test cases for compilers.
This commit is contained in:
Todd Gamblin 2014-06-22 10:06:50 -07:00
parent c256d5d1ac
commit c091c6d412
4 changed files with 25 additions and 2 deletions

View file

@ -64,10 +64,14 @@
db = PackageDB(packages_path) db = PackageDB(packages_path)
# #
# This is the path to mock packages used by spack for testing. # Paths to mock files for testing.
# #
mock_packages_path = join_path(var_path, "mock_packages") mock_packages_path = join_path(var_path, "mock_packages")
mock_config_path = join_path(var_path, "mock_configs")
mock_site_config = join_path(mock_config_path, "site_spackconfig")
mock_user_config = join_path(mock_config_path, "user_spackconfig")
# #
# This controls how spack lays out install prefixes and # This controls how spack lays out install prefixes and
# stage directories. # stage directories.

View file

@ -25,9 +25,11 @@
import unittest import unittest
import spack import spack
import spack.config
from spack.packages import PackageDB from spack.packages import PackageDB
from spack.spec import Spec from spack.spec import Spec
def set_pkg_dep(pkg, spec): def set_pkg_dep(pkg, spec):
"""Alters dependence information for a pacakge. """Alters dependence information for a pacakge.
Use this to mock up constraints. Use this to mock up constraints.
@ -45,9 +47,14 @@ def setUp(self):
self.real_db = spack.db self.real_db = spack.db
spack.db = PackageDB(spack.mock_packages_path) spack.db = PackageDB(spack.mock_packages_path)
self.real_scopes = spack.config._scopes
spack.config._scopes = {
'site' : spack.mock_site_config,
'user' : spack.mock_user_config }
@classmethod @classmethod
def tearDown(self): def tearDown(self):
"""Restore the real packages path after any test.""" """Restore the real packages path after any test."""
#restore_dependencies()
spack.db = self.real_db spack.db = self.real_db
spack.config._scopes = self.real_scopes

View file

@ -0,0 +1,12 @@
[compiler "gcc@4.5.0"]
cc = /path/to/gcc
cxx = /path/to/g++
f77 = /path/to/gfortran
fc = /path/to/gfortran
[compiler "clang@3.3"]
cc = /path/to/clang
cxx = /path/to/clang++
f77 = None
fc = None

View file