Skip to content

Commit

Permalink
Update tests to reflect new in-memory hashing vs. coarser dag_hash.
Browse files Browse the repository at this point in the history
- Spack currently not hashing build deps (to allow more reuse of packages
  and less frequent re-installing)

- Fast in-memory hash should still hash *all* deptypes, and installed
  specs will only reflect link and run deps.

- We'll revert this when we can concretize more liberally based on what
  is already installed.
  • Loading branch information
tgamblin committed Sep 1, 2016
1 parent 235a045 commit bee5c05
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lib/spack/spack/test/directory_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,33 @@ def test_read_and_write_spec(self):

# Make sure spec file can be read back in to get the original spec
spec_from_file = self.layout.read_spec(spec_path)
self.assertEqual(spec, spec_from_file)
self.assertTrue(spec.eq_dag, spec_from_file)

# currently we don't store build dependency information when
# we write out specs to the filesystem.

# TODO: fix this when we can concretize more loosely based on
# TODO: what is installed. We currently omit these to
# TODO: increase reuse of build dependencies.
stored_deptypes = ('link', 'run')
expected = spec.copy(deps=stored_deptypes)
self.assertEqual(expected, spec_from_file)
self.assertTrue(expected.eq_dag, spec_from_file)

This comment has been minimized.

Copy link
@alalazo

alalazo Dec 13, 2016

Member

@tgamblin Just to double check. As I am converting tests I found a couple of self.assertTrue that were clearly meant to be self.assertEqual. The APIs on unittest is kind of sneaky, because if you take the wrong assertion, the call is still valid:

self.assertTrue(expr, msg=None)

Here it seems it makes sense to assertTrue, but I was wondering: do you want the error message to be spec_from_file or was it a cut and paste error from the line above?

self.assertTrue(spec_from_file.concrete)

# Ensure that specs that come out "normal" are really normal.
with open(spec_path) as spec_file:
read_separately = Spec.from_yaml(spec_file.read())

read_separately.normalize()
self.assertEqual(read_separately, spec_from_file)
# TODO: revise this when build deps are in dag_hash
norm = read_separately.normalized().copy(deps=stored_deptypes)
self.assertEqual(norm, spec_from_file)

read_separately.concretize()
self.assertEqual(read_separately, spec_from_file)
# TODO: revise this when build deps are in dag_hash
conc = read_separately.concretized().copy(deps=stored_deptypes)
self.assertEqual(conc, spec_from_file)

# Make sure the hash of the read-in spec is the same
self.assertEqual(spec.dag_hash(), spec_from_file.dag_hash())
self.assertEqual(expected.dag_hash(), spec_from_file.dag_hash())

# Ensure directories are properly removed
self.layout.remove_install_directory(spec)
Expand Down

0 comments on commit bee5c05

Please sign in to comment.