kokkos: new test API (#45010)
* kokkos: new test API * kokkos: added import llnl.util.lang as lang because earlier versions couldn't be installed without it --------- Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
This commit is contained in:
parent
564155fd1a
commit
1e6bef079d
@ -4,7 +4,7 @@
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
import os.path
|
||||
|
||||
from llnl.util import lang, tty
|
||||
import llnl.util.lang as lang
|
||||
|
||||
from spack.package import *
|
||||
|
||||
@ -378,20 +378,6 @@ def cmake_args(self):
|
||||
|
||||
test_script_relative_path = join_path("scripts", "spack_test")
|
||||
|
||||
# TODO: Replace this method and its 'get' use for cmake path with
|
||||
# join_path(self.spec['cmake'].prefix.bin, 'cmake') once stand-alone
|
||||
# tests can access build dependencies through self.spec['cmake'].
|
||||
def cmake_bin(self, set=True):
|
||||
"""(Hack) Set/get cmake dependency path."""
|
||||
filepath = join_path(self.install_test_root, "cmake_bin_path.txt")
|
||||
if set:
|
||||
with open(filepath, "w") as out_file:
|
||||
cmake_bin = join_path(self.spec["cmake"].prefix.bin, "cmake")
|
||||
out_file.write("{0}\n".format(cmake_bin))
|
||||
elif os.path.isfile(filepath):
|
||||
with open(filepath, "r") as in_file:
|
||||
return in_file.read().strip()
|
||||
|
||||
@run_after("install")
|
||||
def setup_build_tests(self):
|
||||
# Skip if unsupported version
|
||||
@ -410,41 +396,19 @@ def setup_build_tests(self):
|
||||
]
|
||||
cmake(*cmake_args)
|
||||
self.cache_extra_test_sources(cmake_out_path)
|
||||
self.cmake_bin(set=True)
|
||||
|
||||
def build_tests(self, cmake_path):
|
||||
"""Build test."""
|
||||
cmake_bin = self.cmake_bin(set=False)
|
||||
|
||||
if not cmake_bin:
|
||||
tty.msg("Skipping kokkos test: cmake_bin_path.txt not found")
|
||||
return
|
||||
|
||||
cmake_args = [cmake_path, "-DEXECUTABLE_OUTPUT_PATH=" + cmake_path]
|
||||
|
||||
if not self.run_test(cmake_bin, options=cmake_args, purpose="Generate the Makefile"):
|
||||
tty.warn("Skipping kokkos test: failed to generate Makefile")
|
||||
return
|
||||
|
||||
if not self.run_test("make", purpose="Build test software"):
|
||||
tty.warn("Skipping kokkos test: failed to build test")
|
||||
|
||||
def run_tests(self, cmake_path):
|
||||
"""Run test."""
|
||||
if not self.run_test(
|
||||
"make", options=[cmake_path, "test"], purpose="Checking ability to execute."
|
||||
):
|
||||
tty.warn("Failed to run kokkos test")
|
||||
|
||||
def test(self):
|
||||
# Skip if unsupported version
|
||||
def test_run(self):
|
||||
"""Test if kokkos builds and runs"""
|
||||
cmake_path = join_path(
|
||||
self.test_suite.current_test_cache_dir, self.test_script_relative_path, "out"
|
||||
)
|
||||
|
||||
if not os.path.exists(cmake_path):
|
||||
tty.warn("Skipping smoke tests: {0} is missing".format(cmake_path))
|
||||
return
|
||||
raise SkipTest(f"{cmake_path} is missing")
|
||||
|
||||
self.build_tests(cmake_path)
|
||||
self.run_tests(cmake_path)
|
||||
cmake = self.spec["cmake"].command
|
||||
cmake(cmake_path, "-DEXECUTABLE_OUTPUT_PATH=" + cmake_path)
|
||||
|
||||
make = which("make")
|
||||
make()
|
||||
make(cmake_path, "test")
|
||||
|
Loading…
Reference in New Issue
Block a user