Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c4bc6fd

Browse files
committedApr 7, 2025
tests: account for target dylib support in output-type-permutations
And ignore on nvptx64.
1 parent f39c8c7 commit c4bc6fd

File tree

1 file changed

+200
-126
lines changed
  • tests/run-make/output-type-permutations

1 file changed

+200
-126
lines changed
 

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

Lines changed: 200 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
// files are exactly what is expected, no more, no less.
55
// See https://github.com/rust-lang/rust/pull/12020
66

7+
//@ ignore-nvptx64 (needs target std)
8+
79
use std::path::PathBuf;
810

911
use run_make_support::{
1012
bin_name, dynamic_lib_name, filename_not_in_denylist, rfs, rust_lib_name, rustc,
11-
shallow_find_files, static_lib_name,
13+
shallow_find_files, static_lib_name, target,
1214
};
1315

1416
// Each test takes 4 arguments:
@@ -17,6 +19,7 @@ use run_make_support::{
1719
// `dir`: the name of the directory where the test happens
1820
// `rustc_invocation`: the rustc command being tested
1921
// Any unexpected output files not listed in `must_exist` or `can_exist` will cause a failure.
22+
#[track_caller]
2023
fn assert_expected_output_files(expectations: Expectations, rustc_invocation: impl Fn()) {
2124
let Expectations { expected_files: must_exist, allowed_files: can_exist, test_dir: dir } =
2225
expectations;
@@ -58,35 +61,40 @@ macro_rules! s {
5861
fn main() {
5962
let bin_foo = bin_name("foo");
6063

61-
assert_expected_output_files(
62-
Expectations {
63-
expected_files: s![
64-
static_lib_name("bar"),
65-
dynamic_lib_name("bar"),
66-
rust_lib_name("bar")
67-
],
68-
allowed_files: s![
69-
"libbar.dll.exp",
70-
"libbar.dll.lib",
71-
"libbar.pdb",
72-
"libbar.dll.a",
73-
"libbar.exe.a",
74-
"bar.dll.exp",
75-
"bar.dll.lib",
76-
"bar.pdb",
77-
"bar.dll.a",
78-
"bar.exe.a"
79-
],
80-
test_dir: "three-crates".to_string(),
81-
},
82-
|| {
83-
rustc()
84-
.input("foo.rs")
85-
.out_dir("three-crates")
86-
.crate_type("rlib,dylib,staticlib")
87-
.run();
88-
},
89-
);
64+
let expect_dylib = !(target().contains("wasm") || target().contains("musl"));
65+
66+
if expect_dylib {
67+
assert_expected_output_files(
68+
Expectations {
69+
expected_files: s![
70+
static_lib_name("bar"),
71+
dynamic_lib_name("bar"),
72+
rust_lib_name("bar")
73+
],
74+
allowed_files: s![
75+
"libbar.dll.exp",
76+
"libbar.dll.lib",
77+
"libbar.pdb",
78+
"libbar.dll.a",
79+
"libbar.exe.a",
80+
"bar.dll.exp",
81+
"bar.dll.lib",
82+
"bar.pdb",
83+
"bar.dll.a",
84+
"bar.exe.a"
85+
],
86+
test_dir: "three-crates".to_string(),
87+
},
88+
|| {
89+
rustc()
90+
.target(target())
91+
.input("foo.rs")
92+
.out_dir("three-crates")
93+
.crate_type("rlib,dylib,staticlib")
94+
.run();
95+
},
96+
);
97+
}
9098

9199
assert_expected_output_files(
92100
Expectations {
@@ -95,7 +103,7 @@ fn main() {
95103
test_dir: "bin-crate".to_string(),
96104
},
97105
|| {
98-
rustc().input("foo.rs").crate_type("bin").out_dir("bin-crate").run();
106+
rustc().target(target()).input("foo.rs").crate_type("bin").out_dir("bin-crate").run();
99107
},
100108
);
101109

@@ -106,7 +114,12 @@ fn main() {
106114
test_dir: "all-emit".to_string(),
107115
},
108116
|| {
109-
rustc().input("foo.rs").emit("asm,llvm-ir,llvm-bc,obj,link").out_dir("all-emit").run();
117+
rustc()
118+
.target(target())
119+
.input("foo.rs")
120+
.emit("asm,llvm-ir,llvm-bc,obj,link")
121+
.out_dir("all-emit")
122+
.run();
110123
},
111124
);
112125

@@ -117,7 +130,7 @@ fn main() {
117130
test_dir: "asm-emit".to_string(),
118131
},
119132
|| {
120-
rustc().input("foo.rs").emit("asm").output("asm-emit/foo").run();
133+
rustc().target(target()).input("foo.rs").emit("asm").output("asm-emit/foo").run();
121134
},
122135
);
123136
assert_expected_output_files(
@@ -127,7 +140,7 @@ fn main() {
127140
test_dir: "asm-emit2".to_string(),
128141
},
129142
|| {
130-
rustc().input("foo.rs").emit("asm=asm-emit2/foo").run();
143+
rustc().target(target()).input("foo.rs").emit("asm=asm-emit2/foo").run();
131144
},
132145
);
133146
assert_expected_output_files(
@@ -137,7 +150,7 @@ fn main() {
137150
test_dir: "asm-emit3".to_string(),
138151
},
139152
|| {
140-
rustc().input("foo.rs").arg("--emit=asm=asm-emit3/foo").run();
153+
rustc().target(target()).input("foo.rs").arg("--emit=asm=asm-emit3/foo").run();
141154
},
142155
);
143156

@@ -148,7 +161,12 @@ fn main() {
148161
test_dir: "llvm-ir-emit".to_string(),
149162
},
150163
|| {
151-
rustc().input("foo.rs").emit("llvm-ir").output("llvm-ir-emit/foo").run();
164+
rustc()
165+
.target(target())
166+
.input("foo.rs")
167+
.emit("llvm-ir")
168+
.output("llvm-ir-emit/foo")
169+
.run();
152170
},
153171
);
154172
assert_expected_output_files(
@@ -158,7 +176,7 @@ fn main() {
158176
test_dir: "llvm-ir-emit2".to_string(),
159177
},
160178
|| {
161-
rustc().input("foo.rs").emit("llvm-ir=llvm-ir-emit2/foo").run();
179+
rustc().target(target()).input("foo.rs").emit("llvm-ir=llvm-ir-emit2/foo").run();
162180
},
163181
);
164182
assert_expected_output_files(
@@ -168,7 +186,7 @@ fn main() {
168186
test_dir: "llvm-ir-emit3".to_string(),
169187
},
170188
|| {
171-
rustc().input("foo.rs").arg("--emit=llvm-ir=llvm-ir-emit3/foo").run();
189+
rustc().target(target()).input("foo.rs").arg("--emit=llvm-ir=llvm-ir-emit3/foo").run();
172190
},
173191
);
174192

@@ -179,7 +197,12 @@ fn main() {
179197
test_dir: "llvm-bc-emit".to_string(),
180198
},
181199
|| {
182-
rustc().input("foo.rs").emit("llvm-bc").output("llvm-bc-emit/foo").run();
200+
rustc()
201+
.target(target())
202+
.input("foo.rs")
203+
.emit("llvm-bc")
204+
.output("llvm-bc-emit/foo")
205+
.run();
183206
},
184207
);
185208
assert_expected_output_files(
@@ -189,7 +212,7 @@ fn main() {
189212
test_dir: "llvm-bc-emit2".to_string(),
190213
},
191214
|| {
192-
rustc().input("foo.rs").emit("llvm-bc=llvm-bc-emit2/foo").run();
215+
rustc().target(target()).input("foo.rs").emit("llvm-bc=llvm-bc-emit2/foo").run();
193216
},
194217
);
195218
assert_expected_output_files(
@@ -199,7 +222,7 @@ fn main() {
199222
test_dir: "llvm-bc-emit3".to_string(),
200223
},
201224
|| {
202-
rustc().input("foo.rs").arg("--emit=llvm-bc=llvm-bc-emit3/foo").run();
225+
rustc().target(target()).input("foo.rs").arg("--emit=llvm-bc=llvm-bc-emit3/foo").run();
203226
},
204227
);
205228

@@ -210,7 +233,7 @@ fn main() {
210233
test_dir: "obj-emit".to_string(),
211234
},
212235
|| {
213-
rustc().input("foo.rs").emit("obj").output("obj-emit/foo").run();
236+
rustc().target(target()).input("foo.rs").emit("obj").output("obj-emit/foo").run();
214237
},
215238
);
216239
assert_expected_output_files(
@@ -220,7 +243,7 @@ fn main() {
220243
test_dir: "obj-emit2".to_string(),
221244
},
222245
|| {
223-
rustc().input("foo.rs").emit("obj=obj-emit2/foo").run();
246+
rustc().target(target()).input("foo.rs").emit("obj=obj-emit2/foo").run();
224247
},
225248
);
226249
assert_expected_output_files(
@@ -230,7 +253,7 @@ fn main() {
230253
test_dir: "obj-emit3".to_string(),
231254
},
232255
|| {
233-
rustc().input("foo.rs").arg("--emit=obj=obj-emit3/foo").run();
256+
rustc().target(target()).input("foo.rs").arg("--emit=obj=obj-emit3/foo").run();
234257
},
235258
);
236259

