-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fail on classpath resource names that are blank after removing leading slash #4761
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
3502b7a
e123ed6
665501c
4eb5925
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ public void selectorProcessed(UniqueId engineId, DiscoverySelector selector, Sel | |
if (result.getStatus() == FAILED) { | ||
this.issues.add(DiscoveryIssue.builder(Severity.ERROR, selector + " resolution failed") // | ||
.cause(result.getThrowable()) // | ||
.source(toSource(selector)) // | ||
.source(toSourceSafely(selector)) // | ||
.build()); | ||
} | ||
else if (result.getStatus() == UNRESOLVED && selector instanceof UniqueIdSelector uniqueIdSelector) { | ||
|
@@ -78,7 +78,17 @@ else if (result.getStatus() == UNRESOLVED && selector instanceof UniqueIdSelecto | |
} | ||
} | ||
|
||
static @Nullable TestSource toSource(DiscoverySelector selector) { | ||
private static @Nullable TestSource toSourceSafely(DiscoverySelector selector) { | ||
try { | ||
return toSource(selector); | ||
} | ||
catch (Exception e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be necessary but we should do our best to avoid throwing an exception while reporting a discovery issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is both too much and not enough. A broad try-catch would make sense if JUnit would be invoking third-party implementations. But the current the At the same time, any third-parties can implement custom selectors, but they'll have to do their own issue reporting. Would it make sense to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was, actually. 😉 I found another inconsistency with Another problem is the normalization that
They would still benefit from the built-in issue reporting but the reported discovery issue would not have a
I thought about it. I don't remember the specifics but we decided to introduce another Another option could be to introduce a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've got no strong feelings about this. Oh and nice catch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 4eb5925 |
||
logger.error(e, () -> "Failed to convert DiscoverySelector [%s] into TestSource".formatted(selector)); | ||
return null; | ||
} | ||
} | ||
|
||
private static @Nullable TestSource toSource(DiscoverySelector selector) { | ||
if (selector instanceof ClassSelector classSelector) { | ||
return ClassSource.from(classSelector.getClassName()); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a implicit
toString
call here to a 3rd party implementation which could throw. So the same caution that promptedtoSourceSafely
, should probably put a try-catch around it.And I only just now realized that
DiscoverySelector.toString()
should have been implemented in Cucumber. 😉There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if a
toString()
method throws an exception, I'm happy to let the entire discovery fail for that engine... 🤭