summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>2023-06-06 11:58:53 -0700
committerGitHub <noreply@github.com>2023-06-06 11:58:53 -0700
commit815b210fc8ea5fd118d713f9035028fba156e1fd (patch)
tree857a065611361d6a90354e23256a55814d7585b8
parente5d5efb4c10a57b5564b1ebc084a173e638c9966 (diff)
downloadspack-815b210fc8ea5fd118d713f9035028fba156e1fd.tar.gz
spack-815b210fc8ea5fd118d713f9035028fba156e1fd.tar.bz2
spack-815b210fc8ea5fd118d713f9035028fba156e1fd.tar.xz
spack-815b210fc8ea5fd118d713f9035028fba156e1fd.zip
tests/ginkgo: converted to new stand-alone test process (#35730)
* Ginkgo: converted to new stand-alone test process * ginkgo: update string formatting, compiler setting
-rw-r--r--var/spack/repos/builtin/packages/ginkgo/package.py107
1 files changed, 52 insertions, 55 deletions
diff --git a/var/spack/repos/builtin/packages/ginkgo/package.py b/var/spack/repos/builtin/packages/ginkgo/package.py
index 64403b628e..fa8c8d5f5b 100644
--- a/var/spack/repos/builtin/packages/ginkgo/package.py
+++ b/var/spack/repos/builtin/packages/ginkgo/package.py
@@ -16,6 +16,8 @@ class Ginkgo(CMakePackage, CudaPackage, ROCmPackage):
homepage = "https://ginkgo-project.github.io/"
git = "https://github.com/ginkgo-project/ginkgo.git"
+ test_requires_compiler = True
+
maintainers("tcojean", "hartwiganzt")
tags = ["e4s"]
@@ -160,33 +162,32 @@ class Ginkgo(CMakePackage, CudaPackage, ROCmPackage):
)
return args
- extra_install_tests = join_path("test", "test_install")
+ @property
+ def extra_install_tests(self):
+ return "test_install" if self.spec.satisfies("@1.3.0") else "test"
@run_after("install")
def cache_test_sources(self):
self.cache_extra_test_sources(self.extra_install_tests)
- @property
- def _cached_tests_src_dir(self):
- """The cached smoke test source directory."""
- return join_path(self.test_suite.current_test_cache_dir, self.extra_install_tests)
+ def _cached_tests_src_dir(self, script):
+ """The cached smoke test source directory for the script."""
+ subdir = script if self.spec.satisfies("@1.4.0:") else ""
+ return join_path(self.test_suite.current_test_cache_dir, self.extra_install_tests, subdir)
- @property
- def _cached_tests_work_dir(self):
- """The working directory for cached test sources."""
- return join_path(self._cached_tests_src_dir, "build")
+ def _build_and_run_test(self, script):
+ """Build and run the test against the installation."""
+ src_dir = self._cached_tests_src_dir(script)
- def _build_test(self):
- cmake_bin = join_path(self.spec["cmake"].prefix.bin, "cmake")
cmake_args = [
- "-DCMAKE_C_COMPILER={0}".format(self.compiler.cc),
- "-DCMAKE_CXX_COMPILER={0}".format(self.compiler.cxx),
- self._cached_tests_src_dir,
+ f"-DCMAKE_C_COMPILER={os.environ['CC']}",
+ f"-DCMAKE_CXX_COMPILER={os.environ['CXX']}",
+ src_dir,
]
# Fix: For HIP tests, add the ARCH compilation flags when not present
if "+rocm" in self.spec:
- src_path = join_path(self._cached_tests_src_dir, "CMakeLists.txt")
+ src_path = join_path(src_dir, "CMakeLists.txt")
cmakelists = open(src_path, "rt")
data = cmakelists.read()
data = data.replace(
@@ -198,43 +199,39 @@ class Ginkgo(CMakePackage, CudaPackage, ROCmPackage):
cmakelists.write(data)
cmakelists.close()
- if not self.run_test(
- cmake_bin,
- options=cmake_args,
- purpose="Generate the Makefile",
- work_dir=self._cached_tests_work_dir,
- ):
- print("Skipping Ginkgo test: failed to generate Makefile")
- return
-
- if not self.run_test(
- "make", purpose="Build test software", work_dir=self._cached_tests_work_dir
- ):
- print("Skipping Ginkgo test: failed to build test")
- return
-
- def test(self):
- """Run the smoke tests."""
- # For now only 1.4.0 and later releases support this scheme.
- if self.spec.satisfies("@:1.3.0"):
- print("SKIPPED: smoke tests not supported with this Ginkgo version.")
- return
-
- self._build_test()
-
- # Perform the test(s) created by setup_build_tests.
- files = [
- ("test_install", [r"REFERENCE", r"correctly detected and is complete"]),
- ("test_install_cuda", [r"CUDA", r"correctly detected and is complete"]),
- ("test_install_hip", [r"HIP", r"correctly detected and is complete"]),
- ]
- for f, expected in files:
- self.run_test(
- f,
- [],
- expected,
- skip_missing=True,
- installed=False,
- purpose="test: Running {0}".format(f),
- work_dir=self._cached_tests_work_dir,
- )
+ cmake = which(self.spec["cmake"].prefix.bin.cmake)
+ make = which("make")
+ with working_dir(src_dir):
+ cmake(*cmake_args)
+ make()
+ exe = which(script)
+ output = exe(output=str.split, error=str.split)
+ assert "correctly detected and is complete" in output
+
+ def test_install(self):
+ """build, run and check results of test_install"""
+ if not self.spec.satisfies("@1.3.0:"):
+ raise SkipTest("Test is only available for v1.3.0:")
+
+ self._build_and_run_test("test_install")
+
+ def test_install_cuda(self):
+ """build, run and check results of test_install_cuda"""
+ if not self.spec.satisfies("@1.4.0: +cuda"):
+ raise SkipTest("Test is only available for v1.4.0: +cuda")
+
+ self._build_and_run_test("test_install_cuda")
+
+ def test_install_hip(self):
+ """build, run and check results of test_install_hip"""
+ if not self.spec.satisfies("@1.4.0: +rocm"):
+ raise SkipTest("Test is only available for v1.4.0: +rocm")
+
+ self._build_and_run_test("test_install_hip")
+
+ def test_exportbuild(self):
+ """build, run and check results of test_exportbuild"""
+ if not self.spec.satisfies("@1.4.0:"):
+ raise SkipTest("Test is only available for v1.4.0:")
+
+ self._build_and_run_test("test_exportbuild")