Use spec.traverse vs. recursive function.
Also even though I calculated which installs are new (e.g. vs. packages that have already been installed by a previous command) I forgot to make use of that in create_test_output (so I was always generating test output even if a package had been installed before running the test-install command). Note to avoid confusion: the 'handled' variable (removed in this commit) did not serve the same purpose as 'newInstalls': it was originally required because the recursive approach would visit the same dependency twice if more than one package depended on it.
This commit is contained in:
parent
f2b4341ad6
commit
b9bf0b942c
@ -81,18 +81,21 @@ def stringId(self):
|
|||||||
return "-".join(str(x) for x in (self.name, self.version, self.hashId))
|
return "-".join(str(x) for x in (self.name, self.version, self.hashId))
|
||||||
|
|
||||||
|
|
||||||
def create_test_output(spec, handled, output):
|
def create_test_output(topSpec, newInstalls, output):
|
||||||
if spec in handled:
|
# Post-order traversal is not strictly required but it makes sense to output
|
||||||
return handled[spec]
|
# tests for dependencies first.
|
||||||
|
for spec in topSpec.traverse(order='post'):
|
||||||
|
if spec not in newInstalls:
|
||||||
|
continue
|
||||||
|
|
||||||
childSuccesses = list(create_test_output(dep, handled, output)
|
if not all(spack.db.get(childSpec).installed for childSpec in
|
||||||
for dep in spec.dependencies.itervalues())
|
spec.dependencies.itervalues()):
|
||||||
package = spack.db.get(spec)
|
#TODO: create a failed test if a dependency didn't install?
|
||||||
handled[spec] = package.installed
|
continue
|
||||||
|
|
||||||
if all(childSuccesses):
|
|
||||||
bId = BuildId(spec.name, spec.version, spec.dag_hash())
|
bId = BuildId(spec.name, spec.version, spec.dag_hash())
|
||||||
|
|
||||||
|
package = spack.db.get(spec)
|
||||||
if package.installed:
|
if package.installed:
|
||||||
buildLogPath = spack.install_layout.build_log_path(spec)
|
buildLogPath = spack.install_layout.build_log_path(spec)
|
||||||
else:
|
else:
|
||||||
@ -106,9 +109,6 @@ def create_test_output(spec, handled, output):
|
|||||||
# lines. It may be better to look for errors.
|
# lines. It may be better to look for errors.
|
||||||
output.add_test(bId, package.installed, buildLogPath + '\n' +
|
output.add_test(bId, package.installed, buildLogPath + '\n' +
|
||||||
spec.to_yaml() + buildLog)
|
spec.to_yaml() + buildLog)
|
||||||
#TODO: create a failed test if a dependency didn't install?
|
|
||||||
|
|
||||||
return handled[spec]
|
|
||||||
|
|
||||||
|
|
||||||
def test_install(parser, args):
|
def test_install(parser, args):
|
||||||
@ -143,14 +143,10 @@ def test_install(parser, args):
|
|||||||
verbose=True,
|
verbose=True,
|
||||||
fake=False)
|
fake=False)
|
||||||
finally:
|
finally:
|
||||||
#Find all packages that are not a dependency of another package
|
|
||||||
topLevelNewInstalls = newInstalls - set(itertools.chain.from_iterable(
|
|
||||||
spec.dependencies for spec in newInstalls))
|
|
||||||
|
|
||||||
jrf = JunitResultFormat()
|
jrf = JunitResultFormat()
|
||||||
handled = {}
|
handled = {}
|
||||||
for spec in topLevelNewInstalls:
|
for spec in specs:
|
||||||
create_test_output(spec, handled, jrf)
|
create_test_output(spec, newInstalls, jrf)
|
||||||
|
|
||||||
with open(args.output, 'wb') as F:
|
with open(args.output, 'wb') as F:
|
||||||
jrf.write_to(F)
|
jrf.write_to(F)
|
||||||
|
Loading…
Reference in New Issue
Block a user