From 34c1d196a45cc0c81e929b834c6de03a31848bf8 Mon Sep 17 00:00:00 2001 From: "Mark W. Krentel" Date: Fri, 3 Dec 2021 14:52:34 -0600 Subject: [PATCH] hpctoolkit: add support for smoke tests (#27783) This adds support in spack for both build/install tests (spack install --run-tests) and post-install smoke tests (spack test run). Hpctoolkit itself only recently added tests, so for now, this only applies to branch master. --- .../builtin/packages/hpctoolkit/package.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/var/spack/repos/builtin/packages/hpctoolkit/package.py b/var/spack/repos/builtin/packages/hpctoolkit/package.py index 42eaf1aba9..f7d188932b 100644 --- a/var/spack/repos/builtin/packages/hpctoolkit/package.py +++ b/var/spack/repos/builtin/packages/hpctoolkit/package.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import llnl.util.tty as tty + from spack import * @@ -20,6 +22,8 @@ class Hpctoolkit(AutotoolsPackage): tags = ['e4s'] + test_requires_compiler = True + version('develop', branch='develop') version('master', branch='master') version('2021.10.15', commit='a8f289e4dc87ff98e05cfc105978c09eb2f5ea16') @@ -202,3 +206,36 @@ def setup_run_environment(self, env): if '+viewer' in spec: env.prepend_path('PATH', spec['hpcviewer'].prefix.bin) env.prepend_path('MANPATH', spec['hpcviewer'].prefix.share.man) + + # Build tests (spack install --run-tests). Disable the default + # spack tests and run autotools 'make check', but only from the + # tests directory. + build_time_test_callbacks = [] + install_time_test_callbacks = [] + + @run_after('install') + @on_package_attributes(run_tests=True) + def check_install(self): + if self.spec.satisfies('@master'): + with working_dir('tests'): + make('check') + else: + tty.warn('spack test for hpctoolkit requires branch master') + + # Post-Install tests (spack test run). These are the same tests + # but with a different Makefile that works outside the build + # directory. + @run_after('install') + def copy_test_files(self): + if self.spec.satisfies('@master'): + self.cache_extra_test_sources(['tests']) + + def test(self): + test_dir = join_path(self.test_suite.current_test_cache_dir, 'tests') + if self.spec.satisfies('@master'): + with working_dir(test_dir): + make('-f', 'Makefile.spack', 'all') + self.run_test('./run-sort', status=[0], installed=False, + purpose='selection sort unit test') + else: + tty.warn('spack test for hpctoolkit requires branch master')