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

Make error message for cyclic graphs in test discovery more actionable #3052

Merged
merged 8 commits into from
Apr 28, 2023

Conversation

tribbloid
Copy link
Contributor

Overview

#3051 error message now contains a list of detected cyclic test UIDs


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

getCyclicUIDs function will return a list containing the first UID that emits a cycle (can be changed to all UIDs, albeit slower)

may still need test case(s)

@tribbloid
Copy link
Contributor Author

Good to go. Can we merge and close it?

Comment on lines 43 to 44
() -> String.format("The discover() method for TestEngine with ID '%s' returned a cyclic graph: "
+ "Cycle found at unique ID '%s'",
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be even more helpful to print all unique IDs in the cycle or at least the two between which the cycle was detected (detectInnerClassCycle in ReflectionUtils could be used for inspiration).

@tribbloid Would you have time to look into that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely, that's why I opted to use List instead of Optional in the first place.

I just don't know if it can halt every time, should we add a some kind of depth check?

Copy link
Member

Choose a reason for hiding this comment

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

Here's an article outlining how to find the shortest cycle in an undirected graph (tests should be a tree, i.e. an acyclic undirected graph): https://www.baeldung.com/cs/shortest-cycle-undirected-graph

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marcphilipp thanks a lot, I'll add the code to print the first detected path of the cycle (using node.parent()).

But I'm reluctant to change the algorithm from breadth first (the status quo) to depth first (one used in your link), the search will hang for diverging tree without loop (e.g. if you generate a UUID suffix for each new sub-test). Existing code probably chose breadth first for this reason (and some other reasons)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK the latest version now print 2 paths that leads to the same node. There are some strange styling errors which shouldn't affect implementation.

All 3 test cases now contains examples of the error messages

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LGTM. Let me know if it looks good or only requires minor revision.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now the styling error is also fixed. Only get some deprecation error under JVM 20 that is irrelevant to the scope of this change.

Can we close it now?

@tribbloid tribbloid force-pushed the verbose-cyclic-msg/squash1 branch 3 times, most recently from 8d6f3e5 to 639ea69 Compare November 11, 2022 02:15
@stale
Copy link

stale bot commented Jan 10, 2023

This pull request has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be closed if no further activity occurs. If you intend to work on this pull request, please reopen the PR. Thank you for your contributions.

@stale
Copy link

stale bot commented Mar 11, 2023

This pull request has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be closed if no further activity occurs. If you intend to work on this pull request, please reopen the PR. Thank you for your contributions.

@stale stale bot added the status: stale label Mar 11, 2023
@stale
Copy link

stale bot commented Apr 2, 2023

This pull request has been automatically closed due to inactivity. If you are still interested in contributing this, please ensure that it is rebased against the latest branch (usually main), all review comments have been addressed and the build is passing.

@stale stale bot closed this Apr 2, 2023
@tribbloid
Copy link
Contributor Author

@marcphilipp I don't see any objection on this patch, can we merge and close it any time soon? It has already become stale once

@marcphilipp
Copy link
Member

@tribbloid Sorry for the delay! We've deactivated Stalebot for PRs now. This PR needs a proper review from someone on the team.

@marcphilipp marcphilipp reopened this Apr 16, 2023
@stale stale bot removed the status: stale label Apr 16, 2023
@marcphilipp marcphilipp self-assigned this Apr 28, 2023
@marcphilipp marcphilipp changed the title add more verbose error message for cyclic UID in discovery Make error message for cyclic graphs in test discovery more actionable Apr 28, 2023
@marcphilipp marcphilipp merged commit d62feaa into junit-team:main Apr 28, 2023
@marcphilipp
Copy link
Member

@tribbloid Thank you! 👍

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.

EngineDiscoveryResultValidator should produce an actionable error message for cyclic TestDescriptor structures
3 participants