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

Invalid line separators in a custom JavaDoc tag prevent test generation #1001

Closed
dtim opened this issue Sep 23, 2022 · 1 comment · Fixed by #1006
Closed

Invalid line separators in a custom JavaDoc tag prevent test generation #1001

dtim opened this issue Sep 23, 2022 · 1 comment · Fixed by #1006
Assignees
Labels
comp-summaries Something related to the method names, code comments and display names generation ctg-bug Issue is a bug priority-blocker Bug blocking some of the main features

Comments

@dtim
Copy link
Collaborator

dtim commented Sep 23, 2022

Description

For some code examples, invalid line separators are generated, presumably in

To Reproduce

Steps to reproduce the behavior:

Example:

Using the plugin, invoke test generation for the foo method:

class Foo {
     public void foo(@NotNull String[] data, Object item) {
        data[0] = (String) item;
    }
}

Expected behavior

Tests are successfully generated, no exceptions are thrown.

Actual behavior

No tests are generated, an exception is thrown and displayed in IDE:

java.lang.AssertionError: Wrong line separators: '...ct item) {\r\n *     d...' at offset 629
	at com.intellij.openapi.util.text.StringUtil.assertValidSeparators(StringUtil.java:2511)
	at com.intellij.openapi.editor.impl.DocumentImpl.assertValidSeparators(DocumentImpl.java:710)
	at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:604)
	at com.intellij.openapi.editor.impl.DocumentImpl.lambda$setText$2(DocumentImpl.java:1081)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:207)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:172)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:162)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:148)
	at com.intellij.openapi.editor.impl.DocumentImpl.setText(DocumentImpl.java:1086)
	at org.utbot.intellij.plugin.generator.CodeGenerationController$generateCodeAndReport$1$1$1$run$$inlined$executeCommand$default$1.run(actions.kt:14)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:216)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:172)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:162)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:148)
	at org.utbot.intellij.plugin.generator.CodeGenerationController$generateCodeAndReport$1$1$1.run(CodeGenerationController.kt:918)
	at org.utbot.intellij.plugin.util.IntelliJApiHelper$run$lambda-6$$inlined$runWriteAction$1.compute(actions.kt:60)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$runWriteAction$15(ApplicationImpl.java:945)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:924)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:945)
	at org.utbot.intellij.plugin.util.IntelliJApiHelper.run(IntelliJApiHelper.kt:58)
	at org.utbot.intellij.plugin.generator.CodeGenerationController$generateCodeAndReport$1$1.run(CodeGenerationController.kt:604)
	at org.utbot.intellij.plugin.util.IntelliJApiHelper$run$lambda-6$$inlined$invokeLater$1.run(ApplicationUtils.kt:69)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
	at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:794)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:350)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:133)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:189)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:885)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:754)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:441)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:825)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:440)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:794)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:486)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)```

Environment

  • Testing framework: JUnit 5
  • No mocks
  • Parametrized tests: off

Additional context

It seems that the summary with the custom tag @utbot.executesCondition may be incorrect for an execution (code has been taken from the debugger, breakpoint set at com.intellij.openapi.util.text.StringUtil#assertValidSeparators:2511; I am not sure but I suppose that this code probably can't be rendered because of the multiline string inside the @code tag).

    /**
    @utbot.classUnderTest {@link Foo}
 * @utbot.methodUnderTest {@link basic.Foo#foo(java.lang.String[],java.lang.Object)}
 * @utbot.executesCondition {@code (public void foo(@NotNull String[] data, Object item) {
 *     data[0] = (String) item;
 * }): False}
 *  */
    @Test
    @DisplayName("foo: ")
    public void testFoo() {
        Foo foo = new Foo();
        java.lang.String[] data = {null};
        
        foo.foo(data, null);
        
        String finalData0 = data[0];
        
        assertNull(finalData0);
    }
    ///endregion
@dtim dtim added ctg-bug Issue is a bug comp-summaries Something related to the method names, code comments and display names generation labels Sep 23, 2022
@korifey korifey moved this to Todo in UTBot Java Sep 23, 2022
@alisevych
Copy link
Member

alisevych commented Sep 26, 2022

@amandelpie Reproducing again on test generation for ArrayQuickSort.
With IDEA 2022.1.4 and latest UTBot plugin build from main

A bit different stacktrace

java.lang.AssertionError: Wrong line separators: '...< a[e2]) {\r\n * a...' at offset 36915
at com.intellij.openapi.util.text.StringUtil.assertValidSeparators(StringUtil.java:2450)
at com.intellij.openapi.editor.impl.DocumentImpl.assertValidSeparators(DocumentImpl.java:715)
at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:609)
at com.intellij.openapi.editor.impl.DocumentImpl.lambda$setText$2(DocumentImpl.java:1086)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:210)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:174)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:164)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:150)
at com.intellij.openapi.editor.impl.DocumentImpl.setText(DocumentImpl.java:1091)
at org.utbot.intellij.plugin.generator.CodeGenerationController$generateCodeAndReport$1$1$1$run$$inlined$executeCommand$default$1.run(actions.kt:14)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:219)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:174)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:164)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:150)
at org.utbot.intellij.plugin.generator.CodeGenerationController$generateCodeAndReport$1$1$1.run(CodeGenerationController.kt:917)
at org.utbot.intellij.plugin.util.IntelliJApiHelper$run$lambda-6$$inlined$runWriteAction$1.compute(actions.kt:60)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$runWriteAction$13(ApplicationImpl.java:1024)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:1003)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1024)
at org.utbot.intellij.plugin.util.IntelliJApiHelper.run(IntelliJApiHelper.kt:58)
at org.utbot.intellij.plugin.generator.CodeGenerationController$generateCodeAndReport$1$1.run(CodeGenerationController.kt:604)
at org.utbot.intellij.plugin.util.IntelliJApiHelper$run$lambda-6$$inlined$invokeLater$1.run(ApplicationUtils.kt:69)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:215)
at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:22)
at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:197)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:873)
at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:511)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:69)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:112)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:42)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:898)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:746)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:439)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:803)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:438)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:604)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:436)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:873)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:484)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

@alisevych alisevych added the priority-blocker Bug blocking some of the main features label Sep 26, 2022
Repository owner moved this from Todo to Done in UTBot Java Sep 27, 2022
@alisevych alisevych added this to the Release preparation milestone Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-summaries Something related to the method names, code comments and display names generation ctg-bug Issue is a bug priority-blocker Bug blocking some of the main features
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants