summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2023-12-27 23:52:19 -0800
committerGitHub <noreply@github.com>2023-12-28 08:52:19 +0100
commit6855512301eb04ecef4e39d65ba838a53c3f0dcb (patch)
tree1246893e01e0aa6384571a4f73a3a761b11925e7 /lib
parentf721d4c6256c05e40e5b71d8ae570e55ec3d9825 (diff)
downloadspack-6855512301eb04ecef4e39d65ba838a53c3f0dcb.tar.gz
spack-6855512301eb04ecef4e39d65ba838a53c3f0dcb.tar.bz2
spack-6855512301eb04ecef4e39d65ba838a53c3f0dcb.tar.xz
spack-6855512301eb04ecef4e39d65ba838a53c3f0dcb.zip
gc tests: replace `find()` with DB query (#41876)
Per https://github.com/spack/spack/pull/41731#discussion_r1434827924, This cleans up the tests for `spack gc` by replacing ```python assert <string> in find() ``` with the more precise ```python assert mutable_database.query_local(<string>) ```
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/cmd/gc.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/spack/spack/test/cmd/gc.py b/lib/spack/spack/test/cmd/gc.py
index 9defb9d99c..1e4ca684e9 100644
--- a/lib/spack/spack/test/cmd/gc.py
+++ b/lib/spack/spack/test/cmd/gc.py
@@ -13,7 +13,6 @@ import spack.spec
gc = spack.main.SpackCommand("gc")
add = spack.main.SpackCommand("add")
install = spack.main.SpackCommand("install")
-find = spack.main.SpackCommand("find")
pytestmark = pytest.mark.not_on_windows("does not run on windows")
@@ -50,7 +49,7 @@ def test_gc_with_environment(config, mutable_database, mutable_mock_env_path):
with e:
add("cmake")
install()
- assert "cmake" in find()
+ assert mutable_database.query_local("cmake")
output = gc("-y")
assert "Restricting garbage collection" in output
assert "There are no unused specs" in output
@@ -66,13 +65,13 @@ def test_gc_with_build_dependency_in_environment(config, mutable_database, mutab
with e:
add("simple-inheritance")
install()
- assert "simple-inheritance" in find()
+ assert mutable_database.query_local("simple-inheritance")
output = gc("-yb")
assert "Restricting garbage collection" in output
assert "There are no unused specs" in output
with e:
- assert "simple-inheritance" in find()
+ assert mutable_database.query_local("simple-inheritance")
output = gc("-y")
assert "Restricting garbage collection" in output
assert "Successfully uninstalled cmake" in output
@@ -84,23 +83,23 @@ def test_gc_except_any_environments(config, mutable_database, mutable_mock_env_p
s.concretize()
s.package.do_install(fake=True, explicit=True)
- assert "zmpi" in find()
+ assert mutable_database.query_local("zmpi")
e = ev.create("test_gc")
with e:
add("simple-inheritance")
install()
- assert "simple-inheritance" in find()
+ assert mutable_database.query_local("simple-inheritance")
output = gc("-yE")
assert "Restricting garbage collection" not in output
assert "Successfully uninstalled zmpi" in output
- assert "zmpi" not in find()
+ assert not mutable_database.query_local("zmpi")
with e:
output = gc("-yE")
assert "Restricting garbage collection" not in output
- assert "There are no unused specs" not in find()
+ assert "There are no unused specs" not in output
@pytest.mark.db
@@ -109,18 +108,18 @@ def test_gc_except_specific_environments(config, mutable_database, mutable_mock_
s.concretize()
s.package.do_install(fake=True, explicit=True)
- assert "zmpi" in find()
+ assert mutable_database.query_local("zmpi")
e = ev.create("test_gc")
with e:
add("simple-inheritance")
install()
- assert "simple-inheritance" in find()
+ assert mutable_database.query_local("simple-inheritance")
output = gc("-ye", "test_gc")
assert "Restricting garbage collection" not in output
assert "Successfully uninstalled zmpi" in output
- assert "zmpi" not in find()
+ assert not mutable_database.query_local("zmpi")
@pytest.mark.db
@@ -136,15 +135,15 @@ def test_gc_except_specific_dir_env(config, mutable_database, mutable_mock_env_p
s.concretize()
s.package.do_install(fake=True, explicit=True)
- assert "zmpi" in find()
+ assert mutable_database.query_local("zmpi")
e = ev.create_in_dir(tmpdir.strpath)
with e:
add("simple-inheritance")
install()
- assert "simple-inheritance" in find()
+ assert mutable_database.query_local("simple-inheritance")
output = gc("-ye", tmpdir.strpath)
assert "Restricting garbage collection" not in output
assert "Successfully uninstalled zmpi" in output
- assert "zmpi" not in find()
+ assert not mutable_database.query_local("zmpi")