1. Added CommandError exception to build_environment
2. The parent of a failed child process in build_environment.fork no longer calls sys.exit - instead it raises a CommandError (from [1]) 3. test-install command now attempts to install all packages even if one fails
This commit is contained in:
parent
246423b4b4
commit
ea872f8098
@ -296,4 +296,8 @@ def child_fun():
|
|||||||
# message. Just make the parent exit with an error code.
|
# message. Just make the parent exit with an error code.
|
||||||
pid, returncode = os.waitpid(pid, 0)
|
pid, returncode = os.waitpid(pid, 0)
|
||||||
if returncode != 0:
|
if returncode != 0:
|
||||||
sys.exit(1)
|
raise CommandError(returncode)
|
||||||
|
|
||||||
|
|
||||||
|
class CommandError(StandardError):
|
||||||
|
pass
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
from llnl.util.filesystem import *
|
from llnl.util.filesystem import *
|
||||||
|
|
||||||
import spack
|
import spack
|
||||||
|
from spack.build_environment import CommandError
|
||||||
import spack.cmd
|
import spack.cmd
|
||||||
|
|
||||||
description = "Treat package installations as unit tests and output formatted test results"
|
description = "Treat package installations as unit tests and output formatted test results"
|
||||||
@ -107,7 +108,12 @@ def fetch_log(path):
|
|||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return list()
|
return list()
|
||||||
with open(path, 'rb') as F:
|
with open(path, 'rb') as F:
|
||||||
return list(F.readlines())
|
return list(line.strip() for line in F.readlines())
|
||||||
|
|
||||||
|
|
||||||
|
def failed_dependencies(spec):
|
||||||
|
return set(childSpec for childSpec in spec.dependencies.itervalues() if not
|
||||||
|
spack.db.get(childSpec).installed)
|
||||||
|
|
||||||
|
|
||||||
def create_test_output(topSpec, newInstalls, output, getLogFunc=fetch_log):
|
def create_test_output(topSpec, newInstalls, output, getLogFunc=fetch_log):
|
||||||
@ -117,9 +123,7 @@ def create_test_output(topSpec, newInstalls, output, getLogFunc=fetch_log):
|
|||||||
if spec not in newInstalls:
|
if spec not in newInstalls:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
failedDeps = set(childSpec for childSpec in
|
failedDeps = failed_dependencies(spec)
|
||||||
spec.dependencies.itervalues() if not
|
|
||||||
spack.db.get(childSpec).installed)
|
|
||||||
package = spack.db.get(spec)
|
package = spack.db.get(spec)
|
||||||
if failedDeps:
|
if failedDeps:
|
||||||
result = TestResult.SKIPPED
|
result = TestResult.SKIPPED
|
||||||
@ -172,10 +176,13 @@ def test_install(parser, args):
|
|||||||
else:
|
else:
|
||||||
outputFpath = args.output
|
outputFpath = args.output
|
||||||
|
|
||||||
try:
|
for spec in topSpec.traverse(order='post'):
|
||||||
for spec in specs:
|
# Calling do_install for the top-level package would be sufficient but
|
||||||
package = spack.db.get(spec)
|
# this attempts to keep going if any package fails (other packages which
|
||||||
if not package.installed:
|
# are not dependents may succeed)
|
||||||
|
package = spack.db.get(spec)
|
||||||
|
if (not failed_dependencies(spec)) and (not package.installed):
|
||||||
|
try:
|
||||||
package.do_install(
|
package.do_install(
|
||||||
keep_prefix=False,
|
keep_prefix=False,
|
||||||
keep_stage=True,
|
keep_stage=True,
|
||||||
@ -183,10 +190,12 @@ def test_install(parser, args):
|
|||||||
make_jobs=args.jobs,
|
make_jobs=args.jobs,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
fake=False)
|
fake=False)
|
||||||
finally:
|
except CommandError:
|
||||||
jrf = JunitResultFormat()
|
pass
|
||||||
handled = {}
|
|
||||||
create_test_output(topSpec, newInstalls, jrf)
|
jrf = JunitResultFormat()
|
||||||
|
handled = {}
|
||||||
|
create_test_output(topSpec, newInstalls, jrf)
|
||||||
|
|
||||||
with open(outputFpath, 'wb') as F:
|
with open(outputFpath, 'wb') as F:
|
||||||
jrf.write_to(F)
|
jrf.write_to(F)
|
||||||
|
Loading…
Reference in New Issue
Block a user