summaryrefslogtreecommitdiffstats
path: root/src/test/run-make-fulldeps/libtest-json
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/run-make-fulldeps/libtest-json/Makefile18
-rw-r--r--src/test/run-make-fulldeps/libtest-json/f.rs22
-rw-r--r--src/test/run-make-fulldeps/libtest-json/output-default.json10
-rw-r--r--src/test/run-make-fulldeps/libtest-json/output-stdout-success.json10
-rwxr-xr-xsrc/test/run-make-fulldeps/libtest-json/validate_json.py8
5 files changed, 68 insertions, 0 deletions
diff --git a/src/test/run-make-fulldeps/libtest-json/Makefile b/src/test/run-make-fulldeps/libtest-json/Makefile
new file mode 100644
index 000000000..67b5fc2ed
--- /dev/null
+++ b/src/test/run-make-fulldeps/libtest-json/Makefile
@@ -0,0 +1,18 @@
+-include ../tools.mk
+
+# Test expected libtest's JSON output
+
+OUTPUT_FILE_DEFAULT := $(TMPDIR)/libtest-json-output-default.json
+OUTPUT_FILE_STDOUT_SUCCESS := $(TMPDIR)/libtest-json-output-stdout-success.json
+
+all: f.rs validate_json.py output-default.json output-stdout-success.json
+ $(RUSTC) --test f.rs
+ RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=json > $(OUTPUT_FILE_DEFAULT) || true
+ RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=json --show-output > $(OUTPUT_FILE_STDOUT_SUCCESS) || true
+
+ cat $(OUTPUT_FILE_DEFAULT) | "$(PYTHON)" validate_json.py
+ cat $(OUTPUT_FILE_STDOUT_SUCCESS) | "$(PYTHON)" validate_json.py
+
+ # Normalize the actual output and compare to expected output file
+ cat $(OUTPUT_FILE_DEFAULT) | sed 's/"exec_time": [0-9.]*/"exec_time": $$TIME/' | diff output-default.json -
+ cat $(OUTPUT_FILE_STDOUT_SUCCESS) | sed 's/"exec_time": [0-9.]*/"exec_time": $$TIME/' | diff output-stdout-success.json -
diff --git a/src/test/run-make-fulldeps/libtest-json/f.rs b/src/test/run-make-fulldeps/libtest-json/f.rs
new file mode 100644
index 000000000..edfe25086
--- /dev/null
+++ b/src/test/run-make-fulldeps/libtest-json/f.rs
@@ -0,0 +1,22 @@
+#[test]
+fn a() {
+ println!("print from successful test");
+ // Should pass
+}
+
+#[test]
+fn b() {
+ assert!(false);
+}
+
+#[test]
+#[should_panic]
+fn c() {
+ assert!(false);
+}
+
+#[test]
+#[ignore = "msg"]
+fn d() {
+ assert!(false);
+}
diff --git a/src/test/run-make-fulldeps/libtest-json/output-default.json b/src/test/run-make-fulldeps/libtest-json/output-default.json
new file mode 100644
index 000000000..63342abc6
--- /dev/null
+++ b/src/test/run-make-fulldeps/libtest-json/output-default.json
@@ -0,0 +1,10 @@
+{ "type": "suite", "event": "started", "test_count": 4 }
+{ "type": "test", "event": "started", "name": "a" }
+{ "type": "test", "name": "a", "event": "ok" }
+{ "type": "test", "event": "started", "name": "b" }
+{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
+{ "type": "test", "event": "started", "name": "c" }
+{ "type": "test", "name": "c", "event": "ok" }
+{ "type": "test", "event": "started", "name": "d" }
+{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
+{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
diff --git a/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json b/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json
new file mode 100644
index 000000000..8f1911446
--- /dev/null
+++ b/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json
@@ -0,0 +1,10 @@
+{ "type": "suite", "event": "started", "test_count": 4 }
+{ "type": "test", "event": "started", "name": "a" }
+{ "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" }
+{ "type": "test", "event": "started", "name": "b" }
+{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
+{ "type": "test", "event": "started", "name": "c" }
+{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:15:5\n" }
+{ "type": "test", "event": "started", "name": "d" }
+{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
+{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
diff --git a/src/test/run-make-fulldeps/libtest-json/validate_json.py b/src/test/run-make-fulldeps/libtest-json/validate_json.py
new file mode 100755
index 000000000..657f732f2
--- /dev/null
+++ b/src/test/run-make-fulldeps/libtest-json/validate_json.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+import sys
+import json
+
+# Try to decode line in order to ensure it is a valid JSON document
+for line in sys.stdin:
+ json.loads(line)