You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "bingx1 (via GitHub)" <gi...@apache.org> on 2024/10/11 00:20:20 UTC

[PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

bingx1 opened a new pull request, #790:
URL: https://github.com/apache/maven-surefire/pull/790

   This PR fixes the bug described in https://issues.apache.org/jira/browse/SUREFIRE-2277
   
   **Problem**
   
   There is a bug in `RunResult.testAppendSerialization`. 
   
   This test creates a `RunResult` object in-memory, serialises it, writes it to disk and then again deserialises the same file into a `RunResult` in-memory. I have run the test with the debugger and found that the final in-memory `RunResult` object is not the same as the initial one.
   
   It shouldn't be passing on master, but is due to a bug in the `RunResult.equals` method which is used in an assertion in the test. The source of the bug is that the value of `RunResult.flakes` isn't preserved during serialisation to and from `failsafe-summary.xml`. The bug is slipping through and the test passes because the `RunResult.equals` method doesn't consider the `RunResult.flakes` field. 
   
   
   
   **Fix**
   
   I have modified the `failsafe-summary.xsd` to include an _optional_  `<flakes>` element,  which will allow `RunResult.flakes` to be persisted in the `failsafe-summary.xml` during serialisation. I have also changed the serialisation and deserialisation methods for `RunResult` to account for `flakes`. 
   
   I have also added a test, `RunResultTest.testLegacyDeserialization` for backwards compatibility. It tests that deserialising a legacy `failsafe-summary.xml` still works. The behaviour is that when the `flakes` XML element is not present in the `failsafe-summary.xml`, the in-memory `RunResult` will have `RunResult.flakes` set to 0 after deserialisation.
   
   -----
   Following this checklist to help us incorporate your 
   contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SUREFIRE) filed 
          for the change (usually before you start working on it).  Trivial changes like typos do not 
          require a JIRA issue.  Your pull request should address just this issue, without 
          pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SUREFIRE-XXX] - Fixes bug in ApproximateQuantiles`,
          where you replace `SUREFIRE-XXX` with the appropriate JIRA issue. Best practice
          is to use the JIRA issue title in the pull request title and in the first line of the 
          commit message.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `mvn clean install` to make sure basic checks pass. A more thorough check will 
          be performed on your pull request automatically.
    - [ ] You have run the integration tests successfully (`mvn -Prun-its clean install`).
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under 
   the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
    
    Our company, Atlassian, has a corporate CLA signed, and we added our team to it.
   Contributors: Alex Courtis, Bing Xu and Hubert Grzeskowiak
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "hubertgrzeskowiak (via GitHub)" <gi...@apache.org>.
hubertgrzeskowiak commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1798627583


##########
maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java:
##########
@@ -84,12 +85,14 @@ public static RunResult toRunResult(File failsafeSummaryXml) throws Exception {
             String skipped = xpath.evaluate("/failsafe-summary/skipped", root);
             String failureMessage = xpath.evaluate("/failsafe-summary/failureMessage", root);
             String timeout = xpath.evaluate("/failsafe-summary/@timeout", root);
+            String flakes = xpath.evaluate("/failsafe-summary/flakes", root);

Review Comment:
   nit: would be better to move this two lines up, right under `skipped`. `completed`, `errors`, `failures` and `skipped` all belong to the same type of field as `flakes`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1813051391


##########
maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java:
##########
@@ -64,6 +69,49 @@ public void testSkipped() throws Exception {
         writeReadCheck(new RunResult(3, 2, 1, 0, null, true));
     }
 
+    @Test
+    public void testFlakes() throws Exception {
+        writeReadCheck(new RunResult(3, 2, 1, 0, 2, null, true));
+    }
+
+    @Test
+    public void testLegacyDeserialization() throws Exception {

Review Comment:
   I 100% disagree. Consistency with imperfect code is **not** a virtue. New code should follow best practices, even when the old code does not. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#issuecomment-2443915493

   I have corrected the line ending of all XSD files, please rebase and we will run ITs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "bingx1 (via GitHub)" <gi...@apache.org>.
bingx1 commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1820563676


##########
maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd:
##########
@@ -1 +1 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="flakes" type="xsd:int" nillable="true"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>

Review Comment:
   TIL; thanks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o closed pull request #790: [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml
URL: https://github.com/apache/maven-surefire/pull/790


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "bingx1 (via GitHub)" <gi...@apache.org>.
bingx1 commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1811685332


##########
maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java:
##########
@@ -64,6 +69,49 @@ public void testSkipped() throws Exception {
         writeReadCheck(new RunResult(3, 2, 1, 0, null, true));
     }
 
+    @Test
+    public void testFlakes() throws Exception {
+        writeReadCheck(new RunResult(3, 2, 1, 0, 2, null, true));
+    }
+
+    @Test
+    public void testLegacyDeserialization() throws Exception {
+        File legacySummary = SureFireFileManager.createTempFile("failsafe", "test");
+        String legacyFailsafeSummaryXmlTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+                + "<failsafe-summary xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+                + " xsi:noNamespaceSchemaLocation=\"https://maven.apache.org/surefire/maven-surefire-plugin/xsd/failsafe-summary.xsd\""
+                + " result=\"%s\" timeout=\"%s\">\n"
+                + "    <completed>%d</completed>\n"
+                + "    <errors>%d</errors>\n"
+                + "    <failures>%d</failures>\n"
+                + "    <skipped>%d</skipped>\n"
+                + "    %s\n"
+                + "</failsafe-summary>";
+        String xml = format(Locale.ROOT, legacyFailsafeSummaryXmlTemplate, 0, false, 3, 2, 1, 0, "msg");
+        Files.write(
+                legacySummary.toPath(),
+                xml.getBytes(StandardCharsets.UTF_8),
+                StandardOpenOption.CREATE,
+                StandardOpenOption.TRUNCATE_EXISTING,
+                StandardOpenOption.WRITE);
+
+        // When the failsafe-summary.xml does not contain the <flakes> element, it should be considered as 0.
+        RunResult expected = new RunResult(3, 2, 1, 0, 0, null, false);
+        RunResult actual = FailsafeSummaryXmlUtils.toRunResult(legacySummary);
+
+        assertThat(actual.getCompletedCount()).isEqualTo(expected.getCompletedCount());

Review Comment:
   Again, I wrote this assertion in such a way to be consistent with the other test methods in the same file. I can change it, but do I only change it in this test or in the existing code too? I also feel this assertion isn't particularly unclear



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1820527147


##########
maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd:
##########
@@ -1 +1 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="flakes" type="xsd:int" nillable="true"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>

Review Comment:
   Can you undo a change to this file, something is off here or are you expected to change the schema?!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "bingx1 (via GitHub)" <gi...@apache.org>.
bingx1 commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1820514268


##########
maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd:
##########
@@ -1 +1 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="flakes" type="xsd:int" nillable="true"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>

Review Comment:
   This diff is really hard to understand (apologies). Which one are you referring to?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "bingx1 (via GitHub)" <gi...@apache.org>.
bingx1 commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1811684687


##########
maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java:
##########
@@ -64,6 +69,49 @@ public void testSkipped() throws Exception {
         writeReadCheck(new RunResult(3, 2, 1, 0, null, true));
     }
 
+    @Test
+    public void testFlakes() throws Exception {
+        writeReadCheck(new RunResult(3, 2, 1, 0, 2, null, true));
+    }
+
+    @Test
+    public void testLegacyDeserialization() throws Exception {

Review Comment:
   Hey, yeah I could but it's a test method, I'm not convinced it's necessary to be specific here. I was following the existing code style in this particular Test class. I think in this case it may be better to be consistent with the original style.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "bingx1 (via GitHub)" <gi...@apache.org>.
bingx1 commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1820537796


##########
maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd:
##########
@@ -1 +1 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="flakes" type="xsd:int" nillable="true"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>

Review Comment:
   `<xsd:element name="flakes" type="xsd:int" nillable="true"/>`
   
   Given I was changing the shape of the `failsafe-summary.xml`; I thought I would need to modify the .xsd - is this not necessary? Happy to undo this change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1820448168


##########
maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java:
##########
@@ -84,12 +85,14 @@ public static RunResult toRunResult(File failsafeSummaryXml) throws Exception {
             String skipped = xpath.evaluate("/failsafe-summary/skipped", root);
             String failureMessage = xpath.evaluate("/failsafe-summary/failureMessage", root);
             String timeout = xpath.evaluate("/failsafe-summary/@timeout", root);
+            String flakes = xpath.evaluate("/failsafe-summary/flakes", root);
 
             return new RunResult(
                     parseInt(completed),
                     parseInt(errors),
                     parseInt(failures),
                     parseInt(skipped),
+                    isBlank(flakes) ? 0 : parseInt(flakes),

Review Comment:
   I agree here, a comment with a remove/replace to `parseInt()` in the future.



##########
surefire-api/src/main/java/org/apache/maven/surefire/api/suite/RunResult.java:
##########
@@ -202,6 +202,9 @@ public boolean equals(Object o) {
         if (skipped != runResult.skipped) {
             return false;
         }
+        if (flakes != runResult.flakes) {
+            return false;
+        }
         if (timeout != runResult.timeout) {
             return false;
         }

Review Comment:
   If you modify `equals()`, why don't you modify `hashCode()` as well?



##########
maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd:
##########
@@ -1 +1 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="flakes" type="xsd:int" nillable="true"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>

Review Comment:
   What happended to line ending here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "hubertgrzeskowiak (via GitHub)" <gi...@apache.org>.
hubertgrzeskowiak commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1798627694


##########
maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java:
##########
@@ -84,12 +85,14 @@ public static RunResult toRunResult(File failsafeSummaryXml) throws Exception {
             String skipped = xpath.evaluate("/failsafe-summary/skipped", root);
             String failureMessage = xpath.evaluate("/failsafe-summary/failureMessage", root);
             String timeout = xpath.evaluate("/failsafe-summary/@timeout", root);
+            String flakes = xpath.evaluate("/failsafe-summary/flakes", root);
 
             return new RunResult(
                     parseInt(completed),
                     parseInt(errors),
                     parseInt(failures),
                     parseInt(skipped),
+                    isBlank(flakes) ? 0 : parseInt(flakes),

Review Comment:
   nit: do you reckon it's worth adding a comment why we are treating this differently, i.e. because of backward compatibility?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "hubertgrzeskowiak (via GitHub)" <gi...@apache.org>.
hubertgrzeskowiak commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1798627583


##########
maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java:
##########
@@ -84,12 +85,14 @@ public static RunResult toRunResult(File failsafeSummaryXml) throws Exception {
             String skipped = xpath.evaluate("/failsafe-summary/skipped", root);
             String failureMessage = xpath.evaluate("/failsafe-summary/failureMessage", root);
             String timeout = xpath.evaluate("/failsafe-summary/@timeout", root);
+            String flakes = xpath.evaluate("/failsafe-summary/flakes", root);

Review Comment:
   nit: would be better to move this two lines up, right under `skipped`. `completed`, `errors`, `failures` and `skipped` all belong to the same type of field as `flakes`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1802043542


##########
maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java:
##########
@@ -64,6 +69,49 @@ public void testSkipped() throws Exception {
         writeReadCheck(new RunResult(3, 2, 1, 0, null, true));
     }
 
+    @Test
+    public void testFlakes() throws Exception {

Review Comment:
   can you be more specific about the exception thrown?



##########
maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java:
##########
@@ -64,6 +69,49 @@ public void testSkipped() throws Exception {
         writeReadCheck(new RunResult(3, 2, 1, 0, null, true));
     }
 
+    @Test
+    public void testFlakes() throws Exception {
+        writeReadCheck(new RunResult(3, 2, 1, 0, 2, null, true));
+    }
+
+    @Test
+    public void testLegacyDeserialization() throws Exception {

Review Comment:
   can you be more specific about the exception thrown?



##########
maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java:
##########
@@ -64,6 +69,49 @@ public void testSkipped() throws Exception {
         writeReadCheck(new RunResult(3, 2, 1, 0, null, true));
     }
 
+    @Test
+    public void testFlakes() throws Exception {
+        writeReadCheck(new RunResult(3, 2, 1, 0, 2, null, true));
+    }
+
+    @Test
+    public void testLegacyDeserialization() throws Exception {
+        File legacySummary = SureFireFileManager.createTempFile("failsafe", "test");
+        String legacyFailsafeSummaryXmlTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+                + "<failsafe-summary xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+                + " xsi:noNamespaceSchemaLocation=\"https://maven.apache.org/surefire/maven-surefire-plugin/xsd/failsafe-summary.xsd\""
+                + " result=\"%s\" timeout=\"%s\">\n"
+                + "    <completed>%d</completed>\n"
+                + "    <errors>%d</errors>\n"
+                + "    <failures>%d</failures>\n"
+                + "    <skipped>%d</skipped>\n"
+                + "    %s\n"
+                + "</failsafe-summary>";
+        String xml = format(Locale.ROOT, legacyFailsafeSummaryXmlTemplate, 0, false, 3, 2, 1, 0, "msg");
+        Files.write(
+                legacySummary.toPath(),
+                xml.getBytes(StandardCharsets.UTF_8),
+                StandardOpenOption.CREATE,
+                StandardOpenOption.TRUNCATE_EXISTING,
+                StandardOpenOption.WRITE);
+
+        // When the failsafe-summary.xml does not contain the <flakes> element, it should be considered as 0.
+        RunResult expected = new RunResult(3, 2, 1, 0, 0, null, false);
+        RunResult actual = FailsafeSummaryXmlUtils.toRunResult(legacySummary);
+
+        assertThat(actual.getCompletedCount()).isEqualTo(expected.getCompletedCount());

Review Comment:
   assertEquals is simpler and more obvious



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#discussion_r1820550530


##########
maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd:
##########
@@ -1 +1 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements.  See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership.  The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License.  You may obtain a copy of the License at ~ ~     http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied.  See the License for the ~ specific language governing permissions and limitations ~ under the License. --> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <xsd:element name="failsafe-summary">         <xsd:complexType>      
        <xsd:sequence>                 <xsd:element name="completed" type="xsd:int"/>                 <xsd:element name="errors" type="xsd:int"/>                 <xsd:element name="failures" type="xsd:int"/>                 <xsd:element name="skipped" type="xsd:int"/>                 <xsd:element name="flakes" type="xsd:int" nillable="true"/>                 <xsd:element name="failureMessage" type="xsd:string" nillable="true"/>             </xsd:sequence>             <xsd:attribute name="result" type="errorType" use="optional"/>             <xsd:attribute name="timeout" type="xsd:boolean" use="required"/>         </xsd:complexType>     </xsd:element>     <xsd:simpleType name="errorType">         <xsd:restriction base="xsd:string">             <xsd:enumeration id="FAILURE" value="255"/>             <xsd:enumeration id="NO_TESTS" value="254"/>         </xsd:restriction>     </xsd:simpleType> </xsd:schema>

Review Comment:
   ...right, but nillable and minOccurs are two different things. See https://github.com/apache/maven-surefire/pull/790/files#r1820448168. I consider the usage of nillable non-reasonable. Make it `minOccurs="0"` with a comment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SUREFIRE-2277] Fix bug in RunResult serialisation/deserialisation to (from) failsafe-summary.xml [maven-surefire]

Posted by "bingx1 (via GitHub)" <gi...@apache.org>.
bingx1 commented on PR #790:
URL: https://github.com/apache/maven-surefire/pull/790#issuecomment-2444053795

   > I have corrected the line ending of all XSD files, please rebase and we will run ITs.
   
   Done


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org