diff options
Diffstat (limited to 'var/spack/repos/builtin/packages/mptensor/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/mptensor/package.py | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/var/spack/repos/builtin/packages/mptensor/package.py b/var/spack/repos/builtin/packages/mptensor/package.py index 3fcae8fc5b..b3b3e97203 100644 --- a/var/spack/repos/builtin/packages/mptensor/package.py +++ b/var/spack/repos/builtin/packages/mptensor/package.py @@ -17,6 +17,8 @@ class Mptensor(CMakePackage): version("0.3.0", sha256="819395a91551bddb77958615042fcb935a4b67ee37f912b9a2ca5b49c71befae") + depends_on("cxx", type="build") # generated + variant("mpi", default=False, description="Build with MPI library") variant("doc", default=False, description="build documentation with Doxygen") @@ -68,33 +70,41 @@ class Mptensor(CMakePackage): def setup_build_tests(self): """Copy the build test files after the package is installed to an install test subdirectory for use during `spack test run`.""" - self.cache_extra_test_sources(".") - def test(self): + # Tests only supported when spec built with mpi if "+mpi" not in self.spec: - print("Test of mptensor only runs with +mpi option.") - else: - with working_dir(join_path(self.install_test_root, "tests"), create=False): - make("clean") - makefile = FileFilter("Makefile") - makefile.filter("g++", "{0}".format(spack_cxx), string=True) - - with working_dir(join_path(self.install_test_root), create=False): - makefile = FileFilter("Makefile.option") - makefile.filter("CXX =.*", "CXX ={0}".format(self.spec["mpi"].mpicxx)) - makefile.filter("CXXFLAGS =.*", "CXXFLAGS ={0}".format(self.compiler.cxx11_flag)) - - math_libs = ( - self.spec["scalapack"].libs + self.spec["lapack"].libs + self.spec["blas"].libs - ) + print("Skipping copy of stand-alone test files: requires +mpi build") + return + + cache_extra_test_sources(self, ".") + + # Clean cached makefiles now so only done once + print("Converting cached Makefile for stand-alone test use") + with working_dir(join_path(install_test_root(self), "tests")): + make("clean") + makefile = FileFilter("Makefile") + makefile.filter("g++", f"{spack_cxx}", string=True) + + print("Converting cached Makefile.option for stand-alone test use") + with working_dir(join_path(install_test_root(self))): + makefile = FileFilter("Makefile.option") + makefile.filter("CXX =.*", f"CXX ={self.spec['mpi'].mpicxx}") + makefile.filter("CXXFLAGS =.*", f"CXXFLAGS ={self.compiler.cxx11_flag}") + + def test_tensor_test(self): + """build and run tensor_test""" + if "+mpi" not in self.spec: + raise SkipTest("Package must be installed with +mpi") + + math_libs = self.spec["scalapack"].libs + self.spec["lapack"].libs + self.spec["blas"].libs - with working_dir(join_path(self.install_test_root, "tests"), create=False): - make("LDFLAGS={0}".format(math_libs.ld_flags)) + with working_dir(self.test_suite.current_test_cache_dir.tests): + make = which("make") + make(f"LDFLAGS={math_libs.ld_flags}") - mpirun = self.spec["mpi"].prefix.bin.mpirun - mpiexec = Executable(mpirun) - mpiexec("-n", "1", "tensor_test.out") + mpirun = which(self.spec["mpi"].prefix.bin.mpirun) + mpirun("-n", "1", "tensor_test.out") - # Test of mptensor has checker - # and checker is abort when check detect any errors. - print("Test of mptensor PASSED !") + # Test of mptensor has checker + # and checker is abort when check detect any errors. + print("Test of mptensor PASSED !") |