summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2021-07-27 14:47:44 -0700
committerMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-08-03 10:07:11 +0200
commit693c4d8f3ad59dd8d9efa750398510e4a7f0f4ae (patch)
treec8e014084ecced6aeb152815d4eeb81b35b5deeb /lib
parent507d3c841cd2c8c0120aa1928ea25be930857f9c (diff)
downloadspack-693c4d8f3ad59dd8d9efa750398510e4a7f0f4ae.tar.gz
spack-693c4d8f3ad59dd8d9efa750398510e4a7f0f4ae.tar.bz2
spack-693c4d8f3ad59dd8d9efa750398510e4a7f0f4ae.tar.xz
spack-693c4d8f3ad59dd8d9efa750398510e4a7f0f4ae.zip
spack style: improve tests for failure cases
This fixes the bad bootstrap test for spack style, and it refines the asserrtions on other failure cases.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/cmd/style.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/spack/spack/test/cmd/style.py b/lib/spack/spack/test/cmd/style.py
index 65a301bc27..af0fc47d24 100644
--- a/lib/spack/spack/test/cmd/style.py
+++ b/lib/spack/spack/test/cmd/style.py
@@ -129,14 +129,15 @@ def test_changed_files_all_files(flake8_package):
@pytest.mark.skipif(sys.version_info >= (3, 6), reason="doesn't apply to newer python")
def test_fail_on_old_python():
"""Ensure that `spack style` runs but fails with older python."""
- style(fail_on_error=False)
- assert style.returncode != 0
+ output = style(fail_on_error=False)
+ assert "spack style requires Python 3.6" in output
@skip_old_python
def test_bad_root(tmpdir):
"""Ensure that `spack style` doesn't run on non-spack directories."""
- style("--root", str(tmpdir), fail_on_error=False)
+ output = style("--root", str(tmpdir), fail_on_error=False)
+ assert "This does not look like a valid spack root" in output
assert style.returncode != 0
@@ -156,10 +157,12 @@ def test_style_is_package(tmpdir):
def test_bad_bootstrap(monkeypatch):
"""Ensure we fail gracefully when we can't bootstrap spack style."""
monkeypatch.setattr(spack.cmd.style, "tool_order", [
- ("foobartool", "foobartool"), # bad package to force concretization failure
+ ("isort", "py-isort@4.3:4.0"), # bad spec to force concretization failure
])
- style(fail_on_error=False)
- assert style.returncode != 0
+ # zero out path to ensure we don't find isort
+ with pytest.raises(spack.error.SpackError) as e:
+ style(env={"PATH": ""})
+ assert "Couldn't bootstrap isort" in str(e)
@pytest.fixture