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