Skip to content

Commit

Permalink
kokkos: new test API (spack#45010)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
AcriusWinter and tldahlgren authored Jul 26, 2024
1 parent 564155f commit 1e6bef0
Showing 1 changed file with 10 additions and 46 deletions.
56 changes: 10 additions & 46 deletions var/spack/repos/builtin/packages/kokkos/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *

Expand Down Expand Up @@ -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
Expand All @@ -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")

cmake = self.spec["cmake"].command
cmake(cmake_path, "-DEXECUTABLE_OUTPUT_PATH=" + cmake_path)

self.build_tests(cmake_path)
self.run_tests(cmake_path)
make = which("make")
make()
make(cmake_path, "test")

0 comments on commit 1e6bef0

Please sign in to comment.