diff options
author | AcriusWinter <152348900+AcriusWinter@users.noreply.github.com> | 2024-08-11 02:03:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-11 03:03:24 -0600 |
commit | e4869cd5580feef221277cd7cd2217fc3cd2399c (patch) | |
tree | a702563deb9e32f4bc3c94d61c912c47db78037e | |
parent | 990e0dc52629d2c38b8b36317c51a4a7e9a4d845 (diff) | |
download | spack-e4869cd5580feef221277cd7cd2217fc3cd2399c.tar.gz spack-e4869cd5580feef221277cd7cd2217fc3cd2399c.tar.bz2 spack-e4869cd5580feef221277cd7cd2217fc3cd2399c.tar.xz spack-e4869cd5580feef221277cd7cd2217fc3cd2399c.zip |
hypre-cmake: old to new test API (#45144)
* hypre-cmake: old to new test API
* hypre-cmake: update Makefile to use installed files
* hypre-cmake: make stand-alone test method name more specific
---------
Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov>
-rw-r--r-- | var/spack/repos/builtin/packages/hypre-cmake/package.py | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/var/spack/repos/builtin/packages/hypre-cmake/package.py b/var/spack/repos/builtin/packages/hypre-cmake/package.py index c65fa30fc2..0a6bd38f6e 100644 --- a/var/spack/repos/builtin/packages/hypre-cmake/package.py +++ b/var/spack/repos/builtin/packages/hypre-cmake/package.py @@ -56,11 +56,13 @@ class HypreCmake(CMakePackage, CudaPackage): def url_for_version(self, version): if version >= Version("2.12.0"): - url = "https://github.com/hypre-space/hypre/archive/v{0}.tar.gz" + url = f"https://github.com/hypre-space/hypre/archive/v{version}.tar.gz" else: - url = "http://computing.llnl.gov/project/linear_solvers/download/hypre-{0}.tar.gz" + url = ( + f"http://computing.llnl.gov/project/linear_solvers/download/hypre-{version}.tar.gz" + ) - return url.format(version) + return url root_cmakelists_dir = "src" @@ -96,38 +98,47 @@ class HypreCmake(CMakePackage, CudaPackage): @run_after("install") def cache_test_sources(self): - self.cache_extra_test_sources(self.extra_install_tests) + if "+mpi" not in self.spec: + print("Package must be installed with +mpi to cache test sources") + return + + cache_extra_test_sources(self, self.extra_install_tests) + + # Customize the examples makefile before caching it + makefile = join_path(install_test_root(self), self.extra_install_tests, "Makefile") + filter_file(r"^HYPRE_DIR\s* =.*", f"HYPRE_DIR = {self.prefix}", makefile) + filter_file(r"^CC\s*=.*", "CC = " + self.spec["mpi"].mpicc, makefile) + filter_file(r"^F77\s*=.*", "F77 = " + self.spec["mpi"].mpif77, makefile) + filter_file(r"^CXX\s*=.*", "CXX = " + self.spec["mpi"].mpicxx, makefile) + filter_file( + r"^LIBS\s*=.*", + r"LIBS = -L$(HYPRE_DIR)/lib64 -lHYPRE -lm $(CUDA_LIBS) $(DOMP_LIBS)", + makefile, + ) @property def _cached_tests_work_dir(self): """The working directory for cached test sources.""" return join_path(self.test_suite.current_test_cache_dir, self.extra_install_tests) - def test(self): - """Perform smoke test on installed HYPRE package.""" + def test_bigint(self): + """Perform smoke tests on installed HYPRE package.""" if "+mpi" not in self.spec: - print("Skipping: HYPRE must be installed with +mpi to run tests") - return + raise SkipTest("Package must be installed with +mpi to run tests") - # Build copied and cached test examples - self.run_test( - "make", - ["HYPRE_DIR={0}".format(self.prefix), "bigint"], - purpose="test: building selected examples", - work_dir=self._cached_tests_work_dir, - ) + # Build and run cached examples + with working_dir(self._cached_tests_work_dir): + make = which("make") + make("bigint") - # Run the examples built above - for exe in ["./ex5big", "./ex15big"]: - self.run_test( - exe, - [], - [], - installed=False, - purpose="test: ensuring {0} runs".format(exe), - skip_missing=True, - work_dir=self._cached_tests_work_dir, - ) + for exe_name in ["ex5big", "ex15big"]: + with test_part(self, f"test_bigint_{exe_name}", purpose=f"Ensure {exe_name} runs"): + + program = which(exe_name) + if program is None: + raise SkipTest(f"{exe_name} does not exist in version {self.version}") + + program() @property def headers(self): |