Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit db010c6

Browse files
committedJul 4, 2024·
Expectations struct for output-type-permutations
1 parent da50aae commit db010c6

File tree

2 files changed

+446
-194
lines changed
  • src/tools/run-make-support/src
  • tests/run-make/output-type-permutations

2 files changed

+446
-194
lines changed
 

‎src/tools/run-make-support/src/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,14 @@ pub fn test_while_readonly<P: AsRef<Path>, F: FnOnce() + std::panic::UnwindSafe>
266266
#[track_caller]
267267
pub fn shallow_find_files<P: AsRef<Path>, F: Fn(&PathBuf) -> bool>(
268268
path: P,
269-
closure: F,
269+
filter: F,
270270
) -> Vec<PathBuf> {
271271
let mut matching_files = Vec::new();
272272
for entry in fs_wrapper::read_dir(path) {
273273
let entry = entry.expect("failed to read directory entry.");
274274
let path = entry.path();
275275

276-
if path.is_file() && closure(&path) {
276+
if path.is_file() && filter(&path) {
277277
matching_files.push(path);
278278
}
279279
}
@@ -291,8 +291,10 @@ pub fn has_extension<P: AsRef<Path>>(path: P, extension: &str) -> bool {
291291
}
292292

293293
/// Returns true if the filename at `path` is not in `expected`.
294-
pub fn name_not_among<P: AsRef<Path>>(path: P, expected: &[&'static str]) -> bool {
295-
path.as_ref().file_name().is_some_and(|name| !expected.contains(&name.to_str().unwrap()))
294+
pub fn filename_not_in_denylist<P: AsRef<Path>>(path: P, expected: &[String]) -> bool {
295+
path.as_ref()
296+
.file_name()
297+
.is_some_and(|name| !expected.contains(&name.to_str().unwrap().to_owned()))
296298
}
297299

298300
/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is

‎tests/run-make/output-type-permutations/rmake.rs

+440-190
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// See https://github.com/rust-lang/rust/pull/12020
66

77
use run_make_support::{
8-
bin_name, cwd, dynamic_lib_name, fs_wrapper, name_not_among, rust_lib_name, rustc,
8+
bin_name, dynamic_lib_name, filename_not_in_denylist, fs_wrapper, rust_lib_name, rustc,
99
shallow_find_files, static_lib_name,
1010
};
1111

@@ -15,46 +15,69 @@ use run_make_support::{
1515
// `dir`: the name of the directory where the test happens
1616
// `rustc_invocation`: the rustc command being tested
1717
// Any unexpected output files not listed in `must_exist` or `can_exist` will cause a failure.
18-
fn assert_expected_output_files(
19-
must_exist: &[&'static str],
20-
can_exist: &[&'static str],
21-
dir: &str,
22-
rustc_invocation: impl Fn(),
23-
) {
24-
fs_wrapper::create_dir(dir);
18+
fn assert_expected_output_files(expectations: Expectations, rustc_invocation: impl Fn()) {
19+
let must_exist = expectations.expected_files;
20+
let can_exist = expectations.allowed_files;
21+
let dir = expectations.test_dir;
22+
23+
fs_wrapper::create_dir(&dir);
2524
rustc_invocation();
2625
for file in must_exist {
27-
fs_wrapper::remove_file(dir.to_owned() + "/" + file);
26+
fs_wrapper::remove_file(dir.to_owned() + "/" + &file);
2827
}
29-
let actual_output_files = shallow_find_files(dir, |path| name_not_among(path, can_exist));
28+
let actual_output_files =
29+
shallow_find_files(dir, |path| filename_not_in_denylist(path, &can_exist));
3030
if !&actual_output_files.is_empty() {
3131
dbg!(&actual_output_files);
3232
panic!("unexpected output artifacts detected");
3333
}
3434
}
3535

36+
struct Expectations {
37+
/// Output files which must be found. The test fails if any are absent.
38+
expected_files: Vec<String>,
39+
/// Allowed output files which will not trigger a failure.
40+
allowed_files: Vec<String>,
41+
/// Name of the directory where the test happens.
42+
test_dir: String,
43+
}
44+
45+
macro_rules! s {
46+
( $( $x:expr ),* ) => {
47+
{
48+
let mut temp_vec = Vec::new();
49+
$(
50+
temp_vec.push($x.to_string());
51+
)*
52+
temp_vec
53+
}
54+
};
55+
}
56+
3657
fn main() {
37-
let bin_foo = Box::leak(Box::new(bin_name("foo")));
38-
let bin_bar = Box::leak(Box::new(bin_name("bar")));
39-
let static_bar = Box::leak(Box::new(static_lib_name("bar")));
40-
let dynamic_bar = Box::leak(Box::new(dynamic_lib_name("bar")));
41-
let rust_bar = Box::leak(Box::new(rust_lib_name("bar")));
58+
let bin_foo = bin_name("foo");
4259

4360
assert_expected_output_files(
44-
&[static_bar, dynamic_bar, rust_bar],
45-
&[
46-
"libbar.ddl.exp",
47-
"libbar.dll.lib",
48-
"libbar.pdb",
49-
"libbar.dll.a",
50-
"libbar.exe.a",
51-
"bar.ddl.exp",
52-
"bar.dll.lib",
53-
"bar.pdb",
54-
"bar.dll.a",
55-
"bar.exe.a",
56-
],
57-
"three-crates",
61+
Expectations {
62+
expected_files: s![
63+
static_lib_name("bar"),
64+
dynamic_lib_name("bar"),
65+
rust_lib_name("bar")
66+
],
67+
allowed_files: s![
68+
"libbar.dll.exp",
69+
"libbar.dll.lib",
70+
"libbar.pdb",
71+
"libbar.dll.a",
72+
"libbar.exe.a",
73+
"bar.dll.exp",
74+
"bar.dll.lib",
75+
"bar.pdb",
76+
"bar.dll.a",
77+
"bar.exe.a"
78+
],
79+
test_dir: "three-crates".to_string(),
80+
},
5881
|| {
5982
rustc()
6083
.input("foo.rs")
@@ -64,113 +87,256 @@ fn main() {
6487
},
6588
);
6689

67-
assert_expected_output_files(&[bin_bar], &["bar.pdb"], "bin-crate", || {
68-
rustc().input("foo.rs").crate_type("bin").out_dir("bin-crate").run();
69-
});
90+
assert_expected_output_files(
91+
Expectations {
92+
expected_files: s![bin_name("bar")],
93+
allowed_files: s!["bar.pdb"],
94+
test_dir: "bin-crate".to_string(),
95+
},
96+
|| {
97+
rustc().input("foo.rs").crate_type("bin").out_dir("bin-crate").run();
98+
},
99+
);
70100

71101
assert_expected_output_files(
72-
&["bar.ll", "bar.bc", "bar.s", "bar.o", bin_bar],
73-
&["bar.pdb"],
74-
"all-emit",
102+
Expectations {
103+
expected_files: s!["bar.ll", "bar.bc", "bar.s", "bar.o", bin_name("bar")],
104+
allowed_files: s!["bar.pdb"],
105+
test_dir: "all-emit".to_string(),
106+
},
75107
|| {
76108
rustc().input("foo.rs").emit("asm,llvm-ir,llvm-bc,obj,link").out_dir("all-emit").run();
77109
},
78110
);
79111

80-
assert_expected_output_files(&["foo"], &[], "asm-emit", || {
81-
rustc().input("foo.rs").emit("asm").output("asm-emit/foo").run();
82-
});
83-
assert_expected_output_files(&["foo"], &[], "asm-emit2", || {
84-
rustc().input("foo.rs").emit("asm=asm-emit2/foo").run();
85-
});
86-
assert_expected_output_files(&["foo"], &[], "asm-emit3", || {
87-
rustc().input("foo.rs").arg("--emit=asm=asm-emit3/foo").run();
88-
});
112+
assert_expected_output_files(
113+
Expectations {
114+
expected_files: s!["foo"],
115+
allowed_files: s![],
116+
test_dir: "asm-emit".to_string(),
117+
},
118+
|| {
119+
rustc().input("foo.rs").emit("asm").output("asm-emit/foo").run();
120+
},
121+
);
122+
assert_expected_output_files(
123+
Expectations {
124+
expected_files: s!["foo"],
125+
allowed_files: s![],
126+
test_dir: "asm-emit2".to_string(),
127+
},
128+
|| {
129+
rustc().input("foo.rs").emit("asm=asm-emit2/foo").run();
130+
},
131+
);
132+
assert_expected_output_files(
133+
Expectations {
134+
expected_files: s!["foo"],
135+
allowed_files: s![],
136+
test_dir: "asm-emit3".to_string(),
137+
},
138+
|| {
139+
rustc().input("foo.rs").arg("--emit=asm=asm-emit3/foo").run();
140+
},
141+
);
89142

90-
assert_expected_output_files(&["foo"], &[], "llvm-ir-emit", || {
91-
rustc().input("foo.rs").emit("llvm-ir").output("llvm-ir-emit/foo").run();
92-
});
93-
assert_expected_output_files(&["foo"], &[], "llvm-ir-emit2", || {
94-
rustc().input("foo.rs").emit("llvm-ir=llvm-ir-emit2/foo").run();
95-
});
96-
assert_expected_output_files(&["foo"], &[], "llvm-ir-emit3", || {
97-
rustc().input("foo.rs").arg("--emit=llvm-ir=llvm-ir-emit3/foo").run();
98-
});
143+
assert_expected_output_files(
144+
Expectations {
145+
expected_files: s!["foo"],
146+
allowed_files: s![],
147+
test_dir: "llvm-ir-emit".to_string(),
148+
},
149+
|| {
150+
rustc().input("foo.rs").emit("llvm-ir").output("llvm-ir-emit/foo").run();
151+
},
152+
);
153+
assert_expected_output_files(
154+
Expectations {
155+
expected_files: s!["foo"],
156+
allowed_files: s![],
157+
test_dir: "llvm-ir-emit2".to_string(),
158+
},
159+
|| {
160+
rustc().input("foo.rs").emit("llvm-ir=llvm-ir-emit2/foo").run();
161+
},
162+
);
163+
assert_expected_output_files(
164+
Expectations {
165+
expected_files: s!["foo"],
166+
allowed_files: s![],
167+
test_dir: "llvm-ir-emit3".to_string(),
168+
},
169+
|| {
170+
rustc().input("foo.rs").arg("--emit=llvm-ir=llvm-ir-emit3/foo").run();
171+
},
172+
);
99173

100-
assert_expected_output_files(&["foo"], &[], "llvm-bc-emit", || {
101-
rustc().input("foo.rs").emit("llvm-bc").output("llvm-bc-emit/foo").run();
102-
});
103-
assert_expected_output_files(&["foo"], &[], "llvm-bc-emit2", || {
104-
rustc().input("foo.rs").emit("llvm-bc=llvm-bc-emit2/foo").run();
105-
});
106-
assert_expected_output_files(&["foo"], &[], "llvm-bc-emit3", || {
107-
rustc().input("foo.rs").arg("--emit=llvm-bc=llvm-bc-emit3/foo").run();
108-
});
174+
assert_expected_output_files(
175+
Expectations {
176+
expected_files: s!["foo"],
177+
allowed_files: s![],
178+
test_dir: "llvm-bc-emit".to_string(),
179+
},
180+
|| {
181+
rustc().input("foo.rs").emit("llvm-bc").output("llvm-bc-emit/foo").run();
182+
},
183+
);
184+
assert_expected_output_files(
185+
Expectations {
186+
expected_files: s!["foo"],
187+
allowed_files: s![],
188+
test_dir: "llvm-bc-emit2".to_string(),
189+
},
190+
|| {
191+
rustc().input("foo.rs").emit("llvm-bc=llvm-bc-emit2/foo").run();
192+
},
193+
);
194+
assert_expected_output_files(
195+
Expectations {
196+
expected_files: s!["foo"],
197+
allowed_files: s![],
198+
test_dir: "llvm-bc-emit3".to_string(),
199+
},
200+
|| {
201+
rustc().input("foo.rs").arg("--emit=llvm-bc=llvm-bc-emit3/foo").run();
202+
},
203+
);
109204

110-
assert_expected_output_files(&["foo"], &[], "obj-emit", || {
111-
rustc().input("foo.rs").emit("obj").output("obj-emit/foo").run();
112-
});
113-
assert_expected_output_files(&["foo"], &[], "obj-emit2", || {
114-
rustc().input("foo.rs").emit("obj=obj-emit2/foo").run();
115-
});
116-
assert_expected_output_files(&["foo"], &[], "obj-emit3", || {
117-
rustc().input("foo.rs").arg("--emit=obj=obj-emit3/foo").run();
118-
});
205+
assert_expected_output_files(
206+
Expectations {
207+
expected_files: s!["foo"],
208+
allowed_files: s![],
209+
test_dir: "obj-emit".to_string(),
210+
},
211+
|| {
212+
rustc().input("foo.rs").emit("obj").output("obj-emit/foo").run();
213+
},
214+
);
215+
assert_expected_output_files(
216+
Expectations {
217+
expected_files: s!["foo"],
218+
allowed_files: s![],
219+
test_dir: "obj-emit2".to_string(),
220+
},
221+
|| {
222+
rustc().input("foo.rs").emit("obj=obj-emit2/foo").run();
223+
},
224+
);
225+
assert_expected_output_files(
226+
Expectations {
227+
expected_files: s!["foo"],
228+
allowed_files: s![],
229+
test_dir: "obj-emit3".to_string(),
230+
},
231+
|| {
232+
rustc().input("foo.rs").arg("--emit=obj=obj-emit3/foo").run();
233+
},
234+
);
119235

120-
assert_expected_output_files(&[bin_foo], &[], "link-emit", || {
121-
rustc().input("foo.rs").emit("link").output("link-emit/".to_owned() + bin_foo).run();
122-
});
123-
assert_expected_output_files(&[bin_foo], &[], "link-emit2", || {
124-
rustc().input("foo.rs").emit(&format!("link=link-emit2/{bin_foo}")).run();
125-
});
126-
assert_expected_output_files(&[bin_foo], &[], "link-emit3", || {
127-
rustc().input("foo.rs").arg(&format!("--emit=link=link-emit3/{bin_foo}")).run();
128-
});
236+
assert_expected_output_files(
237+
Expectations {
238+
expected_files: s![&bin_foo],
239+
allowed_files: s!["foo.pdb"],
240+
test_dir: "link-emit".to_string(),
241+
},
242+
|| {
243+
rustc().input("foo.rs").emit("link").output("link-emit/".to_owned() + &bin_foo).run();
244+
},
245+
);
246+
assert_expected_output_files(
247+
Expectations {
248+
expected_files: s![&bin_foo],
249+
allowed_files: s!["foo.pdb"],
250+
test_dir: "link-emit2".to_string(),
251+
},
252+
|| {
253+
rustc().input("foo.rs").emit(&format!("link=link-emit2/{bin_foo}")).run();
254+
},
255+
);
256+
assert_expected_output_files(
257+
Expectations {
258+
expected_files: s![&bin_foo],
259+
allowed_files: s!["foo.pdb"],
260+
test_dir: "link-emit3".to_string(),
261+
},
262+
|| {
263+
rustc().input("foo.rs").arg(&format!("--emit=link=link-emit3/{bin_foo}")).run();
264+
},
265+
);
129266

130-
assert_expected_output_files(&["foo"], &[], "rlib", || {
131-
rustc().crate_type("rlib").input("foo.rs").output("rlib/foo").run();
132-
});
133-
assert_expected_output_files(&["foo"], &[], "rlib2", || {
134-
rustc().crate_type("rlib").input("foo.rs").emit("link=rlib2/foo").run();
135-
});
136-
assert_expected_output_files(&["foo"], &[], "rlib3", || {
137-
rustc().crate_type("rlib").input("foo.rs").arg("--emit=link=rlib3/foo").run();
138-
});
267+
assert_expected_output_files(
268+
Expectations {
269+
expected_files: s!["foo"],
270+
allowed_files: s![],
271+
test_dir: "rlib".to_string(),
272+
},
273+
|| {
274+
rustc().crate_type("rlib").input("foo.rs").output("rlib/foo").run();
275+
},
276+
);
277+
assert_expected_output_files(
278+
Expectations {
279+
expected_files: s!["foo"],
280+
allowed_files: s![],
281+
test_dir: "rlib2".to_string(),
282+
},
283+
|| {
284+
rustc().crate_type("rlib").input("foo.rs").emit("link=rlib2/foo").run();
285+
},
286+
);
287+
assert_expected_output_files(
288+
Expectations {
289+
expected_files: s!["foo"],
290+
allowed_files: s![],
291+
test_dir: "rlib3".to_string(),
292+
},
293+
|| {
294+
rustc().crate_type("rlib").input("foo.rs").arg("--emit=link=rlib3/foo").run();
295+
},
296+
);
139297

140298
assert_expected_output_files(
141-
&[bin_foo],
142-
&[
143-
"libbar.ddl.exp",
144-
"libbar.dll.lib",
145-
"libbar.pdb",
146-
"libbar.dll.a",
147-
"libbar.exe.a",
148-
"bar.ddl.exp",
149-
"bar.dll.lib",
150-
"bar.pdb",
151-
"bar.dll.a",
152-
"bar.exe.a",
153-
],
154-
"dylib",
155-
|| {
156-
rustc().crate_type("dylib").input("foo.rs").output("dylib/".to_owned() + bin_foo).run();
157-
},
158-
);
159-
assert_expected_output_files(
160-
&[bin_foo],
161-
&[
162-
"libbar.ddl.exp",
163-
"libbar.dll.lib",
164-
"libbar.pdb",
165-
"libbar.dll.a",
166-
"libbar.exe.a",
167-
"bar.ddl.exp",
168-
"bar.dll.lib",
169-
"bar.pdb",
170-
"bar.dll.a",
171-
"bar.exe.a",
172-
],
173-
"dylib2",
299+
Expectations {
300+
expected_files: s![bin_foo],
301+
allowed_files: s![
302+
"libfoo.dll.exp",
303+
"libfoo.dll.lib",
304+
"libfoo.pdb",
305+
"libfoo.dll.a",
306+
"libfoo.exe.a",
307+
"foo.dll.exp",
308+
"foo.dll.lib",
309+
"foo.pdb",
310+
"foo.dll.a",
311+
"foo.exe.a"
312+
],
313+
test_dir: "dylib".to_string(),
314+
},
315+
|| {
316+
rustc()
317+
.crate_type("dylib")
318+
.input("foo.rs")
319+
.output("dylib/".to_owned() + &bin_foo)
320+
.run();
321+
},
322+
);
323+
assert_expected_output_files(
324+
Expectations {
325+
expected_files: s![bin_foo],
326+
allowed_files: s![
327+
"libfoo.dll.exp",
328+
"libfoo.dll.lib",
329+
"libfoo.pdb",
330+
"libfoo.dll.a",
331+
"libfoo.exe.a",
332+
"foo.dll.exp",
333+
"foo.dll.lib",
334+
"foo.pdb",
335+
"foo.dll.a",
336+
"foo.exe.a"
337+
],
338+
test_dir: "dylib2".to_string(),
339+
},
174340
|| {
175341
rustc()
176342
.crate_type("dylib")
@@ -180,20 +346,22 @@ fn main() {
180346
},
181347
);
182348
assert_expected_output_files(
183-
&[bin_foo],
184-
&[
185-
"libbar.ddl.exp",
186-
"libbar.dll.lib",
187-
"libbar.pdb",
188-
"libbar.dll.a",
189-
"libbar.exe.a",
190-
"bar.ddl.exp",
191-
"bar.dll.lib",
192-
"bar.pdb",
193-
"bar.dll.a",
194-
"bar.exe.a",
195-
],
196-
"dylib3",
349+
Expectations {
350+
expected_files: s![bin_foo],
351+
allowed_files: s![
352+
"libfoo.dll.exp",
353+
"libfoo.dll.lib",
354+
"libfoo.pdb",
355+
"libfoo.dll.a",
356+
"libfoo.exe.a",
357+
"foo.dll.exp",
358+
"foo.dll.lib",
359+
"foo.pdb",
360+
"foo.dll.a",
361+
"foo.exe.a"
362+
],
363+
test_dir: "dylib3".to_string(),
364+
},
197365
|| {
198366
rustc()
199367
.crate_type("dylib")
@@ -203,55 +371,121 @@ fn main() {
203371
},
204372
);
205373

206-
assert_expected_output_files(&["foo"], &[], "staticlib", || {
207-
rustc().crate_type("staticlib").input("foo.rs").output("staticlib/foo").run();
208-
});
209-
assert_expected_output_files(&["foo"], &[], "staticlib2", || {
210-
rustc().crate_type("staticlib").input("foo.rs").emit("link=staticlib2/foo").run();
211-
});
212-
assert_expected_output_files(&["foo"], &[], "staticlib3", || {
213-
rustc().crate_type("staticlib").input("foo.rs").arg("--emit=link=staticlib3/foo").run();
214-
});
374+
assert_expected_output_files(
375+
Expectations {
376+
expected_files: s!["foo"],
377+
allowed_files: s![],
378+
test_dir: "staticlib".to_string(),
379+
},
380+
|| {
381+
rustc().crate_type("staticlib").input("foo.rs").output("staticlib/foo").run();
382+
},
383+
);
384+
assert_expected_output_files(
385+
Expectations {
386+
expected_files: s!["foo"],
387+
allowed_files: s![],
388+
test_dir: "staticlib2".to_string(),
389+
},
390+
|| {
391+
rustc().crate_type("staticlib").input("foo.rs").emit("link=staticlib2/foo").run();
392+
},
393+
);
394+
assert_expected_output_files(
395+
Expectations {
396+
expected_files: s!["foo"],
397+
allowed_files: s![],
398+
test_dir: "staticlib3".to_string(),
399+
},
400+
|| {
401+
rustc().crate_type("staticlib").input("foo.rs").arg("--emit=link=staticlib3/foo").run();
402+
},
403+
);
215404

216-
assert_expected_output_files(&["foo"], &["foo.pdb"], "bincrate", || {
217-
rustc().crate_type("bin").input("foo.rs").output("bincrate/".to_owned() + bin_foo).run();
218-
});
219-
assert_expected_output_files(&["foo"], &["foo.pdb"], "bincrate2", || {
220-
rustc().crate_type("bin").input("foo.rs").emit(&format!("link=bincrate2/{bin_foo}")).run();
221-
});
222-
assert_expected_output_files(&["foo"], &["foo.pdb"], "bincrate3", || {
223-
rustc()
224-
.crate_type("bin")
225-
.input("foo.rs")
226-
.arg(&format!("--emit=link=bincrate3/{bin_foo}"))
227-
.run();
228-
});
405+
assert_expected_output_files(
406+
Expectations {
407+
expected_files: s![bin_foo],
408+
allowed_files: s!["foo.pdb"],
409+
test_dir: "bincrate".to_string(),
410+
},
411+
|| {
412+
rustc()
413+
.crate_type("bin")
414+
.input("foo.rs")
415+
.output("bincrate/".to_owned() + &bin_foo)
416+
.run();
417+
},
418+
);
419+
assert_expected_output_files(
420+
Expectations {
421+
expected_files: s![bin_foo],
422+
allowed_files: s!["foo.pdb"],
423+
test_dir: "bincrate2".to_string(),
424+
},
425+
|| {
426+
rustc()
427+
.crate_type("bin")
428+
.input("foo.rs")
429+
.emit(&format!("link=bincrate2/{bin_foo}"))
430+
.run();
431+
},
432+
);
433+
assert_expected_output_files(
434+
Expectations {
435+
expected_files: s![bin_foo],
436+
allowed_files: s!["foo.pdb"],
437+
test_dir: "bincrate3".to_string(),
438+
},
439+
|| {
440+
rustc()
441+
.crate_type("bin")
442+
.input("foo.rs")
443+
.arg(&format!("--emit=link=bincrate3/{bin_foo}"))
444+
.run();
445+
},
446+
);
229447

230-
assert_expected_output_files(&["ir", rust_bar], &[], "rlib-ir", || {
231-
rustc()
232-
.input("foo.rs")
233-
.emit("llvm-ir=rlib-ir/ir")
234-
.emit("link")
235-
.crate_type("rlib")
236-
.out_dir("rlib-ir")
237-
.run();
238-
});
448+
assert_expected_output_files(
449+
Expectations {
450+
expected_files: s!["ir", rust_lib_name("bar")],
451+
allowed_files: s![],
452+
test_dir: "rlib-ir".to_string(),
453+
},
454+
|| {
455+
rustc()
456+
.input("foo.rs")
457+
.emit("llvm-ir=rlib-ir/ir")
458+
.emit("link")
459+
.crate_type("rlib")
460+
.out_dir("rlib-ir")
461+
.run();
462+
},
463+
);
239464

240-
assert_expected_output_files(&["ir", "asm", "bc", "obj", "link"], &[], "staticlib-all", || {
241-
rustc()
242-
.input("foo.rs")
243-
.emit("asm=staticlib-all/asm")
244-
.emit("llvm-ir=staticlib-all/ir")
245-
.emit("llvm-bc=staticlib-all/bc")
246-
.emit("obj=staticlib-all/obj")
247-
.emit("link=staticlib-all/link")
248-
.crate_type("staticlib")
249-
.run();
250-
});
251-
assert_expected_output_files(
252-
&["ir", "asm", "bc", "obj", "link"],
253-
&[],
254-
"staticlib-all2",
465+
assert_expected_output_files(
466+
Expectations {
467+
expected_files: s!["ir", "asm", "bc", "obj", "link"],
468+
allowed_files: s![],
469+
test_dir: "staticlib-all".to_string(),
470+
},
471+
|| {
472+
rustc()
473+
.input("foo.rs")
474+
.emit("asm=staticlib-all/asm")
475+
.emit("llvm-ir=staticlib-all/ir")
476+
.emit("llvm-bc=staticlib-all/bc")
477+
.emit("obj=staticlib-all/obj")
478+
.emit("link=staticlib-all/link")
479+
.crate_type("staticlib")
480+
.run();
481+
},
482+
);
483+
assert_expected_output_files(
484+
Expectations {
485+
expected_files: s!["ir", "asm", "bc", "obj", "link"],
486+
allowed_files: s![],
487+
test_dir: "staticlib-all2".to_string(),
488+
},
255489
|| {
256490
rustc()
257491
.input("foo.rs")
@@ -268,9 +502,10 @@ fn main() {
268502
);
269503

270504
assert_expected_output_files(
271-
&["bar.ll", "bar.s", "bar.o", static_bar],
272-
&["bar.bc"], // keep this one for the next test
273-
"staticlib-all3",
505+
Expectations{ expected_files:
506+
s!["bar.ll", "bar.s", "bar.o", static_lib_name("bar")],
507+
allowed_files: s!["bar.bc"], test_dir: // keep this one for the next test
508+
"staticlib-all3".to_string()},
274509
|| {
275510
rustc()
276511
.input("foo.rs")
@@ -283,9 +518,24 @@ fn main() {
283518

284519
// the .bc file from the previous test should be equivalent to this one, despite the difference
285520
// in crate type
286-
assert_expected_output_files(&["bar.bc", rust_bar, "foo.bc"], &[], "rlib-emits", || {
287-
fs_wrapper::rename("staticlib-all3/bar.bc", "rlib-emits/foo.bc");
288-
rustc().input("foo.rs").emit("llvm-bc,link").crate_type("rlib").out_dir("rlib-emits").run();
289-
assert_eq!(fs_wrapper::read("rlib-emits/foo.bc"), fs_wrapper::read("rlib-emits/bar.bc"));
290-
});
521+
assert_expected_output_files(
522+
Expectations {
523+
expected_files: s!["bar.bc", rust_lib_name("bar"), "foo.bc"],
524+
allowed_files: s![],
525+
test_dir: "rlib-emits".to_string(),
526+
},
527+
|| {
528+
fs_wrapper::rename("staticlib-all3/bar.bc", "rlib-emits/foo.bc");
529+
rustc()
530+
.input("foo.rs")
531+
.emit("llvm-bc,link")
532+
.crate_type("rlib")
533+
.out_dir("rlib-emits")
534+
.run();
535+
assert_eq!(
536+
fs_wrapper::read("rlib-emits/foo.bc"),
537+
fs_wrapper::read("rlib-emits/bar.bc")
538+
);
539+
},
540+
);
291541
}

0 commit comments

Comments
 (0)
Please sign in to comment.