Skip to content

[Bug Fix (and docs too)] : Do not select @develop version by default#1933

Merged
tgamblin merged 4 commits intospack:developfrom
citibeth:efischer/161006-VersionDocs
Oct 6, 2016
Merged

[Bug Fix (and docs too)] : Do not select @develop version by default#1933
tgamblin merged 4 commits intospack:developfrom
citibeth:efischer/161006-VersionDocs

Conversation

@citibeth
Copy link
Copy Markdown
Member

@citibeth citibeth commented Oct 6, 2016

@tgamblin @davydden

This PR fixes a bug in #1561. #1561 was supposed to fix bugs, not change behavior in any significant way.

Before #1561, the @develop version would not be selected in concretization, see comment from old code:

# Disregard @develop and take the next valid version

After #1561, the @develop version would be selected by default if it was available, breaking the pre-#1561 behavior. This could result in naive users (i.e. anyone not familiar with a particular package) "accidentally" obtaining the @develop version of a package without specifically requesting it.

This PR fixes that bug introduced by #1561, with two changes:

  1. Change v.isdevelop() to not v.isdevelop(), ensuring that the @develop version will have lower default priority compared to numeric versions
  2. Remove unnecessary v.isnumeric() from the key. This is already tested when comparing version numbers (the last part of the key), and could possibly mess things up if done separately.

This PR also comes with related documentation improvements:

  1. Improved comments explaining the concretization preference algorithm; avoid future bugs.
  2. Section added to the manual explaining the same thing in English.

Elizabeth Fischer added 2 commits October 6, 2016 09:43
algorithm, the intent was that the @develop version, although
"greater" than numberic versions, is never preferred BY DEFAULT over
numeric versions.

To test this... suppose you have a package with no `preferred=True` in
it, and nothing in `packages.yaml`, but with a `develop` version.  For
the sake of this example, I've hacked my `python/package.py` to work
this way.

Without bugfix (WRONG: user should never get develop by default):

```
  python@develop%[email protected]~tk~ucs4 arch=darwin-elcapitan-x86_64
      ...
```

With bugfix (RIGHT: largest numeric version selected):

```
  [email protected]%[email protected]~tk~ucs4 arch=darwin-elcapitan-x86_64
      ...
```
@citibeth citibeth added bug Something isn't working documentation Improvements or additions to documentation labels Oct 6, 2016
Copy link
Copy Markdown
Member

@davydden davydden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, a few minor typos.

if any(v.satisfies(sv) for sv in spec.versions)]

# The keys below show the order of precedence of factors used
# to select a version when concretizing. The the item with
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: The the

# Numeric versions more preferred than non-numeric
v.isnumeric(),

# ---------- Regular case: use lateston-develop version by default.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lateston-develop -> latest non-develop?

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Oct 6, 2016

@citibeth: do you mind adding a regression test for this in one of the spec tests? Could be a separate PR.

@citibeth
Copy link
Copy Markdown
Member Author

citibeth commented Oct 6, 2016

I think it needs to be added, but I have no idea how. If someone wants to
add the "shell" of a test with an "insert your code here" thing, that would
save me a lot of time.

On Thu, Oct 6, 2016 at 10:40 AM, Todd Gamblin [email protected]
wrote:

@citibeth https://github.com/citibeth: do you mind adding a regression
test for this in one of the spec tests? Could be a separate PR.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1933 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AB1cdyDmE6qeDj-LPiIvKXwNqZjGnOiPks5qxQhngaJpZM4KP-07
.

@adamjstewart
Copy link
Copy Markdown
Member

@citibeth Added an issue requesting documentation on writing unit tests. See #1935.

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Oct 6, 2016

Look at the spec_semantics and concretize_preferences tests. They use mock packages in var/spack/repos/builtin.mock. I believe between those two there is enough scaffolding for this. Probably this test can just live in concretize_preferences.

@citibeth
Copy link
Copy Markdown
Member Author

citibeth commented Oct 6, 2016

And how do I run the test while I'm developing it?

On Thu, Oct 6, 2016 at 11:08 AM, Todd Gamblin [email protected]
wrote:

Look at the spec_semantics and concretize_preferences tests. They use mock
packages in var/spack/repos/builtin.mock. I believe between those two
there is enough scaffolding for this. Probably this test can just live in
concretize_preferences.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1933 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AB1cd6L3pvrl-IcnvMkMK5suq7th2kYQks5qxQ7ggaJpZM4KP-07
.

@adamjstewart
Copy link
Copy Markdown
Member

@citibeth You can run the test by running spack test <test-name>. See spack test --list for options.

@citibeth
Copy link
Copy Markdown
Member Author

citibeth commented Oct 6, 2016

Thanks for the info on unit/regression tests. I will not have time to write the tests today, but I believe this PR should be merged ASAP. See #1940.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants