Skip to content

Commit 0e110a5

Browse files
committed
Port tests/run-make/libtest-json to tests/ui
1 parent c8e3bbf commit 0e110a5

File tree

7 files changed

+54
-57
lines changed

7 files changed

+54
-57
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ run-make/issue-88756-default-output/Makefile
8787
run-make/issue-97463-abi-param-passing/Makefile
8888
run-make/jobserver-error/Makefile
8989
run-make/libs-through-symlinks/Makefile
90-
run-make/libtest-json/Makefile
9190
run-make/libtest-junit/Makefile
9291
run-make/libtest-padding/Makefile
9392
run-make/libtest-thread-limit/Makefile

tests/run-make/libtest-json/Makefile

-20
This file was deleted.

tests/run-make/libtest-json/f.rs

-22
This file was deleted.

tests/run-make/libtest-json/validate_json.py

-8
This file was deleted.

tests/run-make/libtest-json/output-default.json renamed to tests/ui/test-attrs/format-json.normal.run.stdout

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
{ "type": "test", "event": "started", "name": "a" }
33
{ "type": "test", "name": "a", "event": "ok" }
44
{ "type": "test", "event": "started", "name": "b" }
5-
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
5+
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at $DIR/format-json.rs:LL:5:
6+
assertion failed: false
7+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
8+
" }
69
{ "type": "test", "event": "started", "name": "c" }
710
{ "type": "test", "name": "c", "event": "ok" }
811
{ "type": "test", "event": "started", "name": "d" }
912
{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
10-
{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
13+
{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": "$EXEC_TIME" }

tests/ui/test-attrs/format-json.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//@ edition: 2021
2+
//@ run-fail
3+
//@ check-run-results
4+
//@ check-run-stdout-is-json-lines
5+
//@ needs-unwind (for #[should_panic])
6+
// ignore-tidy-linelength
7+
8+
//@ revisions: normal show-output
9+
//@ compile-flags: --test
10+
//@ run-flags: --test-threads=1 -Zunstable-options --format=json
11+
//@ [show-output] run-flags: --show-output
12+
//@ normalize-stdout-test: "(?<prefix>format-json.rs:)[0-9]+(?<suffix>:[0-9]+)" -> "${prefix}LL${suffix}"
13+
//@ normalize-stdout-test: "(?<prefix>\"exec_time\": *)[0-9.]+" -> "${prefix}\"$$EXEC_TIME\""
14+
15+
// Check that passing `--format=json` to the test harness produces output that
16+
// matches the snapshot, and is valid JSON-lines.
17+
18+
#[test]
19+
fn a() {
20+
println!("print from successful test");
21+
// Should pass
22+
}
23+
24+
#[test]
25+
fn b() {
26+
assert!(false);
27+
}
28+
29+
#[test]
30+
#[should_panic]
31+
fn c() {
32+
assert!(false);
33+
}
34+
35+
#[test]
36+
#[ignore = "msg"]
37+
fn d() {
38+
assert!(false);
39+
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
{ "type": "suite", "event": "started", "test_count": 4 }
22
{ "type": "test", "event": "started", "name": "a" }
3-
{ "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" }
3+
{ "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test
4+
" }
45
{ "type": "test", "event": "started", "name": "b" }
5-
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
6+
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at $DIR/format-json.rs:LL:5:
7+
assertion failed: false
8+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
9+
" }
610
{ "type": "test", "event": "started", "name": "c" }
7-
{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at f.rs:15:5:\nassertion failed: false\n" }
11+
{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at $DIR/format-json.rs:LL:5:
12+
assertion failed: false
13+
" }
814
{ "type": "test", "event": "started", "name": "d" }
915
{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
10-
{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
16+
{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": "$EXEC_TIME" }

0 commit comments

Comments
 (0)