diff options
author | Richarda Butler <39577672+RikkiButler20@users.noreply.github.com> | 2022-03-30 18:39:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-30 18:39:41 -0700 |
commit | 63b981dba41e51a65608c2794f413cc6f483f611 (patch) | |
tree | d10b91efa9caa8ec22c66dc9322f2b355b4c903a /var | |
parent | 685e3d7ae9b968aa429c08a642aba4e718e0b419 (diff) | |
download | spack-63b981dba41e51a65608c2794f413cc6f483f611.tar.gz spack-63b981dba41e51a65608c2794f413cc6f483f611.tar.bz2 spack-63b981dba41e51a65608c2794f413cc6f483f611.tar.xz spack-63b981dba41e51a65608c2794f413cc6f483f611.zip |
Bugfix: Kokkos stand alone test (#29403)
* Use the cmake in the user's path
* Use test_suite cache
* Clean up the code
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/kokkos/package.py | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/var/spack/repos/builtin/packages/kokkos/package.py b/var/spack/repos/builtin/packages/kokkos/package.py index c2b37ec00c..aea3eca8b0 100644 --- a/var/spack/repos/builtin/packages/kokkos/package.py +++ b/var/spack/repos/builtin/packages/kokkos/package.py @@ -4,6 +4,8 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os.path +from llnl.util import tty + from spack import * @@ -292,7 +294,21 @@ class Kokkos(CMakePackage, CudaPackage, ROCmPackage): return options - test_script_relative_path = "scripts/spack_test" + 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): @@ -311,28 +327,43 @@ class Kokkos(CMakePackage, CudaPackage, ROCmPackage): "-DSPACK_PACKAGE_INSTALL_DIR:PATH={0}".format(self.prefix)] cmake(*cmake_args) self.cache_extra_test_sources(cmake_out_path) + self.cmake_bin(set=True) - def build_tests(self): + def build_tests(self, cmake_path): """Build test.""" - cmake_path = join_path(self.install_test_root, - self.test_script_relative_path, 'out') + 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] - cmake(*cmake_args) - make() - def run_tests(self): + 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.""" - reason = 'Checking ability to execute.' - run_path = join_path(self.install_test_root, - self.test_script_relative_path, 'out') - self.run_test('make', [run_path, 'test'], [], installed=False, purpose=reason) + 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 - cmake_path = join_path(self.install_test_root, + cmake_path = join_path(self.test_suite.current_test_cache_dir, self.test_script_relative_path, 'out') + if not os.path.exists(cmake_path): - print('Skipping smoke tests: {0} is missing'.format(cmake_path)) + tty.warn('Skipping smoke tests: {0} is missing'.format(cmake_path)) return - self.build_tests() - self.run_tests() + + self.build_tests(cmake_path) + self.run_tests(cmake_path) |