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

Fix crash of :debug-log-filter when --filter wasn't given #2505

Merged
merged 2 commits into from
Apr 6, 2017
Merged

Fix crash of :debug-log-filter when --filter wasn't given #2505

merged 2 commits into from
Apr 6, 2017

Conversation

arp242
Copy link
Contributor

@arp242 arp242 commented Apr 3, 2017

There was no LogFilter. The fix is to always initialize a
LogFilter() with None. as the "filter".

Fixes #2303.


This change is Reviewable


Scenario: Using debug-log-filter
When I run :debug-log-filter webview
Then no crash should happen
Copy link
Member

Choose a reason for hiding this comment

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

We run all tests in one .feature file in the same qutebrowser instance for performance reasons, and most tests work by parsing qutebrowser's log - so this will probably break all tests following this one.

Even if we had a way to unset a filter with :debug-log-filter, the test would probably fail trying to execute that... so I don't really know a good solution for this. Do you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I did't realize that. I need to think about a way to do this (this is one of those cases where you need tests for your tests >_<).

Copy link
Contributor Author

@arp242 arp242 Apr 3, 2017

Choose a reason for hiding this comment

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

Worst-case scenario btw we just don't add the test ... Although that's obviously not ideal.

Copy link
Member

Choose a reason for hiding this comment

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

Right - I'm fine with that for the record FWIW if nothing else works.

What could work is to immediately reset the filter after setting it (and maybe testing if it works, with :pyeval or so maybe?), and initially setting it to something which still outputs enough for the test infrastructure to work (something like ipc,command or so)

Copy link
Contributor Author

@arp242 arp242 Apr 4, 2017

Choose a reason for hiding this comment

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

I moved it out of the BDD tests in to a regular pytest test. Seems to work well.

To reset the filter I had to add a special none argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it looks like test_*.py files need to be unique globally across the entire project?

I worked around this by choosing a silly filename to test this hypothesis, but this seems like a strange requirement?

Any advice? I can dig deeper later if you don't know.

@codecov
Copy link

codecov bot commented Apr 3, 2017

Codecov Report

Merging #2505 into master will increase coverage by <.01%.
The diff coverage is 70%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2505      +/-   ##
==========================================
+ Coverage   81.07%   81.07%   +<.01%     
==========================================
  Files         132      132              
  Lines       18271    18277       +6     
  Branches     2764     2766       +2     
==========================================
+ Hits        14813    14818       +5     
- Misses       2971     2974       +3     
+ Partials      487      485       -2
Impacted Files Coverage Δ
qutebrowser/utils/log.py 84.77% <66.66%> (+0.4%) ⬆️
qutebrowser/misc/utilcmds.py 88% <71.42%> (-0.97%) ⬇️
qutebrowser/browser/webkit/webpage.py 66.66% <0%> (ø) ⬆️
qutebrowser/browser/commands.py 85.1% <0%> (ø) ⬆️
qutebrowser/browser/downloads.py 87.63% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 857565c...e7755f5. Read the comment docs.

There was no `LogFilter`. The fix is to always initialize a
`LogFilter()` with `None`. as the "filter".

Fixes #2303.
@The-Compiler
Copy link
Member

As discussed in IRC, you can simply use this as test, in utilcmds.feature:

    Scenario: Using debug-log-filter
        When I run :debug-log-filter commands,ipc,webview
        And I run :enter-mode insert
        And I run :debug-log-filter none
        And I run :leave-mode
        Then "Entering mode KeyMode.insert *" should not be logged

As for requiring unique filenames, this section in the pytest docs explains why.

This allows us to clear any filters. Useful for users, and needed for
the tests.
@arp242
Copy link
Contributor Author

arp242 commented Apr 5, 2017

Okay, should be good to go now. I'm not sure why codecov/patch fails and thinks only 70% of this diff is tested, since that's not true as far as I can figure out (?!)

@The-Compiler
Copy link
Member

See https://codecov.io/gh/qutebrowser/qutebrowser/pull/2505/diff - seems fine to me though.

@The-Compiler The-Compiler merged commit e7755f5 into qutebrowser:master Apr 6, 2017
@The-Compiler
Copy link
Member

Thanks!

@arp242 arp242 deleted the debug-log-filter-crash branch April 6, 2017 12:11
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.

:debug-log-filter webview crashes
3 participants