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

Simplify test task state to make it CC-friendly #25983

Merged

Conversation

abstratt
Copy link
Member

@abstratt abstratt commented Aug 1, 2023

ListenerBroadcast and friends are complex structures(with lots of lazy init'ing) and pose challenges for correctly storing/restoring their state to/from disk (as required by CC).

This changeset simplifies the configuration-time state kept by AbstractTestTask so it only collects references to TestListener and TestOutputListener instances, without instantiating any ListenerBroadcasts.

Issue: #25855

@abstratt abstratt added this to the 8.4 RC1 milestone Aug 1, 2023
@abstratt abstratt requested a review from a team August 1, 2023 13:42
@abstratt abstratt self-assigned this Aug 1, 2023
@abstratt abstratt requested a review from a team as a code owner August 1, 2023 13:42
@abstratt abstratt requested a review from tresat August 1, 2023 13:42
@abstratt abstratt force-pushed the rchaves/master/make-test-task-listeners-cc-friendly branch 3 times, most recently from d8841a9 to f1df59d Compare August 1, 2023 14:40
@gradle gradle deleted a comment from abstratt Aug 1, 2023
@abstratt abstratt force-pushed the rchaves/master/make-test-task-listeners-cc-friendly branch from f1df59d to fe8bf21 Compare August 1, 2023 14:51
@gradle gradle deleted a comment from abstratt Aug 1, 2023
if (broadcaster == null) {
broadcaster = getListenerManager().createAnonymousBroadcaster(listenerClass);
for (Object listener: subscribedListeners) {
if (listenerClass.isInstance(listener)) {
Copy link
Member

Choose a reason for hiding this comment

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

💅 A transaction log structure could get rid of these execution time decisions by recording the original configuration time decision.

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 had that at first, but with lack of support for lambdas, quite more code was needed (one inner class for each combination of event vs closure/listener).

Copy link
Member

Choose a reason for hiding this comment

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

Hm, I see.

@abstratt abstratt force-pushed the rchaves/master/make-test-task-listeners-cc-friendly branch 3 times, most recently from 70cc4b1 to 7777074 Compare August 4, 2023 12:06
@gradle gradle deleted a comment from abstratt Aug 4, 2023
@abstratt
Copy link
Member Author

abstratt commented Aug 4, 2023

@bamboo I think we covered all the bits we discussed (minus adding guards for listener registration at execution time)

abstratt added a commit that referenced this pull request Aug 4, 2023
@@ -264,43 +264,52 @@ class TestTaskSpec extends AbstractProjectBuilderSpec {
0 * closure._
}

def "adds listeners and removes after execution"() {
def "removes listeners after execution"() {
Copy link
Member

Choose a reason for hiding this comment

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

💭 Do you need to test AbstractTestTask#addTestOutputListener(TestOutputListener) in the same way?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we could and maybe should.

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 couldn't figure how to do that. Couldn't get the event to be observed. Any tips?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I haven't tried anything like this, I just noticed the absence.

@abstratt abstratt force-pushed the rchaves/master/make-test-task-listeners-cc-friendly branch from c701e3e to 2183f54 Compare August 8, 2023 02:36
@gradle gradle deleted a comment from abstratt Aug 8, 2023
@gradle gradle deleted a comment from abstratt Aug 8, 2023
@gradle gradle deleted a comment from abstratt Aug 8, 2023
@gradle gradle deleted a comment from abstratt Aug 8, 2023
bot-gradle added a commit that referenced this pull request Aug 8, 2023
…ndly

ListenerBroadcast and friends are complex structures(with lots of lazy init'ing) and pose challenges for correctly storing/restoring their state to/from disk (as required by CC).

This changeset simplifies the configuration-time state kept by AbstractTestTask so it only collects references to TestListener and TestOutputListener instances, without instantiating any ListenerBroadcasts.

Issue: #25855

Co-authored-by: Rafael Chaves <rchaves@gradle.com>
@bot-gradle
Copy link
Collaborator

I've triggered a build for you. Click here to see all failures if there's any.

@bot-gradle
Copy link
Collaborator

Pre-tested commit build failed. Click here to see all build failures.

ListenerBroadcast and friends are complex structures(with lots of lazy init'ing) and pose challenges for correctly storing/restoring their state to/from disk (as required by CC).

This changeset simplifies the configuration-time state kept by AbstractTestTask so it only collects references to TestListener and TestOutputListener instances, without instantiating any ListenerBroadcasts.

Issue: #25855
No synchronization required as listener addition/removal does not need
to be thread-safe.
@abstratt abstratt force-pushed the rchaves/master/make-test-task-listeners-cc-friendly branch from 2183f54 to 6dc3fe3 Compare August 8, 2023 15:44
@abstratt
Copy link
Member Author

abstratt commented Aug 8, 2023

@bot-gradle test and merge

@gradle gradle deleted a comment from abstratt Aug 8, 2023
@gradle gradle deleted a comment from abstratt Aug 8, 2023
@bot-gradle
Copy link
Collaborator

Your PR is queued. See the queue page for details.

@bot-gradle
Copy link
Collaborator

I've triggered a build for you. Click here to see all failures if there's any.

@bot-gradle bot-gradle merged commit b2db388 into master Aug 8, 2023
19 checks passed
@bot-gradle bot-gradle deleted the rchaves/master/make-test-task-listeners-cc-friendly branch August 8, 2023 17:44
@abstratt abstratt linked an issue Aug 29, 2023 that may be closed by this pull request
bot-gradle added a commit that referenced this pull request Aug 30, 2023
…in AbstractTestTask

...which were not working before 8.4.

Issue: #25311, #25983

Co-authored-by: Rafael Chaves <rchaves@gradle.com>
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.

Test.afterTest is not called with Configuration Cache
4 participants