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

Improve CLI error messages #37

Merged
merged 2 commits into from
Jan 30, 2018
Merged

Conversation

akx
Copy link
Contributor

@akx akx commented Dec 22, 2017

This PR makes the CLI error messages a little more explicit.

I was trying to mistakenly pass in file system paths for modules, which didn't work. :)

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Looks great! Just a couple test improvements.

@@ -81,7 +81,7 @@ def test_no_traces(store_data, stdout, stderr):
store, db_file = store_data
with mock.patch.dict(os.environ, {DefaultConfig.DB_PATH_VAR: db_file.name}):
ret = cli.main(['stub', func.__module__], stdout, stderr)
assert stderr.getvalue() == "No traces found\n"
assert stderr.getvalue().startswith("No traces found")
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we be able to use func.__module__ again here and assert on the full error message?

@akx akx force-pushed the embetter-usage branch 5 times, most recently from c52f2aa to 100c506 Compare December 22, 2017 16:14
@akx
Copy link
Contributor Author

akx commented Dec 22, 2017

@carljm Tests added :)

@@ -81,7 +81,7 @@ def test_no_traces(store_data, stdout, stderr):
store, db_file = store_data
with mock.patch.dict(os.environ, {DefaultConfig.DB_PATH_VAR: db_file.name}):
ret = cli.main(['stub', func.__module__], stdout, stderr)
assert stderr.getvalue() == "No traces found\n"
assert stderr.getvalue() == f"No traces found for module path ('{func.__module__}', None)\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this (module, qualname) representation will be confusing, especially when qualname is None (which is the more common case). Can we rejoin the tuple into its original form instead? (Or maybe there is some argparse way to preserve the original pre-parsing string?)

@mpage
Copy link
Contributor

mpage commented Jan 22, 2018

@akx - This PR is close to being ready to go. Are you still planning on working on it?

@akx akx force-pushed the embetter-usage branch 2 times, most recently from 933418b to 50c8652 Compare January 23, 2018 07:54
@akx
Copy link
Contributor Author

akx commented Jan 23, 2018

@mpage Yes, sorry I'd left this hanging! In my defense I spent two weeks in Japan in the interim and it was pretty.

@carljm Changes made! :)

@mpage
Copy link
Contributor

mpage commented Jan 26, 2018

@akx - Looks great - can you fix the conflicts?

@carljm
Copy link
Contributor

carljm commented Jan 30, 2018

Looks great! Thanks for pushing this through! Merging.

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

Successfully merging this pull request may close these issues.

None yet

4 participants