|
15 | 15 | use run_make_support::{rustc, tmp_dir};
|
16 | 16 | use std::fs;
|
17 | 17 |
|
| 18 | +fn test_with_teardown(rustc_calls: impl Fn()) { |
| 19 | + rustc_calls(); |
| 20 | + let mut dir_entries = fs::read_dir(tmp_dir()).expect("tmp_dir not found"); |
| 21 | + while let Some(entry) = dir_entries.next() { |
| 22 | + let entry = entry.expect("no entry found in tmp_dir"); |
| 23 | + let path = entry.path(); |
| 24 | + if path.is_dir() { |
| 25 | + fs::remove_dir_all(&path).unwrap(); |
| 26 | + } else { |
| 27 | + fs::remove_file(&path).unwrap(); |
| 28 | + } |
| 29 | + } |
| 30 | +} |
| 31 | + |
18 | 32 | fn main() {
|
19 |
| - // Building just baz |
20 |
| - rustc().crate_type("rlib").input("foo.rs").run(); |
21 |
| - rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
22 |
| - rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); |
23 |
| - rustc().crate_type("bin").input("baz.rs").run(); |
24 |
| - fs::remove_dir_all(tmp_dir()).unwrap(); |
25 |
| - fs::create_dir(tmp_dir()).unwrap(); |
26 |
| - rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
27 |
| - rustc().crate_type("rlib").input("bar1.rs").run(); |
28 |
| - rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); |
29 |
| - rustc().crate_type("bin").input("baz.rs").run(); |
30 |
| - fs::remove_dir_all(tmp_dir()).unwrap(); |
31 |
| - fs::create_dir(tmp_dir()).unwrap(); |
32 |
| - // Building baz2 |
33 |
| - rustc().crate_type("rlib").input("foo.rs").run(); |
34 |
| - rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
35 |
| - rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); |
36 |
| - rustc().crate_type("dylib").input("baz2.rs").run_fail_assert_exit_code(1); |
37 |
| - rustc().crate_type("bin").input("baz2.rs").run_fail_assert_exit_code(1); |
38 |
| - fs::remove_dir_all(tmp_dir()).unwrap(); |
39 |
| - fs::create_dir(tmp_dir()).unwrap(); |
40 |
| - rustc().crate_type("rlib").input("foo.rs").run(); |
41 |
| - rustc().crate_type("rlib").input("bar1.rs").run(); |
42 |
| - rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); |
43 |
| - rustc().crate_type("dylib,rlib").input("baz2.rs").run(); |
44 |
| - rustc().crate_type("bin").input("baz2.rs").run; |
45 |
| - fs::remove_dir_all(tmp_dir()).unwrap(); |
46 |
| - fs::create_dir(tmp_dir()).unwrap(); |
47 |
| - rustc().crate_type("rlib").input("foo.rs").run(); |
48 |
| - rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
49 |
| - rustc().crate_type("rlib").input("bar2.rs").run(); |
50 |
| - rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); |
51 |
| - rustc().crate_type("bin").input("baz2.rs").run(); |
52 |
| - fs::remove_dir_all(tmp_dir()).unwrap(); |
53 |
| - fs::create_dir(tmp_dir()).unwrap(); |
54 |
| - rustc().crate_type("rlib").input("foo.rs").run(); |
55 |
| - rustc().crate_type("rlib").input("bar1.rs").run(); |
56 |
| - rustc().crate_type("rlib").input("bar2.rs").run(); |
57 |
| - rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); |
58 |
| - rustc().crate_type("bin").input("baz2.rs").run(); |
59 |
| - fs::remove_dir_all(tmp_dir()).unwrap(); |
60 |
| - fs::create_dir(tmp_dir()).unwrap(); |
61 |
| - rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
62 |
| - rustc().crate_type("rlib").input("bar1.rs").run(); |
63 |
| - rustc().crate_type("rlib").input("bar2.rs").run(); |
64 |
| - rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); |
65 |
| - rustc().crate_type("bin").input("baz2.rs").run(); |
66 |
| - fs::remove_dir_all(tmp_dir()).unwrap(); |
67 |
| - fs::create_dir(tmp_dir()).unwrap(); |
68 |
| - rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
69 |
| - rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
70 |
| - rustc().crate_type("rlib").input("bar2.rs").run(); |
71 |
| - rustc().crate_type("dylib,rlib").input("baz2.rs").run(); |
72 |
| - rustc().crate_type("bin").input("baz2.rs").run(); |
73 |
| - fs::remove_dir_all(tmp_dir()).unwrap(); |
74 |
| - fs::create_dir(tmp_dir()).unwrap(); |
75 |
| - rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
76 |
| - rustc().crate_type("rlib").input("bar1.rs").run(); |
77 |
| - rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); |
78 |
| - rustc().crate_type("dylib,rlib").input("baz2.rs").run(); |
79 |
| - rustc().crate_type("bin").input("baz2.rs").run(); |
80 |
| - fs::remove_dir_all(tmp_dir()).unwrap(); |
81 |
| - fs::create_dir(tmp_dir()).unwrap(); |
| 33 | + test_with_teardown(|| { |
| 34 | + // Building just baz |
| 35 | + rustc().crate_type("rlib").input("foo.rs").run(); |
| 36 | + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
| 37 | + rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); |
| 38 | + rustc().crate_type("bin").input("baz.rs").run(); |
| 39 | + }); |
| 40 | + test_with_teardown(|| { |
| 41 | + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
| 42 | + rustc().crate_type("rlib").input("bar1.rs").run(); |
| 43 | + rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); |
| 44 | + rustc().crate_type("bin").input("baz.rs").run(); |
| 45 | + }); |
| 46 | + test_with_teardown(|| { |
| 47 | + // Building baz2 |
| 48 | + rustc().crate_type("rlib").input("foo.rs").run(); |
| 49 | + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
| 50 | + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); |
| 51 | + rustc().crate_type("dylib").input("baz2.rs").run_fail_assert_exit_code(1); |
| 52 | + rustc().crate_type("bin").input("baz2.rs").run_fail_assert_exit_code(1); |
| 53 | + }); |
| 54 | + test_with_teardown(|| { |
| 55 | + rustc().crate_type("rlib").input("foo.rs").run(); |
| 56 | + rustc().crate_type("rlib").input("bar1.rs").run(); |
| 57 | + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); |
| 58 | + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); |
| 59 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 60 | + }); |
| 61 | + test_with_teardown(|| { |
| 62 | + rustc().crate_type("rlib").input("foo.rs").run(); |
| 63 | + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
| 64 | + rustc().crate_type("rlib").input("bar2.rs").run(); |
| 65 | + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); |
| 66 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 67 | + }); |
| 68 | + test_with_teardown(|| { |
| 69 | + rustc().crate_type("rlib").input("foo.rs").run(); |
| 70 | + rustc().crate_type("rlib").input("bar1.rs").run(); |
| 71 | + rustc().crate_type("rlib").input("bar2.rs").run(); |
| 72 | + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); |
| 73 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 74 | + }); |
| 75 | + test_with_teardown(|| { |
| 76 | + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
| 77 | + rustc().crate_type("rlib").input("bar1.rs").run(); |
| 78 | + rustc().crate_type("rlib").input("bar2.rs").run(); |
| 79 | + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); |
| 80 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 81 | + }); |
| 82 | + test_with_teardown(|| { |
| 83 | + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
| 84 | + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
| 85 | + rustc().crate_type("rlib").input("bar2.rs").run(); |
| 86 | + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); |
| 87 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 88 | + }); |
| 89 | + test_with_teardown(|| { |
| 90 | + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
| 91 | + rustc().crate_type("rlib").input("bar1.rs").run(); |
| 92 | + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); |
| 93 | + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); |
| 94 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 95 | + }); |
82 | 96 | rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run();
|
83 | 97 | rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run();
|
84 | 98 | rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run();
|
|
0 commit comments