test/packages: fixed test suite (#3236)
It seems the tests in `packages.py` were running just because we had a specific order of execution. This should fix the problem, and make the test_suite more resilient to running order.
This commit is contained in:
parent
88f97c07de
commit
5ce926d2d1
@ -23,115 +23,108 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import spack
|
import spack
|
||||||
|
import pytest
|
||||||
|
|
||||||
from llnl.util.filesystem import join_path
|
from llnl.util.filesystem import join_path
|
||||||
from spack.repository import Repo
|
from spack.repository import Repo
|
||||||
from spack.util.naming import mod_to_class
|
from spack.util.naming import mod_to_class
|
||||||
from spack.spec import *
|
from spack.spec import *
|
||||||
|
|
||||||
|
|
||||||
def test_load_package(builtin_mock):
|
@pytest.mark.usefixtures('config', 'builtin_mock')
|
||||||
spack.repo.get('mpich')
|
class TestPackage(object):
|
||||||
|
def test_load_package(self):
|
||||||
|
spack.repo.get('mpich')
|
||||||
|
|
||||||
|
def test_package_name(self):
|
||||||
|
pkg = spack.repo.get('mpich')
|
||||||
|
assert pkg.name == 'mpich'
|
||||||
|
|
||||||
def test_package_name(builtin_mock):
|
def test_package_filename(self):
|
||||||
pkg = spack.repo.get('mpich')
|
repo = Repo(spack.mock_packages_path)
|
||||||
assert pkg.name == 'mpich'
|
filename = repo.filename_for_package_name('mpich')
|
||||||
|
assert filename == join_path(
|
||||||
|
spack.mock_packages_path,
|
||||||
|
'packages',
|
||||||
|
'mpich',
|
||||||
|
'package.py'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_nonexisting_package_filename(self):
|
||||||
|
repo = Repo(spack.mock_packages_path)
|
||||||
|
filename = repo.filename_for_package_name('some-nonexisting-package')
|
||||||
|
assert filename == join_path(
|
||||||
|
spack.mock_packages_path,
|
||||||
|
'packages',
|
||||||
|
'some-nonexisting-package',
|
||||||
|
'package.py'
|
||||||
|
)
|
||||||
|
|
||||||
def test_package_filename(builtin_mock):
|
def test_package_class_names(self):
|
||||||
repo = Repo(spack.mock_packages_path)
|
assert 'Mpich' == mod_to_class('mpich')
|
||||||
filename = repo.filename_for_package_name('mpich')
|
assert 'PmgrCollective' == mod_to_class('pmgr_collective')
|
||||||
assert filename == join_path(
|
assert 'PmgrCollective' == mod_to_class('pmgr-collective')
|
||||||
spack.mock_packages_path,
|
assert 'Pmgrcollective' == mod_to_class('PmgrCollective')
|
||||||
'packages',
|
assert '_3db' == mod_to_class('3db')
|
||||||
'mpich',
|
|
||||||
'package.py'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
# Below tests target direct imports of spack packages from the
|
||||||
|
# spack.pkg namespace
|
||||||
|
def test_import_package(self):
|
||||||
|
import spack.pkg.builtin.mock.mpich # noqa
|
||||||
|
|
||||||
def test_nonexisting_package_filename():
|
def test_import_package_as(self):
|
||||||
repo = Repo(spack.mock_packages_path)
|
import spack.pkg.builtin.mock.mpich as mp # noqa
|
||||||
filename = repo.filename_for_package_name('some-nonexisting-package')
|
|
||||||
assert filename == join_path(
|
|
||||||
spack.mock_packages_path,
|
|
||||||
'packages',
|
|
||||||
'some-nonexisting-package',
|
|
||||||
'package.py'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
import spack.pkg.builtin.mock # noqa
|
||||||
|
import spack.pkg.builtin.mock as m # noqa
|
||||||
|
from spack.pkg.builtin import mock # noqa
|
||||||
|
|
||||||
def test_package_class_names():
|
def test_inheritance_of_diretives(self):
|
||||||
assert 'Mpich' == mod_to_class('mpich')
|
p = spack.repo.get('simple-inheritance')
|
||||||
assert 'PmgrCollective' == mod_to_class('pmgr_collective')
|
|
||||||
assert 'PmgrCollective' == mod_to_class('pmgr-collective')
|
|
||||||
assert 'Pmgrcollective' == mod_to_class('PmgrCollective')
|
|
||||||
assert '_3db' == mod_to_class('3db')
|
|
||||||
|
|
||||||
|
# Check dictionaries that should have been filled by directives
|
||||||
|
assert len(p.dependencies) == 3
|
||||||
|
assert 'cmake' in p.dependencies
|
||||||
|
assert 'openblas' in p.dependencies
|
||||||
|
assert 'mpi' in p.dependencies
|
||||||
|
assert len(p.provided) == 2
|
||||||
|
|
||||||
# Below tests target direct imports of spack packages from the
|
# Check that Spec instantiation behaves as we expect
|
||||||
# spack.pkg namespace
|
s = Spec('simple-inheritance')
|
||||||
def test_import_package(builtin_mock):
|
s.concretize()
|
||||||
import spack.pkg.builtin.mock.mpich # noqa
|
assert '^cmake' in s
|
||||||
|
assert '^openblas' in s
|
||||||
|
assert '+openblas' in s
|
||||||
|
assert 'mpi' in s
|
||||||
|
|
||||||
|
s = Spec('simple-inheritance~openblas')
|
||||||
|
s.concretize()
|
||||||
|
assert '^cmake' in s
|
||||||
|
assert '^openblas' not in s
|
||||||
|
assert '~openblas' in s
|
||||||
|
assert 'mpi' in s
|
||||||
|
|
||||||
def test_import_package_as(builtin_mock):
|
def test_dependency_extensions(self):
|
||||||
import spack.pkg.builtin.mock.mpich as mp # noqa
|
s = Spec('extension2')
|
||||||
|
s.concretize()
|
||||||
|
deps = set(x.name for x in s.package.dependency_activations())
|
||||||
|
assert deps == set(['extension1'])
|
||||||
|
|
||||||
import spack.pkg.builtin.mock # noqa
|
def test_import_class_from_package(self):
|
||||||
import spack.pkg.builtin.mock as m # noqa
|
from spack.pkg.builtin.mock.mpich import Mpich # noqa
|
||||||
from spack.pkg.builtin import mock # noqa
|
|
||||||
|
|
||||||
|
def test_import_module_from_package(self):
|
||||||
|
from spack.pkg.builtin.mock import mpich # noqa
|
||||||
|
|
||||||
def test_inheritance_of_diretives():
|
def test_import_namespace_container_modules(self):
|
||||||
p = spack.repo.get('simple-inheritance')
|
import spack.pkg # noqa
|
||||||
|
import spack.pkg as p # noqa
|
||||||
|
from spack import pkg # noqa
|
||||||
|
|
||||||
# Check dictionaries that should have been filled by directives
|
import spack.pkg.builtin # noqa
|
||||||
assert len(p.dependencies) == 3
|
import spack.pkg.builtin as b # noqa
|
||||||
assert 'cmake' in p.dependencies
|
from spack.pkg import builtin # noqa
|
||||||
assert 'openblas' in p.dependencies
|
|
||||||
assert 'mpi' in p.dependencies
|
|
||||||
assert len(p.provided) == 2
|
|
||||||
|
|
||||||
# Check that Spec instantiation behaves as we expect
|
import spack.pkg.builtin.mock # noqa
|
||||||
s = Spec('simple-inheritance')
|
import spack.pkg.builtin.mock as m # noqa
|
||||||
s.concretize()
|
from spack.pkg.builtin import mock # noqa
|
||||||
assert '^cmake' in s
|
|
||||||
assert '^openblas' in s
|
|
||||||
assert '+openblas' in s
|
|
||||||
assert 'mpi' in s
|
|
||||||
|
|
||||||
s = Spec('simple-inheritance~openblas')
|
|
||||||
s.concretize()
|
|
||||||
assert '^cmake' in s
|
|
||||||
assert '^openblas' not in s
|
|
||||||
assert '~openblas' in s
|
|
||||||
assert 'mpi' in s
|
|
||||||
|
|
||||||
|
|
||||||
def test_dependency_extensions():
|
|
||||||
s = Spec('extension2')
|
|
||||||
s.concretize()
|
|
||||||
deps = set(x.name for x in s.package.dependency_activations())
|
|
||||||
assert deps == set(['extension1'])
|
|
||||||
|
|
||||||
|
|
||||||
def test_import_class_from_package(builtin_mock):
|
|
||||||
from spack.pkg.builtin.mock.mpich import Mpich # noqa
|
|
||||||
|
|
||||||
|
|
||||||
def test_import_module_from_package(builtin_mock):
|
|
||||||
from spack.pkg.builtin.mock import mpich # noqa
|
|
||||||
|
|
||||||
|
|
||||||
def test_import_namespace_container_modules(builtin_mock):
|
|
||||||
import spack.pkg # noqa
|
|
||||||
import spack.pkg as p # noqa
|
|
||||||
from spack import pkg # noqa
|
|
||||||
|
|
||||||
import spack.pkg.builtin # noqa
|
|
||||||
import spack.pkg.builtin as b # noqa
|
|
||||||
from spack.pkg import builtin # noqa
|
|
||||||
|
|
||||||
import spack.pkg.builtin.mock # noqa
|
|
||||||
import spack.pkg.builtin.mock as m # noqa
|
|
||||||
from spack.pkg.builtin import mock # noqa
|
|
||||||
|
Loading…
Reference in New Issue
Block a user