tests/ginkgo: converted to new stand-alone test process (#35730)
* Ginkgo: converted to new stand-alone test process * ginkgo: update string formatting, compiler setting
This commit is contained in:
		| @@ -16,6 +16,8 @@ class Ginkgo(CMakePackage, CudaPackage, ROCmPackage): | |||||||
|     homepage = "https://ginkgo-project.github.io/" |     homepage = "https://ginkgo-project.github.io/" | ||||||
|     git = "https://github.com/ginkgo-project/ginkgo.git" |     git = "https://github.com/ginkgo-project/ginkgo.git" | ||||||
| 
 | 
 | ||||||
|  |     test_requires_compiler = True | ||||||
|  | 
 | ||||||
|     maintainers("tcojean", "hartwiganzt") |     maintainers("tcojean", "hartwiganzt") | ||||||
| 
 | 
 | ||||||
|     tags = ["e4s"] |     tags = ["e4s"] | ||||||
| @@ -160,33 +162,32 @@ def cmake_args(self): | |||||||
|                 ) |                 ) | ||||||
|         return args |         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") |     @run_after("install") | ||||||
|     def cache_test_sources(self): |     def cache_test_sources(self): | ||||||
|         self.cache_extra_test_sources(self.extra_install_tests) |         self.cache_extra_test_sources(self.extra_install_tests) | ||||||
| 
 | 
 | ||||||
|     @property |     def _cached_tests_src_dir(self, script): | ||||||
|     def _cached_tests_src_dir(self): |         """The cached smoke test source directory for the script.""" | ||||||
|         """The cached smoke test source directory.""" |         subdir = script if self.spec.satisfies("@1.4.0:") else "" | ||||||
|         return join_path(self.test_suite.current_test_cache_dir, self.extra_install_tests) |         return join_path(self.test_suite.current_test_cache_dir, self.extra_install_tests, subdir) | ||||||
| 
 | 
 | ||||||
|     @property |     def _build_and_run_test(self, script): | ||||||
|     def _cached_tests_work_dir(self): |         """Build and run the test against the installation.""" | ||||||
|         """The working directory for cached test sources.""" |         src_dir = self._cached_tests_src_dir(script) | ||||||
|         return join_path(self._cached_tests_src_dir, "build") |  | ||||||
| 
 | 
 | ||||||
|     def _build_test(self): |  | ||||||
|         cmake_bin = join_path(self.spec["cmake"].prefix.bin, "cmake") |  | ||||||
|         cmake_args = [ |         cmake_args = [ | ||||||
|             "-DCMAKE_C_COMPILER={0}".format(self.compiler.cc), |             f"-DCMAKE_C_COMPILER={os.environ['CC']}", | ||||||
|             "-DCMAKE_CXX_COMPILER={0}".format(self.compiler.cxx), |             f"-DCMAKE_CXX_COMPILER={os.environ['CXX']}", | ||||||
|             self._cached_tests_src_dir, |             src_dir, | ||||||
|         ] |         ] | ||||||
| 
 | 
 | ||||||
|         # Fix: For HIP tests, add the ARCH compilation flags when not present |         # Fix: For HIP tests, add the ARCH compilation flags when not present | ||||||
|         if "+rocm" in self.spec: |         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") |             cmakelists = open(src_path, "rt") | ||||||
|             data = cmakelists.read() |             data = cmakelists.read() | ||||||
|             data = data.replace( |             data = data.replace( | ||||||
| @@ -198,43 +199,39 @@ def _build_test(self): | |||||||
|             cmakelists.write(data) |             cmakelists.write(data) | ||||||
|             cmakelists.close() |             cmakelists.close() | ||||||
| 
 | 
 | ||||||
|         if not self.run_test( |         cmake = which(self.spec["cmake"].prefix.bin.cmake) | ||||||
|             cmake_bin, |         make = which("make") | ||||||
|             options=cmake_args, |         with working_dir(src_dir): | ||||||
|             purpose="Generate the Makefile", |             cmake(*cmake_args) | ||||||
|             work_dir=self._cached_tests_work_dir, |             make() | ||||||
|         ): |             exe = which(script) | ||||||
|             print("Skipping Ginkgo test: failed to generate Makefile") |             output = exe(output=str.split, error=str.split) | ||||||
|             return |             assert "correctly detected and is complete" in output | ||||||
| 
 | 
 | ||||||
|         if not self.run_test( |     def test_install(self): | ||||||
|             "make", purpose="Build test software", work_dir=self._cached_tests_work_dir |         """build, run and check results of test_install""" | ||||||
|         ): |         if not self.spec.satisfies("@1.3.0:"): | ||||||
|             print("Skipping Ginkgo test: failed to build test") |             raise SkipTest("Test is only available for v1.3.0:") | ||||||
|             return |  | ||||||
| 
 | 
 | ||||||
|     def test(self): |         self._build_and_run_test("test_install") | ||||||
|         """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() |     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") | ||||||
| 
 | 
 | ||||||
|         # Perform the test(s) created by setup_build_tests. |         self._build_and_run_test("test_install_cuda") | ||||||
|         files = [ | 
 | ||||||
|             ("test_install", [r"REFERENCE", r"correctly detected and is complete"]), |     def test_install_hip(self): | ||||||
|             ("test_install_cuda", [r"CUDA", r"correctly detected and is complete"]), |         """build, run and check results of test_install_hip""" | ||||||
|             ("test_install_hip", [r"HIP", r"correctly detected and is complete"]), |         if not self.spec.satisfies("@1.4.0: +rocm"): | ||||||
|         ] |             raise SkipTest("Test is only available for v1.4.0: +rocm") | ||||||
|         for f, expected in files: | 
 | ||||||
|             self.run_test( |         self._build_and_run_test("test_install_hip") | ||||||
|                 f, | 
 | ||||||
|                 [], |     def test_exportbuild(self): | ||||||
|                 expected, |         """build, run and check results of test_exportbuild""" | ||||||
|                 skip_missing=True, |         if not self.spec.satisfies("@1.4.0:"): | ||||||
|                 installed=False, |             raise SkipTest("Test is only available for v1.4.0:") | ||||||
|                 purpose="test: Running {0}".format(f), | 
 | ||||||
|                 work_dir=self._cached_tests_work_dir, |         self._build_and_run_test("test_exportbuild") | ||||||
|             ) |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tamara Dahlgren
					Tamara Dahlgren