@@ -241,7 +264,12 @@ fn main() {
241264
test_dir: "link-emit".to_string(),
242265
},
243266
|| {
244-
rustc().input("foo.rs").emit("link").output("link-emit/".to_owned() + &bin_foo).run();
267+
rustc()
268+
.target(target())
269+
.input("foo.rs")
270+
.emit("link")
271+
.output("link-emit/".to_owned() + &bin_foo)
272+
.run();
245273
},
246274
);
247275
assert_expected_output_files(
@@ -251,7 +279,11 @@ fn main() {
251279
test_dir: "link-emit2".to_string(),
252280
},
253281
|| {
254-
rustc().input("foo.rs").emit(&format!("link=link-emit2/{bin_foo}")).run();
282+
rustc()
283+
.target(target())
284+
.input("foo.rs")
285+
.emit(&format!("link=link-emit2/{bin_foo}"))
286+
.run();
255287
},
256288
);
257289
assert_expected_output_files(
@@ -261,7 +293,11 @@ fn main() {
261293
test_dir: "link-emit3".to_string(),
262294
},
263295
|| {
264-
rustc().input("foo.rs").arg(&format!("--emit=link=link-emit3/{bin_foo}")).run();
296+
rustc()
297+
.target(target())
298+
.input("foo.rs")
299+
.arg(&format!("--emit=link=link-emit3/{bin_foo}"))
300+
.run();
265301
},
266302
);
267303

