@@ -9,11 +9,71 @@ use run_make_support::{diff, rfs, rustc};
9
9
10
10
fn main ( ) {
11
11
rfs:: create_dir ( "out" ) ;
12
- let tests = [ "asm" , "llvm-ir" , "dep-info" , "mir" , "llvm-bc" , "obj" , "metadata" , "link" ] ;
13
- for test in tests {
14
- test_emit ( test) ;
15
- }
16
- // These two last tests, which combine multiple emit types, should be done separately.
12
+ test_asm ( ) ;
13
+ test_llvm_ir ( ) ;
14
+ test_dep_info ( ) ;
15
+ test_mir ( ) ;
16
+ test_llvm_bc ( ) ;
17
+ test_obj ( ) ;
18
+ test_metadata ( ) ;
19
+ test_link ( ) ;
20
+ test_multiple_types ( ) ;
21
+ test_multiple_types_option_o ( ) ;
22
+ }
23
+
24
+ fn test_asm ( ) {
25
+ rustc ( ) . emit ( "asm=out/asm" ) . input ( "test.rs" ) . run ( ) ;
26
+ let emit = rustc ( ) . emit ( "asm=-" ) . input ( "test.rs" ) . run ( ) . stdout_utf8 ( ) ;
27
+ diff ( ) . expected_file ( "out/asm" ) . actual_text ( "actual" , & emit) . run ( ) ;
28
+ }
29
+
30
+ fn test_llvm_ir ( ) {
31
+ rustc ( ) . emit ( "llvm-ir=out/llvm-ir" ) . input ( "test.rs" ) . run ( ) ;
32
+ let emit = rustc ( ) . emit ( "llvm-ir=-" ) . input ( "test.rs" ) . run ( ) . stdout_utf8 ( ) ;
33
+ diff ( ) . expected_file ( "out/llvm-ir" ) . actual_text ( "actual" , & emit) . run ( ) ;
34
+ }
35
+
36
+ fn test_dep_info ( ) {
37
+ rustc ( )
38
+ . emit ( "dep-info=out/dep-info" )
39
+ . input ( "test.rs" )
40
+ . arg ( "-Zdep-info-omit-d-target=yes" )
41
+ . run ( ) ;
42
+ let emit = rustc ( ) . emit ( "dep-info=-" ) . input ( "test.rs" ) . run ( ) . stdout_utf8 ( ) ;
43
+ diff ( ) . expected_file ( "out/dep-info" ) . actual_text ( "actual" , & emit) . run ( ) ;
44
+ }
45
+
46
+ fn test_mir ( ) {
47
+ rustc ( ) . emit ( "mir=out/mir" ) . input ( "test.rs" ) . run ( ) ;
48
+ let emit = rustc ( ) . emit ( "mir=-" ) . input ( "test.rs" ) . run ( ) . stdout_utf8 ( ) ;
49
+ diff ( ) . expected_file ( "out/mir" ) . actual_text ( "actual" , & emit) . run ( ) ;
50
+ }
51
+
52
+ // FIXME: ptmx
53
+ fn test_llvm_bc ( ) {
54
+ let emit = rustc ( ) . emit ( "llvm-bc=-" ) . input ( "test.rs" ) . run ( ) . stderr_utf8 ( ) ;
55
+ diff ( ) . expected_file ( "emit-llvm-bc.stderr" ) . actual_text ( "actual" , & emit) . run ( ) ;
56
+ }
57
+
58
+ // FIXME: ptmx
59
+ fn test_obj ( ) {
60
+ let emit = rustc ( ) . emit ( "obj=-" ) . input ( "test.rs" ) . run ( ) . stderr_utf8 ( ) ;
61
+ diff ( ) . expected_file ( "emit-obj.stderr" ) . actual_text ( "actual" , & emit) . run ( ) ;
62
+ }
63
+
64
+ // FIXME: ptmx
65
+ fn test_metadata ( ) {
66
+ let emit = rustc ( ) . emit ( "metadata=-" ) . input ( "test.rs" ) . run ( ) . stderr_utf8 ( ) ;
67
+ diff ( ) . expected_file ( "emit-metadata.stderr" ) . actual_text ( "actual" , & emit) . run ( ) ;
68
+ }
69
+
70
+ // FIXME: ptmx
71
+ fn test_link ( ) {
72
+ let emit = rustc ( ) . emit ( "link=-" ) . input ( "test.rs" ) . run ( ) . stderr_utf8 ( ) ;
73
+ diff ( ) . expected_file ( "emit-link.stderr" ) . actual_text ( "actual" , & emit) . run ( ) ;
74
+ }
75
+
76
+ fn test_multiple_types ( ) {
17
77
diff ( )
18
78
. expected_file ( "emit-multiple-types.stderr" )
19
79
. actual_text (
@@ -29,6 +89,9 @@ fn main() {
29
89
. stderr_utf8 ( ) ,
30
90
)
31
91
. run ( ) ;
92
+ }
93
+
94
+ fn test_multiple_types_option_o ( ) {
32
95
diff ( )
33
96
. expected_file ( "emit-multiple-types.stderr" )
34
97
. actual_text (
@@ -42,38 +105,3 @@ fn main() {
42
105
)
43
106
. run ( ) ;
44
107
}
45
-
46
- fn test_emit ( emit_type : & str ) {
47
- // Emitting these types will cause a compilation failure, which should be compared to a
48
- // blessed stderr file for differences.
49
- let stderr_types = [ "llvm-bc" , "obj" , "metadata" , "link" ] ;
50
- // Successful types (not in stderr_types) should start by outputting one emit file.
51
- if !stderr_types. contains ( & emit_type) {
52
- let mut initial_compile = rustc ( ) ;
53
- initial_compile. emit ( & format ! ( "{emit_type}=out/{emit_type}" ) ) . input ( "test.rs" ) ;
54
- // dep-info requires an extra unstable argument.
55
- if emit_type == "dep-info" {
56
- initial_compile. arg ( "-Zdep-info-omit-d-target=yes" ) ;
57
- }
58
- initial_compile. run ( ) ;
59
- }
60
- let mut compile = rustc ( ) ;
61
- compile. emit ( & format ! ( "{emit_type}=-" ) ) . input ( "test.rs" ) ;
62
- // Check if compilation should succeed or fail depending on the emit type.
63
- let compile =
64
- if stderr_types. contains ( & emit_type) { compile. run_fail ( ) } else { compile. run ( ) } ;
65
- let emit = if stderr_types. contains ( & emit_type) {
66
- compile. stderr_utf8 ( )
67
- } else {
68
- compile. stdout_utf8 ( )
69
- } ;
70
- let mut diff = diff ( ) ;
71
- // Compare the output with either an emit file or stderr file, depending on success
72
- // or failure.
73
- if stderr_types. contains ( & emit_type) {
74
- diff. expected_file ( & format ! ( "emit-{emit_type}.stderr" ) ) ;
75
- } else {
76
- diff. expected_file ( & format ! ( "out/{emit_type}" ) ) ;
77
- }
78
- diff. actual_text ( "actual" , & emit) . run ( ) ;
79
- }
0 commit comments