C4tWithShell / community-rust

SonarQube plugin to analyze Rust files
GNU Lesser General Public License v3.0
124 stars 10 forks source link

'message' attribute is optional in junit.xsd #67

Closed mstyura closed 1 year ago

mstyura commented 1 year ago

The xunit report produced by cargo-nextest can't be imported by sonar-rust due to invalid assumption that message attribute is mandatory:

20:28:11.239 DEBUG: Using pattern './target/nextest/gitlab/cargo-nextest-run.junit.xml' to find reports
20:28:11.254 WARN: Cannot read report './target/nextest/gitlab/cargo-nextest-run.junit.xml', the following exception occurred: Missing attribute 'message' at line 11
20:28:11.255 INFO: Sensor XUnit Sensor for Rust [communityrust] (done) | time=17ms

Example cargo-nextest-run.junit.xml:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="nextest-run" tests="5" failures="1" errors="0" uuid="40a8f42f-df59-494f-bb6b-a9f4b2e8bd94" timestamp="2023-09-15T20:00:39.279+00:00" time="0.029">
    <testsuite name="test-ci::integration_test" tests="1" disabled="0" errors="0" failures="0">
        <testcase name="test_integration" classname="test-ci::integration_test" timestamp="2023-09-15T20:00:39.285+00:00" time="0.005">
        </testcase>
    </testsuite>
    <testsuite name="test-ci" tests="4" disabled="0" errors="0" failures="1">
        <testcase name="tests::test_bad_sum" classname="test-ci" timestamp="2023-09-15T20:00:39.280+00:00" time="0.006">
        </testcase>
        <testcase name="tests::test_covered_sum" classname="test-ci" timestamp="2023-09-15T20:00:39.280+00:00" time="0.006">
        </testcase>
        <testcase name="tests::test_success" classname="test-ci" timestamp="2023-09-15T20:00:39.282+00:00" time="0.006">
        </testcase>
        <testcase name="tests::test_failure" classname="test-ci" timestamp="2023-09-15T20:00:39.281+00:00" time="0.023">
            <failure type="test failure">thread &apos;tests::test_failure&apos; panicked at &apos;assertion failed: `(left == right)`
  left: `false`,
 right: `true`&apos;, src/lib.rs:44:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::&lt;bool, bool&gt;
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:229:5
   4: test_ci::tests::test_failure
             at ./src/lib.rs:44:9
   5: test_ci::tests::test_failure::{closure#0}
             at ./src/lib.rs:43:23
   6: &lt;test_ci::tests::test_failure::{closure#0} as core::ops::function::FnOnce&lt;()&gt;&gt;::call_once
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/ops/function.rs:250:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.</failure>
            <system-out>
running 1 test
test tests::test_failure ... FAILED

failures:

failures:
    tests::test_failure

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 3 filtered out; finished in 0.02s

</system-out>
            <system-err>thread &apos;tests::test_failure&apos; panicked at &apos;assertion failed: `(left == right)`
  left: `false`,
 right: `true`&apos;, src/lib.rs:44:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::&lt;bool, bool&gt;
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:229:5
   4: test_ci::tests::test_failure
             at ./src/lib.rs:44:9
   5: test_ci::tests::test_failure::{closure#0}
             at ./src/lib.rs:43:23
   6: &lt;test_ci::tests::test_failure::{closure#0} as core::ops::function::FnOnce&lt;()&gt;&gt;::call_once
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/ops/function.rs:250:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
</system-err>
        </testcase>
    </testsuite>
</testsuites>
elegoff commented 1 year ago

Thanks a lot for your report. The messageattribute has been made optional in the parsing and it should allow for cargo-nextest junit reports to be parsed