@@ -7,7 +7,6 @@ use rustc_span::edition::Edition;
7
7
use rustc_span:: source_map:: DUMMY_SP ;
8
8
9
9
use crate :: config:: { Options , RenderOptions } ;
10
- use crate :: externalfiles:: { load_string, LoadStringError } ;
11
10
use crate :: html:: escape:: Escape ;
12
11
use crate :: html:: markdown;
13
12
use crate :: html:: markdown:: { find_testable_code, ErrorCodes , IdMap , Markdown , MarkdownWithToc } ;
@@ -116,13 +115,9 @@ pub fn render<P: AsRef<Path>>(
116
115
}
117
116
118
117
/// Runs any tests/code examples in the markdown file `input`.
119
- pub fn test ( mut options : Options , diag : & rustc_errors:: Handler ) -> i32 {
120
- let input_str = match load_string ( & options. input , diag) {
121
- Ok ( s) => s,
122
- Err ( LoadStringError :: ReadFail ) => return 1 ,
123
- Err ( LoadStringError :: BadUtf8 ) => return 2 ,
124
- } ;
125
-
118
+ pub fn test ( mut options : Options ) -> Result < ( ) , String > {
119
+ let input_str = read_to_string ( & options. input )
120
+ . map_err ( |err| format ! ( "{}: {}" , options. input. display( ) , err) ) ?;
126
121
let mut opts = TestOptions :: default ( ) ;
127
122
opts. no_crate_inject = true ;
128
123
opts. display_warnings = options. display_warnings ;
@@ -146,5 +141,5 @@ pub fn test(mut options: Options, diag: &rustc_errors::Handler) -> i32 {
146
141
collector. tests ,
147
142
Some ( testing:: Options :: new ( ) . display_output ( options. display_warnings ) ) ,
148
143
) ;
149
- 0
144
+ Ok ( ( ) )
150
145
}
0 commit comments