@@ -51,13 +51,30 @@ fn template(me: &str) -> Command {
51
51
return m;
52
52
}
53
53
54
+ fn expected ( fn_name : & str ) -> String {
55
+ // FIXME(#32481)
56
+ //
57
+ // On windows, we read the function name from debuginfo using some
58
+ // system APIs. For whatever reason, these APIs seem to use the
59
+ // "name" field, which is only the "relative" name, not the full
60
+ // name with namespace info, so we just see `foo` and not
61
+ // `backtrace::foo` as we see on linux (which uses the linkage
62
+ // name).
63
+
64
+ if cfg ! ( windows) {
65
+ format ! ( " - {}" , fn_name)
66
+ } else {
67
+ format ! ( " - backtrace::{}" , fn_name)
68
+ }
69
+ }
70
+
54
71
fn runtest ( me : & str ) {
55
72
// Make sure that the stack trace is printed
56
73
let p = template ( me) . arg ( "fail" ) . env ( "RUST_BACKTRACE" , "1" ) . spawn ( ) . unwrap ( ) ;
57
74
let out = p. wait_with_output ( ) . unwrap ( ) ;
58
75
assert ! ( !out. status. success( ) ) ;
59
76
let s = str:: from_utf8 ( & out. stderr ) . unwrap ( ) ;
60
- assert ! ( s. contains( "stack backtrace" ) && s. contains( " - backtrace:: foo") ,
77
+ assert ! ( s. contains( "stack backtrace" ) && s. contains( & expected ( " foo") ) ,
61
78
"bad output: {}" , s) ;
62
79
63
80
// Make sure the stack trace is *not* printed
@@ -67,7 +84,7 @@ fn runtest(me: &str) {
67
84
let out = p. wait_with_output ( ) . unwrap ( ) ;
68
85
assert ! ( !out. status. success( ) ) ;
69
86
let s = str:: from_utf8 ( & out. stderr ) . unwrap ( ) ;
70
- assert ! ( !s. contains( "stack backtrace" ) && !s. contains( " - backtrace:: foo") ,
87
+ assert ! ( !s. contains( "stack backtrace" ) && !s. contains( & expected ( " foo") ) ,
71
88
"bad output2: {}" , s) ;
72
89
73
90
// Make sure a stack trace is printed
@@ -77,7 +94,7 @@ fn runtest(me: &str) {
77
94
let s = str:: from_utf8 ( & out. stderr ) . unwrap ( ) ;
78
95
// loosened the following from double::h to double:: due to
79
96
// spurious failures on mac, 32bit, optimized
80
- assert ! ( s. contains( "stack backtrace" ) && s. contains( " - backtrace:: double") ,
97
+ assert ! ( s. contains( "stack backtrace" ) && s. contains( & expected ( " double") ) ,
81
98
"bad output3: {}" , s) ;
82
99
83
100
// Make sure a stack trace isn't printed too many times
0 commit comments