@@ -272,7 +308,7 @@ fn main() {
272308
test_dir: "rlib".to_string(),
273309
},
274310
|| {
275-
rustc().crate_type("rlib").input("foo.rs").output("rlib/foo").run();
311+
rustc().target(target()).crate_type("rlib").input("foo.rs").output("rlib/foo").run();
276312
},
277313
);
278314
assert_expected_output_files(
@@ -281,105 +317,125 @@ fn main() {
281317
allowed_files: vec![],
282318
test_dir: "rlib2".to_string(),
283319
},
284-
|| {
285-
rustc().crate_type("rlib").input("foo.rs").emit("link=rlib2/foo").run();
286-
},
287-
);
288-
assert_expected_output_files(
289-
Expectations {
290-
expected_files: s!["foo"],
291-
allowed_files: vec![],
292-
test_dir: "rlib3".to_string(),
293-
},
294-
|| {
295-
rustc().crate_type("rlib").input("foo.rs").arg("--emit=link=rlib3/foo").run();
296-
},
297-
);
298-
299-
assert_expected_output_files(
300-
Expectations {
301-
expected_files: s![bin_foo],
302-
allowed_files: s![
303-
"libfoo.dll.exp",
304-
"libfoo.dll.lib",
305-
"libfoo.pdb",
306-
"libfoo.dll.a",
307-
"libfoo.exe.a",
308-
"foo.dll.exp",
309-
"foo.dll.lib",
310-
"foo.pdb",
311-
"foo.dll.a",
312-
"foo.exe.a"
313-
],
314-
test_dir: "dylib".to_string(),
315-
},
316-
|| {
317-
rustc()
318-
.crate_type("dylib")
319-
.input("foo.rs")
320-
.output("dylib/".to_owned() + &bin_foo)
321-
.run();
322-
},
323-
);
324-
assert_expected_output_files(
325-
Expectations {
326-
expected_files: s![bin_foo],
327-
allowed_files: s![
328-
"libfoo.dll.exp",
329-
"libfoo.dll.lib",
330-
"libfoo.pdb",
331-
"libfoo.dll.a",
332-
"libfoo.exe.a",
333-
"foo.dll.exp",
334-
"foo.dll.lib",
335-
"foo.pdb",
336-
"foo.dll.a",
337-
"foo.exe.a"
338-
],
339-
test_dir: "dylib2".to_string(),
340-
},
341320
|| {
342321
rustc()
343-
.crate_type("dylib")
322+
.target(target())
323+
.crate_type("rlib")
344324
.input("foo.rs")
345-
.emit(&format!("link=dylib2/{bin_foo}"))
325+
.emit("link=rlib2/foo")
346326
.run();
347327
},
348328
);
349329
assert_expected_output_files(
350330
Expectations {
351-
expected_files: s![bin_foo],
352-
allowed_files: s![
353-
"libfoo.dll.exp",
354-
"libfoo.dll.lib",
355-
"libfoo.pdb",
356-
"libfoo.dll.a",
357-
"libfoo.exe.a",
358-
"foo.dll.exp",
359-
"foo.dll.lib",
360-
"foo.pdb",
361-
"foo.dll.a",
362-
"foo.exe.a"
363-
],
364-
test_dir: "dylib3".to_string(),
331+
expected_files: s!["foo"],
332+
allowed_files: vec![],
333+
test_dir: "rlib3".to_string(),
365334
},
366335
|| {
367336
rustc()
368-
.crate_type("dylib")
337+
.target(target())
338+
.crate_type("rlib")
369339
.input("foo.rs")
370-
.arg(&format!("--emit=link=dylib3/{bin_foo}"))
340+
.arg("--emit=link=rlib3/foo")
371341
.run();
372342
},
373343
);
374344

