From 38a1036c46c14dd65aef7a8167d6443692920711 Mon Sep 17 00:00:00 2001 From: Richarda Butler <39577672+RikkiButler20@users.noreply.github.com> Date: Tue, 25 Jan 2022 17:10:28 -0800 Subject: Bugfix: Tasmanian stand alone test (#28496) --- .../repos/builtin/packages/tasmanian/package.py | 58 +++++++++++++++++++--- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/var/spack/repos/builtin/packages/tasmanian/package.py b/var/spack/repos/builtin/packages/tasmanian/package.py index bdfb680d77..a957f749f0 100644 --- a/var/spack/repos/builtin/packages/tasmanian/package.py +++ b/var/spack/repos/builtin/packages/tasmanian/package.py @@ -3,6 +3,10 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import os + +from llnl.util import tty + from spack import * @@ -153,10 +157,52 @@ class Tasmanian(CMakePackage, CudaPackage, ROCmPackage): return args + # 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_smoke_test(self): + if not self.spec['cmake'].satisfies('@3.10:'): + tty.msg('Error tasmanian test: CMake 3.10 or higher is required') + return + + install_tree(self.prefix.share.Tasmanian.testing, + join_path(self.install_test_root, 'testing')) + self.cmake_bin(set=True) + def test(self): - # using the tests installed in /share/Tasmanian/testing - cmake_dir = join_path(self.prefix, 'share', 'Tasmanian', 'testing') - with working_dir(self.test_suite.current_test_cache_dir, create=True): - cmake(cmake_dir) - make() - make('test') + cmake_bin = self.cmake_bin(set=False) + + if not cmake_bin: + tty.msg('Skipping tasmanian test: cmake_bin_path.txt not found') + return + + # using the tests copied from /share/Tasmanian/testing + cmake_dir = self.test_suite.current_test_cache_dir.testing + + if not self.run_test(cmake_bin, + options=[cmake_dir], + purpose='Generate the Makefile'): + tty.msg('Skipping tasmanian test: failed to generate Makefile') + return + + if not self.run_test('make', + purpose='Build test software'): + tty.msg('Skipping tasmanian test: failed to build test') + return + + if not self.run_test('make', + options=['test'], + purpose='Run test'): + tty.msg('Failed tasmanian test: failed to run test') -- cgit v1.2.3-60-g2f50