Bug 575520 - Four CodeFormatterTest tests fail since I20210907-1800
Summary: Four CodeFormatterTest tests fail since I20210907-1800
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.22   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: 4.22 M1   Edit
Assignee: Mickael Istria CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks: 466532
  Show dependency tree
 
Reported: 2021-08-20 02:02 EDT by Noopur Gupta CLA
Modified: 2021-09-15 03:15 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Noopur Gupta CLA 2021-08-20 02:02:02 EDT
I20210818-1800

mac64-java11_macosx

Content not as expected: is /** * * HEADER */ package pack; public final class C { /** * javadoc */ public void method() { /* a comment */ int local; } } Differs at pos 113: d() { ^/* a c expected: /** * * HEADER */ package pack; public final class C { /** * javadoc */ public void method() { /* * a comment */ int local; } } expected:<...lic void method() { [ /* * a comment ] */ int local; }...> but was:<...lic void method() { [/* a comment] */ int local; }...>

org.junit.ComparisonFailure: Content not as expected: is
/**
*
* HEADER
*/
package pack;

public final class C {
/**
* javadoc
*/
public void method() {
/* a
comment */
int local;
}
}

Differs at pos 113: d() {
^/* a
c
expected:
/**
*
* HEADER
*/
package pack;

public final class C {
/**
* javadoc
*/
public void method() {
/*
* a comment
*/
int local;
}
}
expected:<...lic void method() {
[ /*
* a comment
] */
int local;
}...> but was:<...lic void method() {
[/* a
comment] */
int local;
}...>
at org.junit.Assert.assertEquals(Assert.java:117)
at org.eclipse.jdt.testplugin.StringAsserts.assertEqualString(StringAsserts.java:73)
at org.eclipse.jdt.ui.tests.core.CoreTests.assertEqualString(CoreTests.java:34)
at org.eclipse.jdt.ui.tests.core.CodeFormatterTest.testFormatElementInComment(CodeFormatterTest.java:319)
...
Comment 1 Noopur Gupta CLA 2021-08-20 02:03:16 EDT
It passes when run locally.
Comment 2 Andrey Loskutov CLA 2021-09-09 06:13:52 EDT
@Noopur: could you please add 4.22 value to the "Version" and change this bug accordingly?

Beside this, the tests fail locally for me (Linux / Java 11)
Comment 3 Andrey Loskutov CLA 2021-09-09 06:23:37 EDT
Regression from bug 466532 commit http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=bf5933129b8eb15b5b7cdefa781eacc1c4a5e3b9

Reverting the commit above fixes tests.
Comment 4 Andrey Loskutov CLA 2021-09-09 06:45:39 EDT
@Mickael: please check this, the regression is there even after the fix for bug 575872.
Comment 5 Noopur Gupta CLA 2021-09-09 06:48:02 EDT
(In reply to Andrey Loskutov from comment #2)
> @Noopur: could you please add 4.22 value to the "Version" and change this
> bug accordingly?
Done.
Comment 6 Mickael Istria CLA 2021-09-10 12:18:25 EDT
I can reproduce it locally. I ran the testFormatElementInComment and logged the arguments for setSelectedRanges:

Reference, before multi-carets patch, OK:
0,0
63,0
118,0
113,15
156,-43
137,0

After multi-carets patch, KO:
0,0
63,0
118,0
113,15
141,0
141,0

I need to look at why we get (141,0) when we expect (156,-43) for proper execution. As I don't have much knowledge about the formatter (nor do I understand why is setSelectedRanges called so often during formatting), it's going to take some more time.
Comment 7 Andrey Loskutov CLA 2021-09-10 12:28:16 EDT
I assume the test selects something for format, but that is broken now, or what the formatter "sees" as selected.
Comment 8 Eclipse Genie CLA 2021-09-14 08:57:55 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.text/+/185400
Comment 10 Mickael Istria CLA 2021-09-15 03:15:28 EDT
Tests ran successfully on main build.