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

Test the interceptor lifecycle #1668

Merged
merged 5 commits into from Nov 28, 2023
Merged

Test the interceptor lifecycle #1668

merged 5 commits into from Nov 28, 2023

Conversation

Vampire
Copy link
Member

@Vampire Vampire commented Jun 1, 2023

No description provided.

@Vampire Vampire requested a review from leonard84 June 2, 2023 14:20
@Vampire Vampire force-pushed the fix-possible-interceptors-example branch from 33ad084 to f7055ec Compare June 6, 2023 12:59
@Vampire Vampire force-pushed the test-interceptor-lifecycle branch from e4775ce to 93f8262 Compare June 6, 2023 12:59
@Vampire Vampire force-pushed the fix-possible-interceptors-example branch from f7055ec to aa845e5 Compare June 6, 2023 22:54
@Vampire Vampire force-pushed the test-interceptor-lifecycle branch from 93f8262 to 8569665 Compare June 6, 2023 22:54
@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1316827) 80.43% compared to head (586f1c1) 80.39%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1668      +/-   ##
============================================
- Coverage     80.43%   80.39%   -0.04%     
+ Complexity     4234     4233       -1     
============================================
  Files           434      434              
  Lines         13279    13279              
  Branches       1688     1688              
============================================
- Hits          10681    10676       -5     
- Misses         1960     1964       +4     
- Partials        638      639       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Vampire Vampire force-pushed the test-interceptor-lifecycle branch from 8569665 to 8fae8fd Compare June 9, 2023 01:04
@Vampire Vampire force-pushed the fix-possible-interceptors-example branch from aa845e5 to 0c0366a Compare June 28, 2023 01:03
Base automatically changed from fix-possible-interceptors-example to master November 6, 2023 21:30
@Vampire Vampire force-pushed the test-interceptor-lifecycle branch 2 times, most recently from 71411ac to 0787f97 Compare November 7, 2023 02:13
@Vampire Vampire changed the base branch from master to vampire/fix-possible-interceptors-example November 7, 2023 02:13
@Vampire Vampire force-pushed the vampire/fix-possible-interceptors-example branch from 3c3183a to 42445ff Compare November 8, 2023 14:50
@Vampire Vampire force-pushed the vampire/fix-possible-interceptors-example branch from 42445ff to 992ad9d Compare November 8, 2023 15:08
@Vampire Vampire force-pushed the vampire/fix-possible-interceptors-example branch from 992ad9d to ccc6ebb Compare November 9, 2023 12:10
@leonard84 leonard84 force-pushed the vampire/fix-possible-interceptors-example branch from ccc6ebb to 1c49943 Compare November 12, 2023 12:51
Base automatically changed from vampire/fix-possible-interceptors-example to master November 12, 2023 13:04
Comment on lines 16 to 19
setup start (SubSpec.foo[#0])
setup start (SubSpec.foo[#0])
setup end (SubSpec.foo[#0])
setup end (SubSpec.foo[#0])
Copy link
Member

Choose a reason for hiding this comment

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

🤔 From a reporting POV it isn't ideal that you get the same spec name twice here, as one of the invoked methods is from the SuperSpec, although it is correct that the the feature belongs to the SubSpec. The same applied to the other methods.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, but that is nothing I change here.
I just add a test that verifies the current state, like I also do not fix the simple feature lifecycle here, but in a separate upstack PR.

So this simply is, what you get from IMethodInvocation#spec#name currently.

Maybe it should generally be reviewed whether the delivered information makes sense in all cases.

But actually I don't see how "one of the invoked methods is from the SuperSpec" here.
The super spec does not have any setup method.
It is just the super specs "wrapper around all setup methods" that is called for the setup phase of the sub spec.

If you have setup method in both sub spec and super spec like in the other feature, it looks like this:

setup start (SubSpec.subFeature1[#0])
  setup start (SubSpec.subFeature1[#0])
    setup method start (SuperSpec.subFeature1[#0].setup())
      fixture method start (SuperSpec.subFeature1[#0].setup())
      fixture method end (SuperSpec.subFeature1[#0].setup())
    setup method end (SuperSpec.subFeature1[#0].setup())
  setup end (SubSpec.subFeature1[#0])
  setup method start (SubSpec.subFeature1[#0].setup())
    fixture method start (SubSpec.subFeature1[#0].setup())
    fixture method end (SubSpec.subFeature1[#0].setup())
  setup method end (SubSpec.subFeature1[#0].setup())
setup end (SubSpec.subFeature1[#0])

But it might also be questionable whether this is correct.
Should it really say the spec is super, which matches the actual method called,
but the feature is the one from the sub spec which does not match the feature?

Maybe it would make more sense if spec here is indeed the sub spec, matching the feature you get, and if you want to know from where the method is from, you use method.parent?

I'm not sure how it best should be to be honest. For "shared initializer" for example, you get sub and super, not twice sub like here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Or maybe it makes sense that for the actual "...method" one the IMethodInvocation.spec gives the one matching that method as it is the main target in view currently, and if you want the features spec, you use feature.parent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, in my other upstack PR I add tests for whether the fields are set at all or not,
but they don't verify to what they are set and whether the spec is consistent with the feature and so on. I guess another PR could introduce such checks later on and fix some of this if it is not like intended.

Copy link
Member Author

Choose a reason for hiding this comment

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

I at least improved the reporting in the method-interceptor cases above now, so that the features are not attributed to the wrong specification.

Copy link
Member

Choose a reason for hiding this comment

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

I was not saying that we should change anything on the IMethodInvocation side, but it would be possible to change

specInfo.specsBottomToTop*.addSetupInterceptor {
        proceed(it, 'setup', "$it.spec.name.$it.feature.name[#$it.iteration.iterationIndex]")
      }

to

specInfo.specsBottomToTop.each { spec -> spec.addSetupInterceptor {
        proceed(it, 'setup', "$spec.name.$it.feature.name[#$it.iteration.iterationIndex]")
      }
}

Copy link
Member

Choose a reason for hiding this comment

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

I just add a test that verifies the current state, like I also do not fix the simple feature lifecycle here, but in a separate upstack PR.

So, the intention is to visualize which interceptors are called in what order. Given that the information in IMethodInvocation is no always sufficient for this, I think it makes sense to change the interceptor registrations to include the spec, like I've shown above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, now I got it, yeah, makes absolute sense. Fixed now.

@leonard84 leonard84 merged commit 1da21da into master Nov 28, 2023
39 of 40 checks passed
@leonard84 leonard84 deleted the test-interceptor-lifecycle branch November 28, 2023 14:29
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.

None yet

2 participants