Make testing spack commands simpler (#4868)

Adds SpackCommand class allowing Spack commands to be easily in Python

Example usage:

    from spack.main import SpackCommand
    info = SpackCommand('info')
    out, err = info('mpich')
    print(info.returncode)

This allows easier testing of Spack commands.

Also:
* Simplify command tests
* Simplify mocking in command tests.
* Simplify module command test
* Simplify python command test
* Simplify uninstall command test
* Simplify url command test
* SpackCommand uses more compatible output redirection
This commit is contained in:
Todd Gamblin
2017-07-22 21:27:54 -07:00
committed by GitHub
parent c07d93a3e5
commit f159246d1d
13 changed files with 299 additions and 398 deletions

View File

@@ -26,7 +26,7 @@
class A(AutotoolsPackage):
"""Simple package with no dependencies"""
"""Simple package with one optional dependency"""
homepage = "http://www.example.com"
url = "http://www.example.com/a-1.0.tar.gz"

View File

@@ -41,4 +41,4 @@ class Libdwarf(Package):
depends_on("libelf")
def install(self, spec, prefix):
pass
touch(prefix.libdwarf)

View File

@@ -34,11 +34,4 @@ class Libelf(Package):
version('0.8.10', '9db4d36c283d9790d8fa7df1f4d7b4d9')
def install(self, spec, prefix):
configure("--prefix=%s" % prefix,
"--enable-shared",
"--disable-dependency-tracking",
"--disable-debug")
make()
# The mkdir commands in libelf's intsall can fail in parallel
make("install", parallel=False)
touch(prefix.libelf)