提交 269cbc20 编写于 作者: R Ralf Jung

respect CARGO_EXTRA_FLAGS in more places

上级 95fe7ab2
......@@ -52,7 +52,7 @@ function run_tests {
# Also run some many-seeds tests. 64 seeds means this takes around a minute per test.
for FILE in tests/many-seeds/*.rs; do
MIRI_SEEDS=64 CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS -q" ./miri many-seeds ./miri run "$FILE"
MIRI_SEEDS=64 ./miri many-seeds ./miri run "$FILE"
done
# Check that the benchmarks build and run, but without actually benchmarking.
......
......@@ -2,5 +2,5 @@
set -e
# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly. Invoking `cargo run` goes through
# rustup (that sets it's own environmental variables), which is undesirable.
cargo build -q --manifest-path "$(dirname "$0")"/miri-script/Cargo.toml
cargo build $CARGO_EXTRA_FLAGS -q --manifest-path "$(dirname "$0")"/miri-script/Cargo.toml
"$(dirname "$0")"/miri-script/target/debug/miri-script "$@"
......@@ -319,6 +319,8 @@ fn bench(benches: Vec<OsString>) -> Result<()> {
let Some((program_name, args)) = hyperfine.split_first() else {
bail!("expected HYPERFINE environment variable to be non-empty");
};
// Extra flags to pass to cargo.
let cargo_extra_flags = std::env::var("CARGO_EXTRA_FLAGS").unwrap_or_default();
// Make sure we have an up-to-date Miri installed and selected the right toolchain.
Self::install(vec![])?;
......@@ -341,7 +343,7 @@ fn bench(benches: Vec<OsString>) -> Result<()> {
// That seems to make Windows CI happy.
cmd!(
sh,
"{program_name} {args...} 'cargo miri run --manifest-path \"'{current_bench}'\"'"
"{program_name} {args...} 'cargo miri run '{cargo_extra_flags}' --manifest-path \"'{current_bench}'\"'"
)
.run()?;
}
......
......@@ -15,12 +15,14 @@ CGREEN = '\33[32m'
CBOLD = '\33[1m'
CEND = '\33[0m'
CARGO_EXTRA_FLAGS = os.environ.get("CARGO_EXTRA_FLAGS", "").split()
def fail(msg):
print("\nTEST FAIL: {}".format(msg))
sys.exit(1)
def cargo_miri(cmd, quiet = True):
args = ["cargo", "miri", cmd]
args = ["cargo", "miri", cmd] + CARGO_EXTRA_FLAGS
if quiet:
args += ["-q"]
if 'MIRI_TEST_TARGET' in os.environ:
......
......@@ -16,6 +16,11 @@ fn get_host() -> String {
.host
}
pub fn flagsplit(flags: &str) -> Vec<String> {
// This code is taken from `RUSTFLAGS` handling in cargo.
flags.split(' ').map(str::trim).filter(|s| !s.is_empty()).map(str::to_string).collect()
}
// Build the shared object file for testing external C function calls.
fn build_so_for_c_ffi_tests() -> PathBuf {
let cc = option_env!("CC").unwrap_or("cc");
......@@ -100,14 +105,16 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
if with_dependencies && use_std {
config.dependencies_crate_manifest_path =
Some(Path::new("test_dependencies").join("Cargo.toml"));
config.dependency_builder.args = vec![
"run".into(),
let mut builder_args = vec!["run".into()];
builder_args.extend(flagsplit(&env::var("CARGO_EXTRA_FLAGS").unwrap_or_default()));
builder_args.extend([
"--manifest-path".into(),
"cargo-miri/Cargo.toml".into(),
"--".into(),
"miri".into(),
"run".into(), // There is no `cargo miri build` so we just use `cargo miri run`.
];
]);
config.dependency_builder.args = builder_args.into_iter().map(Into::into).collect();
}
config
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册