Skip to content

Commit 3e987e1

Browse files
committed
create more fake files for cdylibs and staticlibs
1 parent f85bb0f commit 3e987e1

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

cargo-miri/bin.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,17 @@ fn phase_cargo_rustc(mut args: env::Args) {
692692
exec(cmd);
693693

694694
// Create a stub .rlib file if "link" was requested by cargo.
695+
// This is necessary to prevent cargo from doing rebuilds all the time.
695696
if emit_link_hack {
696697
// Some platforms prepend "lib", some do not... let's just create both files.
697-
let filename = out_filename("lib", ".rlib");
698-
File::create(filename).expect("failed to create rlib file");
699-
let filename = out_filename("", ".rlib");
700-
File::create(filename).expect("failed to create rlib file");
698+
File::create(out_filename("lib", ".rlib")).expect("failed to create fake .rlib file");
699+
File::create(out_filename("", ".rlib")).expect("failed to create fake .rlib file");
700+
// Just in case this is a cdylib or staticlib, also create those fake files.
701+
File::create(out_filename("lib", ".so")).expect("failed to create fake .so file");
702+
File::create(out_filename("lib", ".a")).expect("failed to create fake .a file");
703+
File::create(out_filename("lib", ".dylib")).expect("failed to create fake .dylib file");
704+
File::create(out_filename("", ".dll")).expect("failed to create fake .dll file");
705+
File::create(out_filename("", ".lib")).expect("failed to create fake .lib file");
701706
}
702707
}
703708

test-cargo-miri/run-test.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
5050
print("--- END stderr ---")
5151
fail("exit code was {}".format(p.returncode))
5252

53-
def test_rebuild(name, cmd, rebuild_count_expected):
53+
def test_no_rebuild(name, cmd):
5454
print("Testing {}...".format(name))
5555
p = subprocess.Popen(
5656
cmd,
@@ -62,12 +62,12 @@ def test_rebuild(name, cmd, rebuild_count_expected):
6262
stderr = stderr.decode("UTF-8")
6363
if p.returncode != 0:
6464
fail("rebuild failed");
65-
rebuild_count = stderr.count(" Compiling ");
66-
if rebuild_count != rebuild_count_expected:
65+
# Also check for 'Running' as a sanity check.
66+
if stderr.count(" Compiling ") > 0 or stderr.count(" Running ") == 0:
6767
print("--- BEGIN stderr ---")
6868
print(stderr, end="")
6969
print("--- END stderr ---")
70-
fail("Expected {} rebuild(s), but got {}".format(rebuild_count_expected, rebuild_count));
70+
fail("Something was being rebuilt when it should not be (or we got no output)");
7171

7272
def test_cargo_miri_run():
7373
test("`cargo miri run` (no isolation)",
@@ -89,9 +89,10 @@ def test_cargo_miri_run():
8989
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
9090
)
9191
# Special test: run it again *without* `-q` to make sure nothing is being rebuilt (Miri issue #1722)
92-
test_rebuild("`cargo miri run` (clean rebuild)",
92+
# FIXME: move this test up to right after the first `test`
93+
# (currently that fails, only the 3rd and later runs are really clean... see Miri issue #1722)
94+
test_no_rebuild("`cargo miri run` (no rebuild)",
9395
cargo_miri("run", quiet=False) + ["--", ""],
94-
rebuild_count_expected=1,
9596
)
9697

9798
def test_cargo_miri_test():

0 commit comments

Comments
 (0)