345+
if expect_dylib {
346+
assert_expected_output_files(
347+
Expectations {
348+
expected_files: s![bin_foo],
349+
allowed_files: s![
350+
"libfoo.dll.exp",
351+
"libfoo.dll.lib",
352+
"libfoo.pdb",
353+
"libfoo.dll.a",
354+
"libfoo.exe.a",
355+
"foo.dll.exp",
356+
"foo.dll.lib",
357+
"foo.pdb",
358+
"foo.dll.a",
359+
"foo.exe.a"
360+
],
361+
test_dir: "dylib".to_string(),
362+
},
363+
|| {
364+
rustc()
365+
.target(target())
366+
.crate_type("dylib")
367+
.input("foo.rs")
368+
.output("dylib/".to_owned() + &bin_foo)
369+
.run();
370+
},
371+
);
372+
assert_expected_output_files(
373+
Expectations {
374+
expected_files: s![bin_foo],
375+
allowed_files: s![
376+
"libfoo.dll.exp",
377+
"libfoo.dll.lib",
378+
"libfoo.pdb",
379+
"libfoo.dll.a",
380+
"libfoo.exe.a",
381+
"foo.dll.exp",
382+
"foo.dll.lib",
383+
"foo.pdb",
384+
"foo.dll.a",
385+
"foo.exe.a"
386+
],
387+
test_dir: "dylib2".to_string(),
388+
},
389+
|| {
390+
rustc()
391+
.target(target())
392+
.crate_type("dylib")
393+
.input("foo.rs")
394+
.emit(&format!("link=dylib2/{bin_foo}"))
395+
.run();
396+
},
397+
);
398+
assert_expected_output_files(
399+
Expectations {
400+
expected_files: s![bin_foo],
401+
allowed_files: s![
402+
"libfoo.dll.exp",
403+
"libfoo.dll.lib",
404+
"libfoo.pdb",
405+
"libfoo.dll.a",
406+
"libfoo.exe.a",
407+
"foo.dll.exp",
408+
"foo.dll.lib",
409+
"foo.pdb",
410+
"foo.dll.a",
411+
"foo.exe.a"
412+
],
413+
test_dir: "dylib3".to_string(),
414+
},
415+
|| {
416+
rustc()
417+
.target(target())
418+
.crate_type("dylib")
419+
.input("foo.rs")
420+
.arg(&format!("--emit=link=dylib3/{bin_foo}"))
421+
.run();
422+
},
423+
);
424+
}
425+
375426
assert_expected_output_files(
376427
Expectations {
377428
expected_files: s!["foo"],
378429
allowed_files: vec![],
379430
test_dir: "staticlib".to_string(),
380431
},
381432
|| {
382-
rustc().crate_type("staticlib").input("foo.rs").output("staticlib/foo").run();
433+
rustc()
434+
.target(target())
435+
.crate_type("staticlib")
436+
.input("foo.rs")
437+
.output("staticlib/foo")
438+
.run();
383439
},
384440
);
385441
assert_expected_output_files(
@@ -389,7 +445,12 @@ fn main() {
389445
test_dir: "staticlib2".to_string(),
390446
},
391447
|| {
392-
rustc().crate_type("staticlib").input("foo.rs").emit("link=staticlib2/foo").run();
448+
rustc()
449+
.target(target())
450+
.crate_type("staticlib")
451+
.input("foo.rs")
452+
.emit("link=staticlib2/foo")
453+
.run();
393454
},
394455
);
395456
assert_expected_output_files(
@@ -399,7 +460,12 @@ fn main() {
399460
test_dir: "staticlib3".to_string(),
400461
},
401462
|| {
402-
rustc().crate_type("staticlib").input("foo.rs").arg("--emit=link=staticlib3/foo").run();
463+
rustc()
464+
.target(target())
465+
.crate_type("staticlib")
466+
.input("foo.rs")
467+
.arg("--emit=link=staticlib3/foo")
468+
.run();
403469
},
404470
);
405471

