Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added check of expanded StageComposite property #11661

Merged

Conversation

tldahlgren
Copy link
Contributor

@tldahlgren tldahlgren commented Jun 7, 2019

Add test per discussion in #11647

@tgamblin tgamblin changed the title Added check of expanded StageComposite property (see #11647). Added check of expanded StageComposite property Jun 7, 2019
Copy link
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

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

This is good but can you also add a test for spack location? That is actually where the breakage was that #11647 was fixing.

You can look at the other command tests to see how we test the CLI with SpackCommand

Copy link
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

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

see above

@tldahlgren
Copy link
Contributor Author

tldahlgren commented Jun 7, 2019

This is good but can you also add a test for spack location? That is actually where the breakage was that #11647 was fixing.

You can look at the other command tests to see how we test the CLI with SpackCommand

Sure.

@tldahlgren tldahlgren closed this Jun 7, 2019
@tldahlgren tldahlgren reopened this Jun 7, 2019
@tldahlgren tldahlgren force-pushed the tests/add-composite-expanded-check branch from c2f9a9a to fdb0c42 Compare June 7, 2019 22:18
@tgamblin tgamblin added stage tests General test capability(ies) labels Jun 8, 2019
@tldahlgren tldahlgren force-pushed the tests/add-composite-expanded-check branch from ac2d2c5 to 0f1fba9 Compare June 11, 2019 18:35
@tldahlgren tldahlgren requested a review from tgamblin June 11, 2019 21:26
Copy link
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

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

I have a few requests:

  • Update exception handling and new exception classes (more in comments)
  • Update parameterization of some tests (more in comments)
  • Retrieve expected test values from object properties rather than using static strings (more on this in comment for test_location_build_dir)

lib/spack/spack/cmd/location.py Outdated Show resolved Hide resolved
lib/spack/spack/cmd/location.py Outdated Show resolved Hide resolved
lib/spack/spack/cmd/location.py Outdated Show resolved Hide resolved
lib/spack/spack/test/cmd/location.py Outdated Show resolved Hide resolved
lib/spack/spack/test/cmd/location.py Outdated Show resolved Hide resolved
lib/spack/spack/test/cmd/location.py Outdated Show resolved Hide resolved
@@ -69,7 +68,7 @@ def location(parser, args):
elif args.env:
path = spack.environment.root(args.env)
if not os.path.isdir(path):
tty.die("no such environment: '%s'" % args.env)
raise BadEnvironmentError("No such environment: '%s'" % args.env)
Copy link
Member

Choose a reason for hiding this comment

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

I know I made a comment here suggesting that we should replace tty.die invocations with SpackError subclasses, but I meant for core code. This code is in a command -- where it's fine (and probably clearer) to use tty.die() instead of introducing many different exception types. Commands are really what tty.die() is for. You can think of them as just an extended main() method, where calling exit() is fine. They're not library code - they're supposed to be simple, and if things get complex in the commands, we try to push the complexity into the core so that their logic stays simple.

The only thing that invokes a command besides the framework in spack.main is tests, and for command tests, it's sufficient to just do with pytest.raises(SystemExit):. The one I complained about here was a method of DIYStage (a core class) calling tty.die(). Sorry for confusing things.

Basically, I don't think we need to go overboard on exception types here. My general rule of thumb is that we shouldn't define new exception types in the commands, because it clutters up the command logic for not a lot of gain. I'd just revert this change and the others in cmd/location.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suspected as such wrt tty.die versus exceptions but it's good to get confirmation.

Copy link
Contributor Author

@tldahlgren tldahlgren Jun 13, 2019

Choose a reason for hiding this comment

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

Thankfully I found the fail_on_error option so I could still check the unique output message instead of SpackCommandError's standard Command exited with code 1: location(<args>).

lib/spack/spack/cmd/location.py Outdated Show resolved Hide resolved
lib/spack/spack/cmd/location.py Outdated Show resolved Hide resolved
lib/spack/spack/cmd/location.py Outdated Show resolved Hide resolved
lib/spack/spack/test/cmd/location.py Outdated Show resolved Hide resolved
lib/spack/spack/test/cmd/location.py Outdated Show resolved Hide resolved
Copy link
Member

@tgamblin tgamblin 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! Feel free to squash merge this when the tests pass.


@pytest.mark.parametrize('specs,expected', [
([], "You must supply a spec."),
(['spec1', 'spec2'], "Too many specs. Supply only one.")])
Copy link
Member

Choose a reason for hiding this comment

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

This can just stay the way it is for now, but in general I think we don't want to be too specific about what we check for. It can end up being brittle. I think this is fine for now -- if it breaks we'll make it less specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I debated myself on the specificity because there is a trade-off, especially wrt error messages.

Thanks.

@scheibelp scheibelp merged commit 25b21c0 into spack:develop Jun 13, 2019
@tldahlgren tldahlgren deleted the tests/add-composite-expanded-check branch June 13, 2019 19:34
carsonwoods pushed a commit to carsonwoods/spack that referenced this pull request Jun 27, 2019
The "spack location" command was previously untested. This also adds
a check to ensure that composite Stages can report whether they were
expanded (this property was previously only recorded in Stage but not
in CompositeStage).
dev-zero pushed a commit to dev-zero/spack that referenced this pull request Aug 13, 2019
The "spack location" command was previously untested. This also adds
a check to ensure that composite Stages can report whether they were
expanded (this property was previously only recorded in Stage but not
in CompositeStage).
@tldahlgren tldahlgren self-assigned this Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage tests General test capability(ies)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants