-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix stack overflow in spock making junit ignore test failures (#7674)
Fix stack overflow on TooManyInvocationsError
- Loading branch information
1 parent
201bcbe
commit e46eaa2
Showing
7 changed files
with
115 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
dd-java-agent/testing/src/test/groovy/TooManyInvocationsErrorListenerTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import datadog.trace.agent.test.AgentTestRunner | ||
import datadog.trace.agent.test.SpockRunner | ||
import org.junit.runner.Description | ||
import org.junit.runner.notification.Failure | ||
import org.spockframework.mock.IMockInteraction | ||
import org.spockframework.mock.IMockMethod | ||
import org.spockframework.mock.IMockObject | ||
import org.spockframework.mock.IResponseGenerator | ||
import org.spockframework.mock.TooManyInvocationsError | ||
import org.spockframework.mock.runtime.MockInvocation | ||
|
||
class TooManyInvocationsErrorListenerTest extends AgentTestRunner { | ||
|
||
@SuppressWarnings('GroovyAccessibility') | ||
void 'test that listener modifies failure'() { | ||
setup: | ||
final error = new TooManyInvocationsError(Stub(IMockInteraction), []) | ||
error.acceptedInvocations.add(new MockInvocation(Stub(IMockObject), | ||
Stub(IMockMethod), | ||
[error], | ||
Stub(IResponseGenerator))) | ||
final failure = new Failure(new Description(TooManyInvocationsErrorListenerTest, 'test'), error) | ||
|
||
when: | ||
failure.getMessage() | ||
|
||
then: | ||
thrown(StackOverflowError) | ||
|
||
when: | ||
final listener = new SpockRunner.TooManyInvocationsErrorListener() | ||
listener.testFailure(failure) | ||
failure.getMessage() | ||
|
||
then: | ||
noExceptionThrown() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters