Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import javax.xml.stream.XMLStreamException;
import org.codehaus.staxmate.in.ElementFilter;
import org.codehaus.staxmate.in.SMHierarchicCursor;
Expand All @@ -39,7 +40,7 @@ private static TestCase parseTestCaseTag(SMInputCursor testCaseCursor) throws XM
Double time = parseTime(testCaseCursor);
TestCaseStatus status = TestCaseStatus.OK;
String stack = "";
String msg = "";
Optional<String> msg = Optional.empty();

String file = testCaseCursor.getAttrValue("file");
String testClassName = testCaseCursor.getAttrValue("classname");
Expand All @@ -52,15 +53,19 @@ private static TestCase parseTestCaseTag(SMInputCursor testCaseCursor) throws XM
status = TestCaseStatus.SKIPPED;
} else if (TestCaseStatus.FAILURE.equals(testCaseStatus)) {
status = TestCaseStatus.FAILURE;
msg = getExpectedAttribute(childCursor, "message");
msg = getOptionalAttribute(childCursor, "message");
stack = childCursor.collectDescendantText();
} else if (TestCaseStatus.ERROR.equals(testCaseStatus)) {
status = TestCaseStatus.ERROR;
msg = getExpectedAttribute(childCursor, "message");
msg = getOptionalAttribute(childCursor, "message");
stack = childCursor.collectDescendantText();
}
}
return new TestCase(name, status, stack, msg, time.intValue(), file, testClassName);
String message ="";
if (msg.isPresent()){
message=msg.get();
}
return new TestCase(name, status, stack, message, time.intValue(), file, testClassName);
}

private static double parseTime(SMInputCursor testCaseCursor) throws XMLStreamException {
Expand All @@ -82,6 +87,14 @@ private static String getExpectedAttribute(SMInputCursor testCaseCursor, String
return attrValue;
}

private static Optional<String> getOptionalAttribute(SMInputCursor testCaseCursor, String attributeName) throws XMLStreamException {
String attrValue = testCaseCursor.getAttrValue(attributeName);
if (attrValue == null) {
return Optional.empty();
}
return Optional.of(attrValue);
}

private static String parseTestCaseName(SMInputCursor testCaseCursor) throws XMLStreamException {
String name = getExpectedAttribute(testCaseCursor, "name");
String classname = testCaseCursor.getAttrValue("CLASSNAME");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ public void shouldReportNothingWhenNoReportFound() {
assertThat(context.measures(context.module().key())).isEmpty();
}

@Test
public void test_report_with_failure_no_message() {

settings.setProperty(XUnitSensor.REPORT_PATH_KEY, "cargo-nextest.xml");
context = SensorContextTester.create(moduleBaseDir);
context.setSettings(settings);

unitSensor.execute(context);
assertThat(moduleMeasure(CoreMetrics.TESTS)).isEqualTo(6);
assertThat(moduleMeasure(CoreMetrics.SKIPPED_TESTS)).isEqualTo(0);
assertThat(moduleMeasure(CoreMetrics.TEST_ERRORS)).isEqualTo(0);
assertThat(moduleMeasure(CoreMetrics.TEST_FAILURES)).isEqualTo(1);
}

private Integer moduleMeasure(Metric<Integer> metric) {
return measure(context.module(), metric);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="nextest-run" tests="6" failures="1" errors="0" uuid="2535f8b1-dc49-4ef5-984a-0d138c39f82c" timestamp="2023-09-27T12:19:18.220+00:00" time="0.201">
<testsuite name="unicode-xid" tests="4" disabled="0" errors="0" failures="1">
<testcase name="tests::test_is_not_xid_continue" classname="unicode-xid" timestamp="2023-09-27T12:19:18.222+00:00" time="0.014">
</testcase>
<testcase name="tests::test_is_not_xid_start" classname="unicode-xid" timestamp="2023-09-27T12:19:18.225+00:00" time="0.016">
</testcase>
<testcase name="tests::test_is_xid_continue" classname="unicode-xid" timestamp="2023-09-27T12:19:18.226+00:00" time="0.018">
</testcase>
<testcase name="tests::test_is_xid_start" classname="unicode-xid" timestamp="2023-09-27T12:19:18.228+00:00" time="0.017">
<failure type="test failure">thread &apos;tests::test_is_xid_start&apos; panicked at &apos;assertion failed: false&apos;, src/tests.rs:62:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace</failure>
<system-out>
running 1 test
test tests::test_is_xid_start ... FAILED

failures:

failures:
tests::test_is_xid_start

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

</system-out>
<system-err>thread &apos;tests::test_is_xid_start&apos; panicked at &apos;assertion failed: false&apos;, src/tests.rs:62:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
</system-err>
</testcase>
</testsuite>
<testsuite name="unicode-xid::exhaustive_tests" tests="2" disabled="0" errors="0" failures="0">
<testcase name="all_valid_chars_do_not_panic_for_is_xid_start" classname="unicode-xid::exhaustive_tests" timestamp="2023-09-27T12:19:18.241+00:00" time="0.167">
</testcase>
<testcase name="all_valid_chars_do_not_panic_for_is_xid_continue" classname="unicode-xid::exhaustive_tests" timestamp="2023-09-27T12:19:18.236+00:00" time="0.184">
</testcase>
</testsuite>
</testsuites>