summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2020-11-12 15:55:34 -0800
committerGitHub <noreply@github.com>2020-11-12 15:55:34 -0800
commit32bfe0a001d409e90bf4c81bde05f46ca9146ec4 (patch)
tree4e2b77c25b108649c625f9b29fe6029f49c18eb8
parentca3b91270361c5f0561bf297bc999ca2de670946 (diff)
downloadspack-32bfe0a001d409e90bf4c81bde05f46ca9146ec4.tar.gz
spack-32bfe0a001d409e90bf4c81bde05f46ca9146ec4.tar.bz2
spack-32bfe0a001d409e90bf4c81bde05f46ca9146ec4.tar.xz
spack-32bfe0a001d409e90bf4c81bde05f46ca9146ec4.zip
Testing: ensure that all packages can be pickled (#19890)
As of #18205, all packages must be pickle-able to be installed by Spack. This adds a test to check that each package can be pickled. If any package fails to pickle, the test keeps going and collects the names of all failed packages; it then takes the first one that failed and attempts to re-pickle it, generating the full stack trace for the failed pickle attempt.
-rw-r--r--lib/spack/spack/test/package_sanity.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/spack/spack/test/package_sanity.py b/lib/spack/spack/test/package_sanity.py
index 2496bc99b7..6475b3377e 100644
--- a/lib/spack/spack/test/package_sanity.py
+++ b/lib/spack/spack/test/package_sanity.py
@@ -18,6 +18,9 @@ import spack.util.executable as executable
# do sanity checks only on packagess modified by a PR
import spack.cmd.flake8 as flake8
import spack.util.crypto as crypto
+import pickle
+
+import llnl.util.tty as tty
def check_repo():
@@ -32,6 +35,27 @@ def test_get_all_packages():
check_repo()
+def test_packages_are_pickleable():
+ failed_to_pickle = list()
+ for name in spack.repo.all_package_names():
+ pkg = spack.repo.get(name)
+ try:
+ pickle.dumps(pkg)
+ except Exception:
+ # If there are any failures, keep track of all packages that aren't
+ # pickle-able and re-run the pickling later on to recreate the
+ # error
+ failed_to_pickle.append(name)
+
+ if failed_to_pickle:
+ tty.msg('The following packages failed to pickle: ' +
+ ', '.join(failed_to_pickle))
+
+ for name in failed_to_pickle:
+ pkg = spack.repo.get(name)
+ pickle.dumps(pkg)
+
+
def test_get_all_mock_packages():
"""Get the mock packages once each too."""
db = spack.repo.RepoPath(spack.paths.mock_packages_path)