maven-archetype icon indicating copy to clipboard operation
maven-archetype copied to clipboard

[ARCHETYPE-584] don't normalize whitespace in tests so we can test for whitespace

Open elharo opened this issue 3 years ago • 7 comments

@newur @Tibor17

Passes in Java 8. I want to see if this fails in Java 11.

elharo avatar Jul 07 '21 14:07 elharo

Looks like it fails on JDK 11+

https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-archetype/job/linebreak/1/testReport/

newur avatar Jul 07 '21 14:07 newur

Yep:

Expected: Expected text value '
  ' but was '
    
  ' - comparing <project ...>
  </project> at /project[1]/text()[1] to <project ...>
    
  </project> at /project[1]/text()[1]:
<project>
  <packaging>pom</packaging>
<modules>  <module>myArtifactId1</module>
  </modules>
</project>
     but: result was: 
<project>
    
  <packaging>pom</packaging>
  
  <modules>
      
    <module>myArtifactId1</module>
      
  </modules>
</project>

elharo avatar Jul 07 '21 14:07 elharo

It might make sense to create a new Java 11 test rather than changing this one.

elharo avatar Jul 07 '21 15:07 elharo

@elharo

I don't see what you try to achieve or what your reasoning is here. However, the call to .normalizeWhitespace() is rather new and I assume it was added to 'get the test green'. So undoing the normalize is bringing the test back to the status quo - which was a stronger test anyway!

You can see it here: https://github.com/apache/maven-archetype/commit/bf7961805ea56cdad7e138f47098aacccb314db8#diff-db4ddee9a40aadf3fab866c350ca950397f69b630de05a126f0265e2136cc070

newur avatar Jul 07 '21 18:07 newur

I'm trying to understand what's going on here, and how it fails. This is easier to do one change at a time. This test isn't very well factored to start with, and might need some cleanup before the issue can be fixed.

elharo avatar Jul 07 '21 23:07 elharo

I'm trying to understand what's going on here, and how it fails.

Right, that is always a good approach to solve a bug.

I would hope that the existing PR is a reasonable starting point on how to fix the bug and my comment in JIRA points to the commit that most likely causes the bug.

Anyway, I wish you good luck with the approach you apply to the problem. :)

newur avatar Jul 08 '21 11:07 newur

I think you've identified the likely cause of the bug. I do not, however, agree with the proposed fix. There's nothing about this bug that suggests we should be adding schema processing. I'll be quite surprised if that turns out to be necessary.

elharo avatar Jul 08 '21 11:07 elharo