Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
cli: add version command #1746
Conversation
| + | ||
| + def test_has_version_without_hyphens(self): | ||
| + result = self.run_command(['version']) | ||
| + print(result.output) |
kalikiana
Nov 20, 2017
Collaborator
In general, tests shouldn't print anything - instead I would recommend you do something like self.assertThat(result.output, Equals(snapcraft.__version__)) which will only output the value if it fails.
| def test_has_version(self): | ||
| result = self.run_command(['--version']) | ||
| self.assertThat(result.exit_code, Equals(0)) | ||
| + | ||
| + def test_has_version_without_hyphens(self): |
kyrofa
Nov 20, 2017
•
Member
I'd like to see one more test ensuring that the output from --version == the output from version. Because I can tell you right now, it doesn't
kyrofa
requested changes
Nov 20, 2017
Run both --version and version, and you'll see the output is not exactly the same. Click is using its default template, we need to duplicate that here.
kyrofa
changed the title from
Implemented method to get snapcraft version.
to
cli: add version command
Nov 20, 2017
|
Thank you for your review. Indeed it is important to add that. But I do not want to hard code the text string before the method returns the version number. Maybe I am missing something from the click framework to also include in the method I wrote? This would actually allow the results to be tested. |
|
To quote the
I don't have a problem hard-coding that string here. However, if your concern is that Click might change out from under us, you can also add the |
|
Both methods are now printing the same output and the same text. A test was added to guarantee this. |
|
@gsilvapt I see a failure from flake8: I think you should probably add |
|
I can give that a try, for sure. It's awkward that it passed all tests locally |
| + def test_method_return_same_value(self): | ||
| + result1 = self.run_command(['version']) | ||
| + result2 = self.run_command(['--version']) | ||
| + self.assertEqual(result1.output, result2.output) |
|
It's almost like it's validating against its own bundled (and apparently old) version of Click. @sergiusens could use some guidance here. |
kyrofa
approved these changes
Nov 24, 2017
Thanks for this, @gsilvapt! We need to figure out the static failure, but that's not really on you. Overall this PR looks good.
|
Oh, nice! Thank you for reviewing this PR all the time, @kyrofa. |
kalikiana
requested a review
from
sergiusens
Dec 4, 2017
| + snapcraft version | ||
| + snapcraft --version | ||
| + """ | ||
| + click.echo('snapcraft, version {}'.format(snapcraft.__version__)) |
sergiusens
Dec 4, 2017
Collaborator
add a constant here with the version message, make it look like the current on in click, from the source:
'%(prog)s, version %(version)s'
gsilvapt
Dec 8, 2017
Contributor
I had to hardcode "snapcraft, version %(version)" otherwise it would produce issues.
Thank you for your review. Hopefully I did not mess up commit after a long time (had a couple of busy weeks). If you prefer, I can start over. to avoid multiple commits and such.
| @@ -100,7 +99,8 @@ def list_commands(self, ctx): | ||
| @click.group(cls=SnapcraftGroup, invoke_without_command=True) | ||
| -@click.version_option(version=snapcraft.__version__) | ||
| +@click.version_option(message='snapcraft, version %(version)s', |
gsilvapt
Dec 8, 2017
Contributor
this command changed to `( = MESSAGE_SNAPCRAFT_VERSION,version = snapcraft.version)
sergiusens
requested changes
Dec 4, 2017
Hey there, nice job, I only have one request for consistency and book keeping.
Thanks
gsilvapt
and others
added some commits
Dec 8, 2017
sergiusens
added this to the 2.38 milestone
Dec 14, 2017
|
There is unnecessary white space causing the static tests to fail. If I fix this, some conflicts arise in other files. I need guidance here, if you please. I can push a single commit just to fix the white spaces. I wanted to squash this into the previous commit but it is a no-brainer for me. |
gsilvapt commentedNov 20, 2017
•
Edited 6 times
-
gsilvapt
Nov 20, 2017
-
gsilvapt
Nov 20, 2017
-
gsilvapt
Nov 20, 2017
-
gsilvapt
Nov 20, 2017
-
gsilvapt
Nov 20, 2017
-
gsilvapt
Nov 20, 2017
number when called like snapcraft version and snapcraft --version.
./runtests.sh static?./runtests.sh unit?