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

Add flag to print all attachments for successful tests #242

Merged
merged 2 commits into from Jun 28, 2019

Conversation

mtreinish
Copy link
Owner

This commit adds a new flag, --all-attachments, to the run, load, and
last commands (in addition to a matching user config flag). When set
this flag will tell subunit trace to print all text attachments for a
test whether it was successful or it failed.

Fixes #223

@mtreinish mtreinish requested a review from masayukig May 20, 2019 14:54
@mtreinish
Copy link
Owner Author

@aspiers give this a try and let me know if it's what you're looking for.

@coveralls
Copy link

coveralls commented May 20, 2019

Coverage Status

Coverage decreased (-0.2%) to 65.891% when pulling 784e7ab on add-all-attachments into cacc175 on master.

@mtreinish
Copy link
Owner Author

@masayukig Do you have any thoughts on this?

Copy link
Collaborator

@masayukig masayukig left a comment

Choose a reason for hiding this comment

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

I didn't see this patch deeply (I'll do it later) but, can we have unit tests for this change? Meaningless?

@mtreinish
Copy link
Owner Author

Unit testing this is a bit tricky, since the difference when the flag is set is to print text attachments that are not stdout and stderr. The only way I could think of testing it would be to create a fake test case with a text attachment, run it with the flag, and then inspect the captured output from the run. Which seemed like a lot of effort for minimal gain.

Copy link
Collaborator

@masayukig masayukig left a comment

Choose a reason for hiding this comment

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

LGTM. This option works in my environment, too. But I'd like to wait for a while for @aspiers 's comment and/or feedback before merging.

@mtreinish
Copy link
Owner Author

@aspiers have you had a chance to take a look at this and see if it fixes #223 for you?

@aspiers
Copy link

aspiers commented Jun 13, 2019

@mtreinish Sorry for the delay. I've now tested this via

.tox/py36/bin/pip install -e 'git+https://github.com/mtreinish/stestr.git@add-all-attachments#egg=stestr'

and it works great! Many thanks :-)

Copy link

@aspiers aspiers left a comment

Choose a reason for hiding this comment

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

Just an observation (even though I hardly know this codebase, so treat with a big pinch of salt) - there seems to be a lot of parameter passing required, which makes adding new options like this a pretty heavyweight change for what it is. Maybe worth a refactor so that an "output options" object is passed around instead?

doc/source/MANUAL.rst Outdated Show resolved Hide resolved
successful tests you can use the ``--all-attachments`` flag to print all text
attachments on both successful and failed tests. If both ``--all-attachments``
and ``--suppress-attachments`` are set then the ``--suppress--attachments``
flag will take priority and no attachments will be printed for successful
Copy link

Choose a reason for hiding this comment

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

Wouldn't it make more sense to error in this case?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I was just being lazy, doing it this way was slightly easier to implement. In my mind it doesn't matter exactly what the behavior is as long as we're explicit about how it works. That being said, this just made me realize there is a broken edge case with mixed inputs right now. If you set suppress-attachments in the user config file and --all-attachments on the cli that will mean no attachments print. So I'll have to change the behavior here anyway to make sure the cli takes precedence for both. I'll change this to an error at the same time since I'm not attached to any behavior.

@mtreinish
Copy link
Owner Author

Just an observation (even though I hardly know this codebase, so treat with a big pinch of salt) - there seems to be a lot of parameter passing required, which makes adding new options like this a pretty heavyweight change for what it is. Maybe worth a refactor so that an "output options" object is passed around instead?

That might be something to investigate in the future. Part of my concern with doing this though is that each most of the places we pass a parameter is an external public interface. So we have to watch out for any backwards compatibility issues. For example, all the the arg parsing just uses the public python interface so it passes all the parsed args just to that. It'll be easier to do a cleanup like this in the lower internal levels (like the _run_tests() function where we don't have to worry about breaking users (hopefully).

This commit adds a new flag, --all-attachments, to the run, load, and
last commands (in addition to a matching user config flag). When set
this flag will tell subunit trace to print all text attachments for a
test whether it was successful or it failed.

Fixes #223
@masayukig
Copy link
Collaborator

https://ci.appveyor.com/project/mtreinish/stestr/builds/25586943/job/1a0fw6pgbgtuivh6#L196

ERROR: Sphinx requires at least Python 3.5 to run.

This is really annoying... I pushed a patch for this #246 .

@masayukig masayukig merged commit 5018167 into master Jun 28, 2019
@masayukig masayukig deleted the add-all-attachments branch June 28, 2019 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add flag to always print all text attachments
4 participants