Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ Full contents:
tutorial_spack_scripting
tutorial_modules
tutorial_buildsystems
tutorial_testing
tutorial_advanced_packaging
3 changes: 3 additions & 0 deletions outputs/testing/cleanup.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ spack repo remove spack-tests
==> Removed repository /home/spack/spack/var/spack/repos/spack-tests with namespace 'spack-tests'.
$ rm -rf $SPACK_ROOT/var/spack/repos/spack-tests
2 changes: 2 additions & 0 deletions outputs/testing/repo-add.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ spack repo add $SPACK_ROOT/var/spack/repos/spack-tests/
==> Added repo with namespace 'tutorial'.
60 changes: 60 additions & 0 deletions tutorial_testing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.. 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)

.. include:: common/setup.rst

.. _testing-tutorial:

=========================
Package Testing Tutorial
=========================

This tutorial walks you through the steps for adding and running Spack
package tests during and after the software installation process. A package
that *appears* to install successfully may not actually be installed
correctly or continue to work indefinitely. There are a number of possible
reasons. For example, the installation process may not have fully installed
the software. The installed software may not work. Or the software may
work right after it is installed but, due to system changes, it stops
working days, weeks, or months later. So Spack provides features for
`checking installed software
<https://spack-tutorial.readthedocs.io/en/latest/tutorial_packaging.html>`_

Recall from `Package Creation
<https://spack-tutorial.readthedocs.io/en/latest/tutorial_packaging.html>`_
that Spack packages are installation scripts, or recipes, for building
software. As such, they are well suited for also encapsulating recipes
for testing the installed software.

Tests can be performed at two points in the life of an installed
package: build-time and stand-alone. **Build-time** tests run as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried/discovered both recently in spack/spack#25300

Currently, for spack test run /<spec> the spec needs to be loaded to work.

part of the package installation process. **Stand-alone** tests run
at any point after the software is installed.

---------------
Getting started
---------------

In order to avoid modifying your Spack instance with changes from this
tutorial, let's add a package repository called ``spack-tests``:

.. literalinclude:: outputs/testing/repo-add.out
:language: console

Doing this ensures changes we make here do not adversely affect other
parts of the tutorial. You can find out more about repositories at
`Package Repositories <https://spack.readthedocs.io/en/latest/repositories.html>`_.

-----------
Cleaning up
-----------

Before leaving, let's ensure what we have done does not interfere with your
Spack instance or future sections of the tutorial. Undo the work by entering
the following commands:

.. literalinclude:: outputs/testing/cleanup.out
:language: console