ionelmc / python-hunter

Hunter is a flexible code tracing toolkit.
https://python-hunter.readthedocs.io/
BSD 2-Clause "Simplified" License
794 stars 46 forks source link

Backlog #81

Closed Dan-Ailenei closed 4 years ago

Dan-Ailenei commented 4 years ago

https://github.com/ionelmc/python-hunter/issues/78

ionelmc commented 4 years ago

I've added an integration tests that expects two backlog set of outputs (it fails because of the use fo the self.called flag - it should be removed).

However this reveals a problem with how the indentation is or could be managed. While on the first output the indentation will be fine ... on the second output from the backlog the indentation will be all wrong since there aren't any matching return events from the first backlog output.

It would looks like this:

gration.py:648   call      => test_backlog_before_call(LineMatcher=<class '_pytest.pytester.LineMatcher'>) [backlog]
sample7.py:7     call         => one(a=None, b=None) [backlog]
sample7.py:13    call            => two(c={'3': [4, 5], 'side': 'effect'}) [backlog]
sample7.py:18    call               => three() [backlog]
sample7.py:17    line                  for i in range(1):  # three [backlog]
sample7.py:18    line                  four() [backlog]
sample7.py:21    call                  => four() [backlog]
sample7.py:22    line                     for i in range(1):  # four [backlog]
sample7.py:23    line                     five() [backlog]
sample7.py:26    call                     => five()
sample7.py:27    line                        in_five = 1
sample7.py:28    line                        for i in range(1):  # five
sample7.py:29    line                        return i  # five
sample7.py:29    return                   <= five: 0
gration.py:648   call                     => test_backlog_before_call(LineMatcher=<class '_pytest.pytester.LineMatcher'>) [backlog]
sample7.py:7     call                        => one(a=None, b=None) [backlog]
sample7.py:13    call                           => two(c={'3': [4, 5], 'side': 'effect'}) [backlog]
sample7.py:18    call                              => three() [backlog]
sample7.py:17    line                                 for i in range(1):  # three [backlog]
sample7.py:18    line                                 four() [backlog]
sample7.py:21    call                                 => four() [backlog]
sample7.py:22    line                                    for i in range(1):  # four [backlog]
sample7.py:23    line                                    five() [backlog]
sample7.py:26    call                                    => five()
sample7.py:27    line                                       in_five = 1
sample7.py:28    line                                       for i in range(1):  # five
sample7.py:29    line                                       return i  # five
sample7.py:29    return                                  <= five: 0

So given this problem that is not easy to solve perhaps it's not even worth trying to address consistent identation.

Without any indentation sharing or action instance sharing:

gration.py:648   call      => test_backlog_before_call(LineMatcher=<class '_pytest.pytester.LineMatcher'>) [backlog]
sample7.py:7     call         => one(a=None, b=None) [backlog]
sample7.py:13    call            => two(c={'3': [4, 5], 'side': 'effect'}) [backlog]
sample7.py:18    call               => three() [backlog]
sample7.py:17    line                  for i in range(1):  # three [backlog]
sample7.py:18    line                  four() [backlog]
sample7.py:21    call                  => four() [backlog]
sample7.py:22    line                     for i in range(1):  # four [backlog]
sample7.py:23    line                     five() [backlog]
sample7.py:26    call      => five()
sample7.py:27    line         in_five = 1
sample7.py:28    line         for i in range(1):  # five
sample7.py:29    line         return i  # five
sample7.py:29    return    <= five: 0
gration.py:648   call      => test_backlog_before_call(LineMatcher=<class '_pytest.pytester.LineMatcher'>) [backlog]
sample7.py:7     call         => one(a=None, b=None) [backlog]
sample7.py:13    call            => two(c={'3': [4, 5], 'side': 'effect'}) [backlog]
sample7.py:18    call               => three() [backlog]
sample7.py:17    line                  for i in range(1):  # three [backlog]
sample7.py:18    line                  four() [backlog]
sample7.py:21    call                  => four() [backlog]
sample7.py:22    line                     for i in range(1):  # four [backlog]
sample7.py:23    line                     five() [backlog]
sample7.py:26    call      => five()
sample7.py:27    line         in_five = 1
sample7.py:28    line         for i in range(1):  # five
sample7.py:29    line         return i  # five
sample7.py:29    return    <= five: 0
codecov-io commented 4 years ago

Codecov Report

Merging #81 into master will decrease coverage by 3.7%. The diff coverage is 73.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
- Coverage   82.09%   78.39%   -3.71%     
==========================================
  Files          13       13              
  Lines        1960     2064     +104     
  Branches      255      274      +19     
==========================================
+ Hits         1609     1618       +9     
- Misses        319      402      +83     
- Partials       32       44      +12
Impacted Files Coverage Δ
src/hunter/util.py 83.63% <25%> (-11.65%) :arrow_down:
src/hunter/predicates.py 92.77% <69.76%> (-7.23%) :arrow_down:
src/hunter/event.py 67.91% <72.72%> (+9.58%) :arrow_up:
src/hunter/actions.py 89.58% <87.5%> (+0.66%) :arrow_up:
src/hunter/__init__.py 89.1% <94.44%> (+1.4%) :arrow_up:
src/hunter/backports/inspect.py 0% <0%> (-85.06%) :arrow_down:

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 3c0a356...3bf7b3f. Read the comment docs.

ionelmc commented 4 years ago

Need to figure out the uncovered corner-cases and the we can proceed with the Cython implementation.

ionelmc commented 4 years ago

Rebased.