@@ -411,6 +477,7 @@ fn main() {
411477
},
412478
|| {
413479
rustc()
480+
.target(target())
414481
.crate_type("bin")
415482
.input("foo.rs")
416483
.output("bincrate/".to_owned() + &bin_foo)
@@ -425,6 +492,7 @@ fn main() {
425492
},
426493
|| {
427494
rustc()
495+
.target(target())
428496
.crate_type("bin")
429497
.input("foo.rs")
430498
.emit(&format!("link=bincrate2/{bin_foo}"))
@@ -439,6 +507,7 @@ fn main() {
439507
},
440508
|| {
441509
rustc()
510+
.target(target())
442511
.crate_type("bin")
443512
.input("foo.rs")
444513
.arg(&format!("--emit=link=bincrate3/{bin_foo}"))
@@ -454,6 +523,7 @@ fn main() {
454523
},
455524
|| {
456525
rustc()
526+
.target(target())
457527
.input("foo.rs")
458528
.emit("llvm-ir=rlib-ir/ir")
459529
.emit("link")
@@ -471,6 +541,7 @@ fn main() {
471541
},
472542
|| {
473543
rustc()
544+
.target(target())
474545
.input("foo.rs")
475546
.emit("asm=staticlib-all/asm")
476547
.emit("llvm-ir=staticlib-all/ir")
@@ -489,6 +560,7 @@ fn main() {
489560
},
490561
|| {
491562
rustc()
563+
.target(target())
492564
.input("foo.rs")
493565
.arg("--emit=asm=staticlib-all2/asm")
494566
.arg("--emit")
@@ -510,6 +582,7 @@ fn main() {
510582
},
511583
|| {
512584
rustc()
585+
.target(target())
513586
.input("foo.rs")
514587
.emit("asm,llvm-ir,llvm-bc,obj,link")
515588
.crate_type("staticlib")
@@ -529,6 +602,7 @@ fn main() {
529602
|| {
530603
rfs::rename("staticlib-all3/bar.bc", "rlib-emits/foo.bc");
531604
rustc()
605+
.target(target())
532606
.input("foo.rs")
533607
.emit("llvm-bc,link")
534608
.crate_type("rlib")

0 commit comments

Comments
 (0)
This repository has been archived.