pkg grep
: use capfd
instead of executable for tests
This commit is contained in:
parent
8035eeb36d
commit
aa3b6e598f
@ -297,19 +297,19 @@ def test_pkg_hash(mock_packages):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not spack.cmd.pkg.get_grep(), reason="grep is not installed")
|
@pytest.mark.skipif(not spack.cmd.pkg.get_grep(), reason="grep is not installed")
|
||||||
def test_pkg_grep(mock_packages, capsys):
|
def test_pkg_grep(mock_packages, capfd):
|
||||||
# only splice-* mock packages have the string "splice" in them
|
# only splice-* mock packages have the string "splice" in them
|
||||||
with capsys.disabled():
|
pkg("grep", "-l", "splice", output=str)
|
||||||
output = pkg("grep", "-l", "splice", output=str)
|
output, _ = capfd.readouterr()
|
||||||
|
|
||||||
assert output.strip() == "\n".join(
|
assert output.strip() == "\n".join(
|
||||||
spack.repo.path.get_pkg_class(name).module.__file__
|
spack.repo.path.get_pkg_class(name).module.__file__
|
||||||
for name in ["splice-a", "splice-h", "splice-t", "splice-vh", "splice-z"]
|
for name in ["splice-a", "splice-h", "splice-t", "splice-vh", "splice-z"]
|
||||||
)
|
)
|
||||||
|
|
||||||
# ensure that this string isn't fouhnd
|
# ensure that this string isn't fouhnd
|
||||||
output = pkg("grep", "abcdefghijklmnopqrstuvwxyz", output=str, fail_on_error=False)
|
pkg("grep", "abcdefghijklmnopqrstuvwxyz", output=str, fail_on_error=False)
|
||||||
assert pkg.returncode == 1
|
assert pkg.returncode == 1
|
||||||
|
output, _ = capfd.readouterr()
|
||||||
assert output.strip() == ""
|
assert output.strip() == ""
|
||||||
|
|
||||||
# ensure that we return > 1 for an error
|
# ensure that we return > 1 for an error
|
||||||
|
Loading…
Reference in New Issue
Block a user