Skip to content

Commit d83cfeb

Browse files
committed
Auto merge of #113298 - tgross35:update-bless-envs, r=oli-obk
Unite bless environment variables under `RUST_BLESS` Currently, Clippy and Miri both use an environment variable to indicate that output should be blessed, but they use different variable names. In order to improve consistency, this patch applies the following changes: - Rename the variable `MIRI_BLESS` (as used in the Miri subtree) to `RUST_BLESS` - Rename the variable `BLESS` (as used in the Clippy subtree) to `RUST_BLESS` - Move emitting `RUST_BLESS` into `prepare_cargo_test` so it is always available (I need this for a WIP PR) --- I prefer something like `RUST_BLESS` to `BLESS` just for a lower chance of conflict (not super common but other tools [do use `BLESS`](https://grep.app/search?q=%22BLESS%22&case=true&words=true&filter[lang][0]=Text&filter[lang][1]=Rust&filter[lang][2]=Python&filter[lang][3]=C%2B%2B&filter[lang][4]=Markdown&filter[lang][5]=C&filter[lang][6]=JSON)), but I can change it to whatever is preferred. Original discussion: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/BLESS.20env.20var.3A.20rename.20to.20CLIPPY_BLESS r? `@oli-obk` cc `@flip1995`
2 parents 3ba315f + 2c502c5 commit d83cfeb

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ Moreover, Miri recognizes some environment variables:
482482
purpose.
483483
* `MIRI_NO_STD` (recognized by `cargo miri` and the test suite) makes sure that the target's
484484
sysroot is built without libstd. This allows testing and running no_std programs.
485-
* `MIRI_BLESS` (recognized by the test suite and `cargo-miri-test/run-test.py`): overwrite all
485+
* `RUSTC_BLESS` (recognized by the test suite and `cargo-miri-test/run-test.py`): overwrite all
486486
`stderr` and `stdout` files instead of checking whether the output matches.
487487
* `MIRI_SKIP_UI_CHECKS` (recognized by the test suite): don't check whether the
488488
`stderr` or `stdout` files match the actual output.

miri

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ test|bless)
303303
$CARGO build $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml
304304
find_sysroot
305305
if [ "$COMMAND" = "bless" ]; then
306-
export MIRI_BLESS="Gesundheit"
306+
export RUSTC_BLESS="Gesundheit"
307307
fi
308308
# Then test, and let caller control flags.
309309
# Only in root project as `cargo-miri` has no tests.

test-cargo-miri/run-test.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import difflib
99
import os
1010
import re
11-
import sys
1211
import subprocess
12+
import sys
1313

1414
CGREEN = '\33[32m'
1515
CBOLD = '\33[1m'
@@ -37,7 +37,8 @@ def normalize_stderr(str):
3737
return str
3838

3939
def check_output(actual, path, name):
40-
if 'MIRI_BLESS' in os.environ:
40+
if os.environ.get("RUSTC_BLESS", "0") != "0":
41+
# Write the output only if bless is set
4142
open(path, mode='w').write(actual)
4243
return True
4344
expected = open(path).read()

tests/compiletest.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
7272
program.args.push(flag);
7373
}
7474

75+
let bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v !="0");
7576
let skip_ui_checks = env::var_os("MIRI_SKIP_UI_CHECKS").is_some();
7677

77-
let output_conflict_handling = match (env::var_os("MIRI_BLESS").is_some(), skip_ui_checks) {
78+
let output_conflict_handling = match (bless, skip_ui_checks) {
7879
(false, false) => OutputConflictHandling::Error("./miri bless".into()),
7980
(true, false) => OutputConflictHandling::Bless,
8081
(false, true) => OutputConflictHandling::Ignore,
81-
(true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
82+
(true, true) => panic!("cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
8283
};
8384

8485
let mut config = Config {

0 commit comments

Comments
 (0)