summaryrefslogtreecommitdiffstats
path: root/tests/run-make/libtest-junit
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /tests/run-make/libtest-junit
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/libtest-junit')
-rw-r--r--tests/run-make/libtest-junit/Makefile19
-rw-r--r--tests/run-make/libtest-junit/f.rs23
-rw-r--r--tests/run-make/libtest-junit/output-default.xml1
-rw-r--r--tests/run-make/libtest-junit/output-stdout-success.xml1
-rwxr-xr-xtests/run-make/libtest-junit/validate_junit.py12
5 files changed, 56 insertions, 0 deletions
diff --git a/tests/run-make/libtest-junit/Makefile b/tests/run-make/libtest-junit/Makefile
new file mode 100644
index 000000000..d97cafccf
--- /dev/null
+++ b/tests/run-make/libtest-junit/Makefile
@@ -0,0 +1,19 @@
+# ignore-cross-compile
+include ../tools.mk
+
+# Test expected libtest's junit output
+
+OUTPUT_FILE_DEFAULT := $(TMPDIR)/libtest-junit-output-default.xml
+OUTPUT_FILE_STDOUT_SUCCESS := $(TMPDIR)/libtest-junit-output-stdout-success.xml
+
+all: f.rs validate_junit.py output-default.xml output-stdout-success.xml
+ $(RUSTC) --test f.rs
+ RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=junit > $(OUTPUT_FILE_DEFAULT) || true
+ RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=junit --show-output > $(OUTPUT_FILE_STDOUT_SUCCESS) || true
+
+ cat $(OUTPUT_FILE_DEFAULT) | "$(PYTHON)" validate_junit.py
+ cat $(OUTPUT_FILE_STDOUT_SUCCESS) | "$(PYTHON)" validate_junit.py
+
+ # Normalize the actual output and compare to expected output file
+ cat $(OUTPUT_FILE_DEFAULT) | sed 's/time="[0-9.]*"/time="$$TIME"/g' | diff output-default.xml -
+ cat $(OUTPUT_FILE_STDOUT_SUCCESS) | sed 's/time="[0-9.]*"/time="$$TIME"/g' | diff output-stdout-success.xml -
diff --git a/tests/run-make/libtest-junit/f.rs b/tests/run-make/libtest-junit/f.rs
new file mode 100644
index 000000000..d360d7731
--- /dev/null
+++ b/tests/run-make/libtest-junit/f.rs
@@ -0,0 +1,23 @@
+#[test]
+fn a() {
+ println!("print from successful test");
+ // Should pass
+}
+
+#[test]
+fn b() {
+ println!("print from failing test");
+ assert!(false);
+}
+
+#[test]
+#[should_panic]
+fn c() {
+ assert!(false);
+}
+
+#[test]
+#[ignore = "msg"]
+fn d() {
+ assert!(false);
+}
diff --git a/tests/run-make/libtest-junit/output-default.xml b/tests/run-make/libtest-junit/output-default.xml
new file mode 100644
index 000000000..d59e07b8a
--- /dev/null
+++ b/tests/run-make/libtest-junit/output-default.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"/><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>&#xA;<![CDATA[thread 'b' panicked at 'assertion failed: false', f.rs:10:5]]>&#xA;<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"/><system-out/><system-err/></testsuite></testsuites>
diff --git a/tests/run-make/libtest-junit/output-stdout-success.xml b/tests/run-make/libtest-junit/output-stdout-success.xml
new file mode 100644
index 000000000..0c300611e
--- /dev/null
+++ b/tests/run-make/libtest-junit/output-stdout-success.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"><system-out><![CDATA[print from successful test]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>&#xA;<![CDATA[thread 'b' panicked at 'assertion failed: false', f.rs:10:5]]>&#xA;<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"><system-out><![CDATA[thread 'c' panicked at 'assertion failed: false', f.rs:16:5]]>&#xA;<![CDATA[]]></system-out></testcase><system-out/><system-err/></testsuite></testsuites>
diff --git a/tests/run-make/libtest-junit/validate_junit.py b/tests/run-make/libtest-junit/validate_junit.py
new file mode 100755
index 000000000..47a8e70cc
--- /dev/null
+++ b/tests/run-make/libtest-junit/validate_junit.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+
+import sys
+import xml.etree.ElementTree as ET
+
+# Try to decode line in order to ensure it is a valid XML document
+for line in sys.stdin:
+ try:
+ ET.fromstring(line)
+ except ET.ParseError as pe:
+ print("Invalid xml: %r" % line)
+ raise