5
5
// See https://github.com/rust-lang/rust/pull/12020
6
6
7
7
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,
9
9
shallow_find_files, static_lib_name,
10
10
} ;
11
+ use std:: path:: PathBuf ;
11
12
12
13
// Each test takes 4 arguments:
13
14
// `must_exist`: output files which must be found - if any are absent, the test fails
14
15
// `can_exist`: optional output files which will not trigger a failure
15
16
// `dir`: the name of the directory where the test happens
16
17
// `rustc_invocation`: the rustc command being tested
17
18
// 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) ;
19
+ fn assert_expected_output_files ( expectations : Expectations , rustc_invocation : impl Fn ( ) ) {
20
+ let must_exist = expectations. expected_files ;
21
+ let can_exist = expectations. allowed_files ;
22
+ let dir = expectations. test_dir ;
23
+
24
+ fs_wrapper:: create_dir ( & dir) ;
25
25
rustc_invocation ( ) ;
26
26
for file in must_exist {
27
- fs_wrapper:: remove_file ( dir. to_owned ( ) + "/" + file) ;
27
+ fs_wrapper:: remove_file ( PathBuf :: from ( & dir) . join ( & file) ) ;
28
28
}
29
- let actual_output_files = shallow_find_files ( dir, |path| name_not_among ( path, can_exist) ) ;
29
+ let actual_output_files =
30
+ shallow_find_files ( dir, |path| filename_not_in_denylist ( path, & can_exist) ) ;
30
31
if !& actual_output_files. is_empty ( ) {
31
32
dbg ! ( & actual_output_files) ;
32
33
panic ! ( "unexpected output artifacts detected" ) ;
33
34
}
34
35
}
35
36
37
+ struct Expectations {
38
+ /// Output files which must be found. The test fails if any are absent.
39
+ expected_files : Vec < String > ,
40
+ /// Allowed output files which will not trigger a failure.
41
+ allowed_files : Vec < String > ,
42
+ /// Name of the directory where the test happens.
43
+ test_dir : String ,
44
+ }
45
+
46
+ macro_rules! s {
47
+ ( $( $x: expr ) ,* ) => {
48
+ {
49
+ let mut temp_vec = Vec :: new( ) ;
50
+ $(
51
+ temp_vec. push( $x. to_string( ) ) ;
52
+ ) *
53
+ temp_vec
54
+ }
55
+ } ;
56
+ }
57
+
36
58
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" ) ) ) ;
59
+ let bin_foo = bin_name ( "foo" ) ;
42
60
43
61
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" ,
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
+ } ,
58
82
|| {
59
83
rustc ( )
60
84
. input ( "foo.rs" )
@@ -64,113 +88,256 @@ fn main() {
64
88
} ,
65
89
) ;
66
90
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
- } ) ;
91
+ assert_expected_output_files (
92
+ Expectations {
93
+ expected_files : s ! [ bin_name( "bar" ) ] ,
94
+ allowed_files : s ! [ "bar.pdb" ] ,
95
+ test_dir : "bin-crate" . to_string ( ) ,
96
+ } ,
97
+ || {
98
+ rustc ( ) . input ( "foo.rs" ) . crate_type ( "bin" ) . out_dir ( "bin-crate" ) . run ( ) ;
99
+ } ,
100
+ ) ;
70
101
71
102
assert_expected_output_files (
72
- & [ "bar.ll" , "bar.bc" , "bar.s" , "bar.o" , bin_bar] ,
73
- & [ "bar.pdb" ] ,
74
- "all-emit" ,
103
+ Expectations {
104
+ expected_files : s ! [ "bar.ll" , "bar.bc" , "bar.s" , "bar.o" , bin_name( "bar" ) ] ,
105
+ allowed_files : s ! [ "bar.pdb" ] ,
106
+ test_dir : "all-emit" . to_string ( ) ,
107
+ } ,
75
108
|| {
76
109
rustc ( ) . input ( "foo.rs" ) . emit ( "asm,llvm-ir,llvm-bc,obj,link" ) . out_dir ( "all-emit" ) . run ( ) ;
77
110
} ,
78
111
) ;
79
112
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
- } ) ;
113
+ assert_expected_output_files (
114
+ Expectations {
115
+ expected_files : s ! [ "foo" ] ,
116
+ allowed_files : s ! [ ] ,
117
+ test_dir : "asm-emit" . to_string ( ) ,
118
+ } ,
119
+ || {
120
+ rustc ( ) . input ( "foo.rs" ) . emit ( "asm" ) . output ( "asm-emit/foo" ) . run ( ) ;
121
+ } ,
122
+ ) ;
123
+ assert_expected_output_files (
124
+ Expectations {
125
+ expected_files : s ! [ "foo" ] ,
126
+ allowed_files : s ! [ ] ,
127
+ test_dir : "asm-emit2" . to_string ( ) ,
128
+ } ,
129
+ || {
130
+ rustc ( ) . input ( "foo.rs" ) . emit ( "asm=asm-emit2/foo" ) . run ( ) ;
131
+ } ,
132
+ ) ;
133
+ assert_expected_output_files (
134
+ Expectations {
135
+ expected_files : s ! [ "foo" ] ,
136
+ allowed_files : s ! [ ] ,
137
+ test_dir : "asm-emit3" . to_string ( ) ,
138
+ } ,
139
+ || {
140
+ rustc ( ) . input ( "foo.rs" ) . arg ( "--emit=asm=asm-emit3/foo" ) . run ( ) ;
141
+ } ,
142
+ ) ;
89
143
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
- } ) ;
144
+ assert_expected_output_files (
145
+ Expectations {
146
+ expected_files : s ! [ "foo" ] ,
147
+ allowed_files : s ! [ ] ,
148
+ test_dir : "llvm-ir-emit" . to_string ( ) ,
149
+ } ,
150
+ || {
151
+ rustc ( ) . input ( "foo.rs" ) . emit ( "llvm-ir" ) . output ( "llvm-ir-emit/foo" ) . run ( ) ;
152
+ } ,
153
+ ) ;
154
+ assert_expected_output_files (
155
+ Expectations {
156
+ expected_files : s ! [ "foo" ] ,
157
+ allowed_files : s ! [ ] ,
158
+ test_dir : "llvm-ir-emit2" . to_string ( ) ,
159
+ } ,
160
+ || {
161
+ rustc ( ) . input ( "foo.rs" ) . emit ( "llvm-ir=llvm-ir-emit2/foo" ) . run ( ) ;
162
+ } ,
163
+ ) ;
164
+ assert_expected_output_files (
165
+ Expectations {
166
+ expected_files : s ! [ "foo" ] ,
167
+ allowed_files : s ! [ ] ,
168
+ test_dir : "llvm-ir-emit3" . to_string ( ) ,
169
+ } ,
170
+ || {
171
+ rustc ( ) . input ( "foo.rs" ) . arg ( "--emit=llvm-ir=llvm-ir-emit3/foo" ) . run ( ) ;
172
+ } ,
173
+ ) ;
99
174
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
- } ) ;
175
+ assert_expected_output_files (
176
+ Expectations {
177
+ expected_files : s ! [ "foo" ] ,
178
+ allowed_files : s ! [ ] ,
179
+ test_dir : "llvm-bc-emit" . to_string ( ) ,
180
+ } ,
181
+ || {
182
+ rustc ( ) . input ( "foo.rs" ) . emit ( "llvm-bc" ) . output ( "llvm-bc-emit/foo" ) . run ( ) ;
183
+ } ,
184
+ ) ;
185
+ assert_expected_output_files (
186
+ Expectations {
187
+ expected_files : s ! [ "foo" ] ,
188
+ allowed_files : s ! [ ] ,
189
+ test_dir : "llvm-bc-emit2" . to_string ( ) ,
190
+ } ,
191
+ || {
192
+ rustc ( ) . input ( "foo.rs" ) . emit ( "llvm-bc=llvm-bc-emit2/foo" ) . run ( ) ;
193
+ } ,
194
+ ) ;
195
+ assert_expected_output_files (
196
+ Expectations {
197
+ expected_files : s ! [ "foo" ] ,
198
+ allowed_files : s ! [ ] ,
199
+ test_dir : "llvm-bc-emit3" . to_string ( ) ,
200
+ } ,
201
+ || {
202
+ rustc ( ) . input ( "foo.rs" ) . arg ( "--emit=llvm-bc=llvm-bc-emit3/foo" ) . run ( ) ;
203
+ } ,
204
+ ) ;
109
205
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
- } ) ;
206
+ assert_expected_output_files (
207
+ Expectations {
208
+ expected_files : s ! [ "foo" ] ,
209
+ allowed_files : s ! [ ] ,
210
+ test_dir : "obj-emit" . to_string ( ) ,
211
+ } ,
212
+ || {
213
+ rustc ( ) . input ( "foo.rs" ) . emit ( "obj" ) . output ( "obj-emit/foo" ) . run ( ) ;
214
+ } ,
215
+ ) ;
216
+ assert_expected_output_files (
217
+ Expectations {
218
+ expected_files : s ! [ "foo" ] ,
219
+ allowed_files : s ! [ ] ,
220
+ test_dir : "obj-emit2" . to_string ( ) ,
221
+ } ,
222
+ || {
223
+ rustc ( ) . input ( "foo.rs" ) . emit ( "obj=obj-emit2/foo" ) . run ( ) ;
224
+ } ,
225
+ ) ;
226
+ assert_expected_output_files (
227
+ Expectations {
228
+ expected_files : s ! [ "foo" ] ,
229
+ allowed_files : s ! [ ] ,
230
+ test_dir : "obj-emit3" . to_string ( ) ,
231
+ } ,
232
+ || {
233
+ rustc ( ) . input ( "foo.rs" ) . arg ( "--emit=obj=obj-emit3/foo" ) . run ( ) ;
234
+ } ,
235
+ ) ;
119
236
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
- } ) ;
237
+ assert_expected_output_files (
238
+ Expectations {
239
+ expected_files : s ! [ & bin_foo] ,
240
+ allowed_files : s ! [ "foo.pdb" ] ,
241
+ test_dir : "link-emit" . to_string ( ) ,
242
+ } ,
243
+ || {
244
+ rustc ( ) . input ( "foo.rs" ) . emit ( "link" ) . output ( "link-emit/" . to_owned ( ) + & bin_foo) . run ( ) ;
245
+ } ,
246
+ ) ;
247
+ assert_expected_output_files (
248
+ Expectations {
249
+ expected_files : s ! [ & bin_foo] ,
250
+ allowed_files : s ! [ "foo.pdb" ] ,
251
+ test_dir : "link-emit2" . to_string ( ) ,
252
+ } ,
253
+ || {
254
+ rustc ( ) . input ( "foo.rs" ) . emit ( & format ! ( "link=link-emit2/{bin_foo}" ) ) . run ( ) ;
255
+ } ,
256
+ ) ;
257
+ assert_expected_output_files (
258
+ Expectations {
259
+ expected_files : s ! [ & bin_foo] ,
260
+ allowed_files : s ! [ "foo.pdb" ] ,
261
+ test_dir : "link-emit3" . to_string ( ) ,
262
+ } ,
263
+ || {
264
+ rustc ( ) . input ( "foo.rs" ) . arg ( & format ! ( "--emit=link=link-emit3/{bin_foo}" ) ) . run ( ) ;
265
+ } ,
266
+ ) ;
129
267
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
- } ) ;
268
+ assert_expected_output_files (
269
+ Expectations {
270
+ expected_files : s ! [ "foo" ] ,
271
+ allowed_files : s ! [ ] ,
272
+ test_dir : "rlib" . to_string ( ) ,
273
+ } ,
274
+ || {
275
+ rustc ( ) . crate_type ( "rlib" ) . input ( "foo.rs" ) . output ( "rlib/foo" ) . run ( ) ;
276
+ } ,
277
+ ) ;
278
+ assert_expected_output_files (
279
+ Expectations {
280
+ expected_files : s ! [ "foo" ] ,
281
+ allowed_files : s ! [ ] ,
282
+ test_dir : "rlib2" . to_string ( ) ,
283
+ } ,
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 : s ! [ ] ,
292
+ test_dir : "rlib3" . to_string ( ) ,
293
+ } ,
294
+ || {
295
+ rustc ( ) . crate_type ( "rlib" ) . input ( "foo.rs" ) . arg ( "--emit=link=rlib3/foo" ) . run ( ) ;
296
+ } ,
297
+ ) ;
139
298
140
299
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" ,
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
+ } ,
174
341
|| {
175
342
rustc ( )
176
343
. crate_type ( "dylib" )
@@ -180,20 +347,22 @@ fn main() {
180
347
} ,
181
348
) ;
182
349
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" ,
350
+ 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 ( ) ,
365
+ } ,
197
366
|| {
198
367
rustc ( )
199
368
. crate_type ( "dylib" )
@@ -203,55 +372,121 @@ fn main() {
203
372
} ,
204
373
) ;
205
374
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
- } ) ;
375
+ assert_expected_output_files (
376
+ Expectations {
377
+ expected_files : s ! [ "foo" ] ,
378
+ allowed_files : s ! [ ] ,
379
+ test_dir : "staticlib" . to_string ( ) ,
380
+ } ,
381
+ || {
382
+ rustc ( ) . crate_type ( "staticlib" ) . input ( "foo.rs" ) . output ( "staticlib/foo" ) . run ( ) ;
383
+ } ,
384
+ ) ;
385
+ assert_expected_output_files (
386
+ Expectations {
387
+ expected_files : s ! [ "foo" ] ,
388
+ allowed_files : s ! [ ] ,
389
+ test_dir : "staticlib2" . to_string ( ) ,
390
+ } ,
391
+ || {
392
+ rustc ( ) . crate_type ( "staticlib" ) . input ( "foo.rs" ) . emit ( "link=staticlib2/foo" ) . run ( ) ;
393
+ } ,
394
+ ) ;
395
+ assert_expected_output_files (
396
+ Expectations {
397
+ expected_files : s ! [ "foo" ] ,
398
+ allowed_files : s ! [ ] ,
399
+ test_dir : "staticlib3" . to_string ( ) ,
400
+ } ,
401
+ || {
402
+ rustc ( ) . crate_type ( "staticlib" ) . input ( "foo.rs" ) . arg ( "--emit=link=staticlib3/foo" ) . run ( ) ;
403
+ } ,
404
+ ) ;
215
405
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
- } ) ;
406
+ assert_expected_output_files (
407
+ Expectations {
408
+ expected_files : s ! [ bin_foo] ,
409
+ allowed_files : s ! [ "foo.pdb" ] ,
410
+ test_dir : "bincrate" . to_string ( ) ,
411
+ } ,
412
+ || {
413
+ rustc ( )
414
+ . crate_type ( "bin" )
415
+ . input ( "foo.rs" )
416
+ . output ( "bincrate/" . to_owned ( ) + & bin_foo)
417
+ . run ( ) ;
418
+ } ,
419
+ ) ;
420
+ assert_expected_output_files (
421
+ Expectations {
422
+ expected_files : s ! [ bin_foo] ,
423
+ allowed_files : s ! [ "foo.pdb" ] ,
424
+ test_dir : "bincrate2" . to_string ( ) ,
425
+ } ,
426
+ || {
427
+ rustc ( )
428
+ . crate_type ( "bin" )
429
+ . input ( "foo.rs" )
430
+ . emit ( & format ! ( "link=bincrate2/{bin_foo}" ) )
431
+ . run ( ) ;
432
+ } ,
433
+ ) ;
434
+ assert_expected_output_files (
435
+ Expectations {
436
+ expected_files : s ! [ bin_foo] ,
437
+ allowed_files : s ! [ "foo.pdb" ] ,
438
+ test_dir : "bincrate3" . to_string ( ) ,
439
+ } ,
440
+ || {
441
+ rustc ( )
442
+ . crate_type ( "bin" )
443
+ . input ( "foo.rs" )
444
+ . arg ( & format ! ( "--emit=link=bincrate3/{bin_foo}" ) )
445
+ . run ( ) ;
446
+ } ,
447
+ ) ;
229
448
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
- } ) ;
449
+ assert_expected_output_files (
450
+ Expectations {
451
+ expected_files : s ! [ "ir" , rust_lib_name( "bar" ) ] ,
452
+ allowed_files : s ! [ ] ,
453
+ test_dir : "rlib-ir" . to_string ( ) ,
454
+ } ,
455
+ || {
456
+ rustc ( )
457
+ . input ( "foo.rs" )
458
+ . emit ( "llvm-ir=rlib-ir/ir" )
459
+ . emit ( "link" )
460
+ . crate_type ( "rlib" )
461
+ . out_dir ( "rlib-ir" )
462
+ . run ( ) ;
463
+ } ,
464
+ ) ;
239
465
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" ,
466
+ assert_expected_output_files (
467
+ Expectations {
468
+ expected_files : s ! [ "ir" , "asm" , "bc" , "obj" , "link" ] ,
469
+ allowed_files : s ! [ ] ,
470
+ test_dir : "staticlib-all" . to_string ( ) ,
471
+ } ,
472
+ || {
473
+ rustc ( )
474
+ . input ( "foo.rs" )
475
+ . emit ( "asm=staticlib-all/asm" )
476
+ . emit ( "llvm-ir=staticlib-all/ir" )
477
+ . emit ( "llvm-bc=staticlib-all/bc" )
478
+ . emit ( "obj=staticlib-all/obj" )
479
+ . emit ( "link=staticlib-all/link" )
480
+ . crate_type ( "staticlib" )
481
+ . run ( ) ;
482
+ } ,
483
+ ) ;
484
+ assert_expected_output_files (
485
+ Expectations {
486
+ expected_files : s ! [ "ir" , "asm" , "bc" , "obj" , "link" ] ,
487
+ allowed_files : s ! [ ] ,
488
+ test_dir : "staticlib-all2" . to_string ( ) ,
489
+ } ,
255
490
|| {
256
491
rustc ( )
257
492
. input ( "foo.rs" )
@@ -268,9 +503,10 @@ fn main() {
268
503
) ;
269
504
270
505
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" ,
506
+ Expectations { expected_files :
507
+ s ! [ "bar.ll" , "bar.s" , "bar.o" , static_lib_name( "bar" ) ] ,
508
+ allowed_files : s ! [ "bar.bc" ] , test_dir : // keep this one for the next test
509
+ "staticlib-all3" . to_string ( ) } ,
274
510
|| {
275
511
rustc ( )
276
512
. input ( "foo.rs" )
@@ -283,9 +519,24 @@ fn main() {
283
519
284
520
// the .bc file from the previous test should be equivalent to this one, despite the difference
285
521
// 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
- } ) ;
522
+ assert_expected_output_files (
523
+ Expectations {
524
+ expected_files : s ! [ "bar.bc" , rust_lib_name( "bar" ) , "foo.bc" ] ,
525
+ allowed_files : s ! [ ] ,
526
+ test_dir : "rlib-emits" . to_string ( ) ,
527
+ } ,
528
+ || {
529
+ fs_wrapper:: rename ( "staticlib-all3/bar.bc" , "rlib-emits/foo.bc" ) ;
530
+ rustc ( )
531
+ . input ( "foo.rs" )
532
+ . emit ( "llvm-bc,link" )
533
+ . crate_type ( "rlib" )
534
+ . out_dir ( "rlib-emits" )
535
+ . run ( ) ;
536
+ assert_eq ! (
537
+ fs_wrapper:: read( "rlib-emits/foo.bc" ) ,
538
+ fs_wrapper:: read( "rlib-emits/bar.bc" )
539
+ ) ;
540
+ } ,
541
+ ) ;
291
542
}
0 commit comments