Create stub .d files
This commit is contained in:
parent
74b771423a
commit
49cd383537
2 changed files with 22 additions and 11 deletions
|
|
@ -609,6 +609,14 @@ fn phase_cargo_rustc(mut args: env::Args) {
|
|||
let print = get_arg_flag_value("--print").is_some(); // whether this is cargo passing `--print` to get some infos
|
||||
|
||||
let store_json = |info: CrateRunInfo| {
|
||||
// Create a stub .d file to stop Cargo from "rebuilding" the crate:
|
||||
// https://github.com/rust-lang/miri/issues/1724#issuecomment-787115693
|
||||
// As we store a JSON file instead of building the crate here, an empty file is fine.
|
||||
let dep_info_name = out_filename("", ".d");
|
||||
if verbose {
|
||||
eprintln!("[cargo-miri rustc] writing dep-info to `{}`", dep_info_name.display());
|
||||
}
|
||||
File::create(dep_info_name).expect("failed to create fake .d file");
|
||||
let filename = out_filename("", "");
|
||||
if verbose {
|
||||
eprintln!("[cargo-miri rustc] writing run info to `{}`", filename.display());
|
||||
|
|
|
|||
|
|
@ -50,12 +50,15 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
|
|||
print("--- END stderr ---")
|
||||
fail("exit code was {}".format(p.returncode))
|
||||
|
||||
def test_no_rebuild(name, cmd):
|
||||
def test_no_rebuild(name, cmd, env={}):
|
||||
print("Testing {}...".format(name))
|
||||
p_env = os.environ.copy()
|
||||
p_env.update(env)
|
||||
p = subprocess.Popen(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
env=p_env,
|
||||
)
|
||||
(stdout, stderr) = p.communicate()
|
||||
stdout = stdout.decode("UTF-8")
|
||||
|
|
@ -70,14 +73,20 @@ def test_no_rebuild(name, cmd):
|
|||
fail("Something was being rebuilt when it should not be (or we got no output)");
|
||||
|
||||
def test_cargo_miri_run():
|
||||
default_env={
|
||||
'MIRIFLAGS': "-Zmiri-disable-isolation",
|
||||
'MIRITESTVAR': "wrongval", # make sure the build.rs value takes precedence
|
||||
}
|
||||
test("`cargo miri run` (no isolation)",
|
||||
cargo_miri("run"),
|
||||
"run.default.stdout.ref", "run.default.stderr.ref",
|
||||
stdin=b'12\n21\n',
|
||||
env={
|
||||
'MIRIFLAGS': "-Zmiri-disable-isolation",
|
||||
'MIRITESTVAR': "wrongval", # make sure the build.rs value takes precedence
|
||||
},
|
||||
env=default_env,
|
||||
)
|
||||
# Special test: run it again *without* `-q` to make sure nothing is being rebuilt (Miri issue #1722)
|
||||
test_no_rebuild("`cargo miri run` (no rebuild, no isolation)",
|
||||
cargo_miri("run", quiet=False) + ["--", ""],
|
||||
env=default_env,
|
||||
)
|
||||
test("`cargo miri run` (with arguments and target)",
|
||||
cargo_miri("run") + ["--bin", "cargo-miri-test", "--", "hello world", '"hello world"'],
|
||||
|
|
@ -88,12 +97,6 @@ def test_cargo_miri_run():
|
|||
"run.subcrate.stdout.ref", "run.subcrate.stderr.ref",
|
||||
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
|
||||
)
|
||||
# Special test: run it again *without* `-q` to make sure nothing is being rebuilt (Miri issue #1722)
|
||||
# FIXME: move this test up to right after the first `test`
|
||||
# (currently that fails, only the 3rd and later runs are really clean... see Miri issue #1722)
|
||||
test_no_rebuild("`cargo miri run` (no rebuild)",
|
||||
cargo_miri("run", quiet=False) + ["--", ""],
|
||||
)
|
||||
|
||||
def test_cargo_miri_test():
|
||||
# rustdoc is not run on foreign targets
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue