From dc58449bbf2eb28c1670ae5ae5d4efffaeded573 Mon Sep 17 00:00:00 2001 From: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> Date: Thu, 11 May 2023 05:40:02 -0700 Subject: caliper: convert to new stand-alone test process (#35691) --- .../repos/builtin/packages/caliper/package.py | 67 +++++++++------------- 1 file changed, 26 insertions(+), 41 deletions(-) diff --git a/var/spack/repos/builtin/packages/caliper/package.py b/var/spack/repos/builtin/packages/caliper/package.py index 37cd8a33e8..143ee2253d 100644 --- a/var/spack/repos/builtin/packages/caliper/package.py +++ b/var/spack/repos/builtin/packages/caliper/package.py @@ -6,8 +6,6 @@ import os import sys -from llnl.util import tty - from spack.package import * @@ -149,44 +147,31 @@ class Caliper(CMakePackage, CudaPackage, ROCmPackage): install test subdirectory for use during `spack test run`.""" self.cache_extra_test_sources([join_path("examples", "apps")]) - def run_cxx_example_test(self): - """Run stand alone test: cxx_example""" + def test_cxx_example(self): + """build and run cxx-example""" - test_dir = self.test_suite.current_test_cache_dir.examples.apps exe = "cxx-example" - source_file = "cxx-example.cpp" - - if not os.path.isfile(join_path(test_dir, source_file)): - tty.warn("Skipping caliper test:" "{0} does not exist".format(source_file)) - return - - if os.path.exists(self.prefix.lib): - lib_dir = self.prefix.lib - else: - lib_dir = self.prefix.lib64 - - options = [ - "-L{0}".format(lib_dir), - "-I{0}".format(self.prefix.include), - "{0}".format(join_path(test_dir, source_file)), - "-o", - exe, - "-std=c++11", - "-lcaliper", - "-lstdc++", - ] - - if not self.run_test( - exe=os.environ["CXX"], - options=options, - purpose="test: compile {0} example".format(exe), - work_dir=test_dir, - ): - tty.warn("Skipping caliper test: failed to compile example") - return - - if not self.run_test(exe, purpose="test: run {0} example".format(exe), work_dir=test_dir): - tty.warn("Skipping caliper test: failed to run example") - - def test(self): - self.run_cxx_example_test() + source_file = "{0}.cpp".format(exe) + + source_path = find_required_file( + self.test_suite.current_test_cache_dir, source_file, expected=1, recursive=True + ) + + lib_dir = self.prefix.lib if os.path.exists(self.prefix.lib) else self.prefix.lib64 + + cxx = which(os.environ["CXX"]) + test_dir = os.path.dirname(source_path) + with working_dir(test_dir): + cxx( + "-L{0}".format(lib_dir), + "-I{0}".format(self.prefix.include), + source_path, + "-o", + exe, + "-std=c++11", + "-lcaliper", + "-lstdc++", + ) + + cxx_example = which(exe) + cxx_example() -- cgit v1.2.3-70-g09d2