@@ -121,13 +121,11 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
121
121
debug ! ( "current path: {}" ,
122
122
ast_util:: path_name_i( & self . cx. path) ) ;
123
123
124
- if is_test_fn ( & self . cx , & * i) || is_bench_fn ( & self . cx , & * i) {
124
+ let i = if is_test_fn ( & self . cx , & * i) || is_bench_fn ( & self . cx , & * i) {
125
125
match i. node {
126
126
ast:: ItemFn ( _, ast:: Unsafety :: Unsafe , _, _, _) => {
127
127
let diag = self . cx . span_diagnostic ;
128
- diag. span_fatal ( i. span ,
129
- "unsafe functions cannot be used for \
130
- tests") ;
128
+ diag. span_fatal ( i. span , "unsafe functions cannot be used for tests" ) ;
131
129
}
132
130
_ => {
133
131
debug ! ( "this is a test function" ) ;
@@ -142,9 +140,18 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
142
140
self . tests . push ( i. ident ) ;
143
141
// debug!("have {} test/bench functions",
144
142
// cx.testfns.len());
143
+
144
+ // Make all tests public so we can call them from outside
145
+ // the module (note that the tests are re-exported and must
146
+ // be made public themselves to avoid privacy errors).
147
+ let mut result = ( * i) . clone ( ) ;
148
+ result. vis = ast:: Public ;
149
+ P ( result)
145
150
}
146
151
}
147
- }
152
+ } else {
153
+ i
154
+ } ;
148
155
149
156
// We don't want to recurse into anything other than mods, since
150
157
// mods or tests inside of functions will break things
0 commit comments