From 3ef7f91f1eea0edc3d3867d990556b5cb2b94258 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 8 Oct 2022 09:04:54 +0200 Subject: [PATCH] bless cargo-miri output I think cargo has a bug here: https://github.com/rust-lang/cargo/issues/11191 but for now we bless its output so that we can keep CI green --- README.md | 9 ++++----- test-cargo-miri/run-test.py | 5 ++++- test-cargo-miri/test.filter.cross-target.stdout.ref | 5 +++++ test-cargo-miri/test.filter.stdout.ref | 10 +++++----- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d75f0cc1e80d4..7ad51520a4287 100644 --- a/README.md +++ b/README.md @@ -435,11 +435,10 @@ Moreover, Miri recognizes some environment variables: purpose. * `MIRI_NO_STD` (recognized by `cargo miri` and the test suite) makes sure that the target's sysroot is built without libstd. This allows testing and running no_std programs. -* `MIRI_BLESS` (recognized by the test suite) overwrite all `stderr` and `stdout` files - instead of checking whether the output matches. -* `MIRI_SKIP_UI_CHECKS` (recognized by the test suite) don't check whether the - `stderr` or `stdout` files match the actual output. Useful for the rustc test suite - which has subtle differences that we don't care about. +* `MIRI_BLESS` (recognized by the test suite and `cargo-miri-test/run-test.py`): overwrite all + `stderr` and `stdout` files instead of checking whether the output matches. +* `MIRI_SKIP_UI_CHECKS` (recognized by the test suite): don't check whether the + `stderr` or `stdout` files match the actual output. The following environment variables are *internal* and must not be used by anyone but Miri itself. They are used to communicate between different Miri diff --git a/test-cargo-miri/run-test.py b/test-cargo-miri/run-test.py index 4485d3252ccc2..c611b9c44be9d 100755 --- a/test-cargo-miri/run-test.py +++ b/test-cargo-miri/run-test.py @@ -33,10 +33,13 @@ def normalize_stderr(str): return str def check_output(actual, path, name): + if 'MIRI_BLESS' in os.environ: + open(path, mode='w').write(actual) + return True expected = open(path).read() if expected == actual: return True - print(f"{path} did not match reference!") + print(f"{name} output did not match reference in {path}!") print(f"--- BEGIN diff {name} ---") for text in difflib.unified_diff(expected.split("\n"), actual.split("\n")): print(text) diff --git a/test-cargo-miri/test.filter.cross-target.stdout.ref b/test-cargo-miri/test.filter.cross-target.stdout.ref index bb0282d6c9167..39e1857060d04 100644 --- a/test-cargo-miri/test.filter.cross-target.stdout.ref +++ b/test-cargo-miri/test.filter.cross-target.stdout.ref @@ -1,4 +1,9 @@ +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out + + running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out diff --git a/test-cargo-miri/test.filter.stdout.ref b/test-cargo-miri/test.filter.stdout.ref index c618956656a8a..39e1857060d04 100644 --- a/test-cargo-miri/test.filter.stdout.ref +++ b/test-cargo-miri/test.filter.stdout.ref @@ -1,4 +1,9 @@ +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out + + running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out @@ -10,8 +15,3 @@ test simple ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out; finished in $TIME -