spack test (#15702)
Users can add test() methods to their packages to run smoke tests on installations with the new `spack test` command (the old `spack test` is now `spack unit-test`). spack test is environment-aware, so you can `spack install` an environment and then run `spack test run` to run smoke tests on all of its packages. Historical test logs can be perused with `spack test results`. Generic smoke tests for MPI implementations, C, C++, and Fortran compilers as well as specific smoke tests for 18 packages. Inside the test method, individual tests can be run separately (and continue to run best-effort after a test failure) using the `run_test` method. The `run_test` method encapsulates finding test executables, running and checking return codes, checking output, and error handling. This handles the following trickier aspects of testing with direct support in Spack's package API: - [x] Caching source or intermediate build files at build time for use at test time. - [x] Test dependencies, - [x] packages that require a compiler for testing (such as library only packages). See the packaging guide for more details on using Spack testing support. Included is support for package.py files for virtual packages. This does not change the Spack interface, but is a major change in internals. Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov> Co-authored-by: wspear <wjspear@gmail.com> Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
This commit is contained in:
@@ -56,7 +56,7 @@ contains 'hdf5' _spack_completions spack -d install --jobs 8 ''
|
||||
contains 'hdf5' _spack_completions spack install -v ''
|
||||
|
||||
# XFAIL: Fails for Python 2.6 because pkg_resources not found?
|
||||
#contains 'compilers.py' _spack_completions spack test ''
|
||||
#contains 'compilers.py' _spack_completions spack unit-test ''
|
||||
|
||||
title 'Testing debugging functions'
|
||||
|
||||
|
@@ -42,4 +42,4 @@ spack -p --lines 20 spec mpileaks%gcc ^elfutils@0.170
|
||||
#-----------------------------------------------------------
|
||||
# Run unit tests with code coverage
|
||||
#-----------------------------------------------------------
|
||||
$coverage_run $(which spack) test -x --verbose
|
||||
$coverage_run $(which spack) unit-test -x --verbose
|
||||
|
@@ -320,7 +320,7 @@ _spack() {
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help -H --all-help --color -C --config-scope -d --debug --timestamp --pdb -e --env -D --env-dir -E --no-env --use-env-repo -k --insecure -l --enable-locks -L --disable-locks -m --mock -p --profile --sorted-profile --lines -v --verbose --stacktrace -V --version --print-shell-vars"
|
||||
else
|
||||
SPACK_COMPREPLY="activate add arch blame build-env buildcache cd checksum ci clean clone commands compiler compilers concretize config containerize create deactivate debug dependencies dependents deprecate dev-build develop docs edit env extensions external fetch find flake8 gc gpg graph help info install license list load location log-parse maintainers mirror module patch pkg providers pydoc python reindex remove rm repo resource restage setup solve spec stage test tutorial undevelop uninstall unload url verify versions view"
|
||||
SPACK_COMPREPLY="activate add arch blame build-env buildcache cd checksum ci clean clone commands compiler compilers concretize config containerize create deactivate debug dependencies dependents deprecate dev-build develop docs edit env extensions external fetch find flake8 gc gpg graph help info install license list load location log-parse maintainers mirror module patch pkg providers pydoc python reindex remove rm repo resource restage setup solve spec stage test test-env tutorial undevelop uninstall unit-test unload url verify versions view"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1020,7 +1020,7 @@ _spack_info() {
|
||||
_spack_install() {
|
||||
if $list_options
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help --only -u --until -j --jobs --overwrite --fail-fast --keep-prefix --keep-stage --dont-restage --use-cache --no-cache --cache-only --no-check-signature --require-full-hash-match --show-log-on-error --source -n --no-checksum -v --verbose --fake --only-concrete -f --file --clean --dirty --test --run-tests --log-format --log-file --help-cdash -y --yes-to-all --cdash-upload-url --cdash-build --cdash-site --cdash-track --cdash-buildstamp"
|
||||
SPACK_COMPREPLY="-h --help --only -u --until -j --jobs --overwrite --fail-fast --keep-prefix --keep-stage --dont-restage --use-cache --no-cache --cache-only --no-check-signature --require-full-hash-match --show-log-on-error --source -n --no-checksum -v --verbose --fake --only-concrete -f --file --clean --dirty --test --run-tests --log-format --log-file --help-cdash --cdash-upload-url --cdash-build --cdash-site --cdash-track --cdash-buildstamp -y --yes-to-all"
|
||||
else
|
||||
_all_packages
|
||||
fi
|
||||
@@ -1046,7 +1046,7 @@ _spack_license_verify() {
|
||||
_spack_list() {
|
||||
if $list_options
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help -d --search-description --format --update -t --tags"
|
||||
SPACK_COMPREPLY="-h --help -d --search-description --format --update -v --virtuals -t --tags"
|
||||
else
|
||||
_all_packages
|
||||
fi
|
||||
@@ -1494,9 +1494,67 @@ _spack_stage() {
|
||||
_spack_test() {
|
||||
if $list_options
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help -H --pytest-help -l --list -L --list-long -N --list-names --extension -s -k --showlocals"
|
||||
SPACK_COMPREPLY="-h --help"
|
||||
else
|
||||
_tests
|
||||
SPACK_COMPREPLY="run list find status results remove"
|
||||
fi
|
||||
}
|
||||
|
||||
_spack_test_run() {
|
||||
if $list_options
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help --alias --fail-fast --fail-first --keep-stage --log-format --log-file --cdash-upload-url --cdash-build --cdash-site --cdash-track --cdash-buildstamp --help-cdash --clean --dirty"
|
||||
else
|
||||
_installed_packages
|
||||
fi
|
||||
}
|
||||
|
||||
_spack_test_list() {
|
||||
SPACK_COMPREPLY="-h --help"
|
||||
}
|
||||
|
||||
_spack_test_find() {
|
||||
if $list_options
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help"
|
||||
else
|
||||
_all_packages
|
||||
fi
|
||||
}
|
||||
|
||||
_spack_test_status() {
|
||||
if $list_options
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help"
|
||||
else
|
||||
SPACK_COMPREPLY=""
|
||||
fi
|
||||
}
|
||||
|
||||
_spack_test_results() {
|
||||
if $list_options
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help -l --logs -f --failed"
|
||||
else
|
||||
SPACK_COMPREPLY=""
|
||||
fi
|
||||
}
|
||||
|
||||
_spack_test_remove() {
|
||||
if $list_options
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help -y --yes-to-all"
|
||||
else
|
||||
SPACK_COMPREPLY=""
|
||||
fi
|
||||
}
|
||||
|
||||
_spack_test_env() {
|
||||
if $list_options
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help --clean --dirty --dump --pickle"
|
||||
else
|
||||
_all_packages
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1522,6 +1580,15 @@ _spack_uninstall() {
|
||||
fi
|
||||
}
|
||||
|
||||
_spack_unit_test() {
|
||||
if $list_options
|
||||
then
|
||||
SPACK_COMPREPLY="-h --help -H --pytest-help -l --list -L --list-long -N --list-names --extension -s -k --showlocals"
|
||||
else
|
||||
_tests
|
||||
fi
|
||||
}
|
||||
|
||||
_spack_unload() {
|
||||
if $list_options
|
||||
then
|
||||
|
27
share/spack/templates/reports/cdash/Test.xml
Normal file
27
share/spack/templates/reports/cdash/Test.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<Test>
|
||||
<StartTestTime>{{ test.starttime }}</StartTestTime>
|
||||
<TestCommand>{{ install_command }}</TestCommand>
|
||||
{% for warning in test.warnings %}
|
||||
<Warning>
|
||||
<TestLogLine>{{ warning.line_no }}</TestLogLine>
|
||||
<Text>{{ warning.text }}</Text>
|
||||
<SourceFile>{{ warning.source_file }}</SourceFile>
|
||||
<SourceLineNumber>{{ warning.source_line_no }}</SourceLineNumber>
|
||||
<PreContext>{{ warning.pre_context }}</PreContext>
|
||||
<PostContext>{{ warning.post_context }}</PostContext>
|
||||
</Warning>
|
||||
{% endfor %}
|
||||
{% for error in test.errors %}
|
||||
<Error>
|
||||
<TestLogLine>{{ error.line_no }}</TestLogLine>
|
||||
<Text>{{ error.text }}</Text>
|
||||
<SourceFile>{{ error.source_file }}</SourceFile>
|
||||
<SourceLineNumber>{{ error.source_line_no }}</SourceLineNumber>
|
||||
<PreContext>{{ error.pre_context }}</PreContext>
|
||||
<PostContext>{{ error.post_context }}</PostContext>
|
||||
</Error>
|
||||
{% endfor %}
|
||||
<EndTestTime>{{ test.endtime }}</EndTestTime>
|
||||
<ElapsedMinutes>0</ElapsedMinutes>
|
||||
</Test>
|
||||
</Site>
|
Reference in New Issue
Block a user