Stand-alone/Smoke tests: copy cached test sources to test stage (#23713)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
|
||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
from spack import *
|
||||
|
||||
|
||||
class TrivialSmokeTest(Package):
|
||||
"""This package is a stub with trivial smoke test features."""
|
||||
homepage = "http://www.example.com/trivial_test"
|
||||
url = "http://www.unit-test-should-replace-this-url/trivial_test-1.0.tar.gz"
|
||||
|
||||
version('1.0', 'foobarbaz')
|
||||
|
||||
test_source_filename = 'cached_file.in'
|
||||
|
||||
@run_before('install')
|
||||
def create_extra_test_source(self):
|
||||
mkdirp(self.install_test_root)
|
||||
touch(join_path(self.install_test_root, self.test_source_filename))
|
||||
|
||||
@run_after('install')
|
||||
def copy_test_sources(self):
|
||||
self.cache_extra_test_sources([self.test_source_filename])
|
@@ -220,26 +220,36 @@ def install(self, spec, prefix):
|
||||
'-rhsone')
|
||||
make("install")
|
||||
|
||||
extra_install_tests = join_path('src', 'examples')
|
||||
|
||||
@run_after('install')
|
||||
def cache_test_sources(self):
|
||||
srcs = ['src/examples']
|
||||
self.cache_extra_test_sources(srcs)
|
||||
self.cache_extra_test_sources(self.extra_install_tests)
|
||||
|
||||
@property
|
||||
def _cached_tests_work_dir(self):
|
||||
"""The working directory for cached test sources."""
|
||||
return join_path(self.test_suite.current_test_cache_dir,
|
||||
self.extra_install_tests)
|
||||
|
||||
def test(self):
|
||||
"""Perform smoke test on installed HYPRE package."""
|
||||
if '+mpi' not in self.spec:
|
||||
print('Skipping: HYPRE must be installed with +mpi to run tests')
|
||||
return
|
||||
|
||||
if '+mpi' in self.spec:
|
||||
examples_dir = join_path(self.install_test_root, 'src/examples')
|
||||
with working_dir(examples_dir, create=False):
|
||||
make("HYPRE_DIR=" + self.prefix, "bigint")
|
||||
# Build copied and cached test examples
|
||||
self.run_test('make',
|
||||
['HYPRE_DIR={0}'.format(self.prefix), 'bigint'],
|
||||
purpose='test: building selected examples',
|
||||
work_dir=self._cached_tests_work_dir)
|
||||
|
||||
reason = "test: ensuring HYPRE examples run"
|
||||
self.run_test('./ex5big', [], [], installed=True,
|
||||
purpose=reason, skip_missing=True, work_dir='.')
|
||||
self.run_test('./ex15big', [], [], installed=True,
|
||||
purpose=reason, skip_missing=True, work_dir='.')
|
||||
|
||||
make("distclean")
|
||||
# Run the examples built above
|
||||
for exe in ['./ex5big', './ex15big']:
|
||||
self.run_test(exe, [], [], installed=False,
|
||||
purpose='test: ensuring {0} runs'.format(exe),
|
||||
skip_missing=True,
|
||||
work_dir=self._cached_tests_work_dir)
|
||||
|
||||
@property
|
||||
def headers(self):
|
||||
|
@@ -891,9 +891,10 @@ def _test_bin_ops(self):
|
||||
'shmemrun': ls,
|
||||
}
|
||||
|
||||
for exe in checks:
|
||||
options, expected, status = checks[exe]
|
||||
reason = 'test: checking {0} output'.format(exe)
|
||||
for binary in checks:
|
||||
options, expected, status = checks[binary]
|
||||
exe = join_path(self.prefix.bin, binary)
|
||||
reason = 'test: checking {0} output'.format(binary)
|
||||
self.run_test(exe, options, expected, status, installed=True,
|
||||
purpose=reason, skip_missing=True)
|
||||
|
||||
@@ -942,36 +943,28 @@ def _test_check_versions(self):
|
||||
'shmemcxx': comp_vers,
|
||||
}
|
||||
|
||||
for exe in checks:
|
||||
expected = checks[exe]
|
||||
for binary in checks:
|
||||
expected = checks[binary]
|
||||
purpose = 'test: ensuring version of {0} is {1}' \
|
||||
.format(exe, expected)
|
||||
.format(binary, expected)
|
||||
exe = join_path(self.prefix.bin, binary)
|
||||
self.run_test(exe, '--version', expected, installed=True,
|
||||
purpose=purpose, skip_missing=True)
|
||||
|
||||
def _test_build_examples(self):
|
||||
# Build the examples copied during installation and return "status"
|
||||
reason = 'test: ensuring ability to build the examples'
|
||||
return self.run_test('make', ['all'], [],
|
||||
purpose=reason,
|
||||
work_dir=join_path(self.install_test_root,
|
||||
self.extra_install_tests))
|
||||
|
||||
def _test_clean_examples(self):
|
||||
# Clean up any example build files
|
||||
reason = 'test: ensuring copied examples cleaned up'
|
||||
return self.run_test('make', ['clean'], [],
|
||||
purpose=reason,
|
||||
work_dir=join_path(self.install_test_root,
|
||||
self.extra_install_tests))
|
||||
@property
|
||||
def _cached_tests_work_dir(self):
|
||||
"""The working directory for cached test sources."""
|
||||
return join_path(self.test_suite.current_test_cache_dir,
|
||||
self.extra_install_tests)
|
||||
|
||||
def _test_examples(self):
|
||||
# First ensure can build copied examples
|
||||
if not self._test_build_examples():
|
||||
self._test_clean_examples()
|
||||
return
|
||||
"""Run test examples copied from source at build-time."""
|
||||
# Build the copied, cached test examples
|
||||
self.run_test('make', ['all'], [],
|
||||
purpose='test: building cached test examples',
|
||||
work_dir=self._cached_tests_work_dir)
|
||||
|
||||
# Now run examples with known, simple-to-verify results
|
||||
# Run examples with known, simple-to-verify results
|
||||
have_spml = self.spec.satisfies('@2.0.0:2.1.6')
|
||||
|
||||
hello_world = (['Hello, world', 'I am', '0 of', '1'], 0)
|
||||
@@ -1015,14 +1008,11 @@ def _test_examples(self):
|
||||
.format(exe, status)
|
||||
self.run_test(exe, [], expected, status, installed=False,
|
||||
purpose=reason, skip_missing=True,
|
||||
work_dir=join_path(self.install_test_root,
|
||||
self.extra_install_tests))
|
||||
|
||||
self._test_clean_examples()
|
||||
work_dir=self._cached_tests_work_dir)
|
||||
|
||||
def test(self):
|
||||
"""Perform smoke tests on the installed package."""
|
||||
# Simple version check tests on known packages
|
||||
"""Perform stand-alone/smoke tests on the installed package."""
|
||||
# Simple version check tests on selected installed binaries
|
||||
self._test_check_versions()
|
||||
|
||||
# Test the operation of selected executables
|
||||
|
Reference in New Issue
Block a user