@@ -1879,20 +1879,19 @@ actual:\n\
18791879 fn run_rustdoc_test ( & self ) {
18801880 assert ! ( self . revision. is_none( ) , "revisions not relevant here" ) ;
18811881
1882- if self . props . compile_flags . contains ( & "--test" . to_owned ( ) ) &&
1883- self . props . check_stdout == true {
1884- self . check_rustdoc_test_option ( ) ;
1885- } else {
1886- let out_dir = self . output_base_name ( ) ;
1887- let _ = fs:: remove_dir_all ( & out_dir) ;
1888- self . create_dir_racy ( & out_dir) ;
1882+ let out_dir = self . output_base_name ( ) ;
1883+ let _ = fs:: remove_dir_all ( & out_dir) ;
1884+ self . create_dir_racy ( & out_dir) ;
18891885
1890- let proc_res = self . document ( & out_dir) ;
1891- if !proc_res. status . success ( ) {
1892- self . fatal_proc_rec ( "rustdoc failed!" , & proc_res) ;
1893- }
1894- let root = self . find_rust_src_root ( ) . unwrap ( ) ;
1886+ let proc_res = self . document ( & out_dir) ;
1887+ if !proc_res. status . success ( ) {
1888+ self . fatal_proc_rec ( "rustdoc failed!" , & proc_res) ;
1889+ }
18951890
1891+ if self . props . check_test_line_numbers_match == true {
1892+ self . check_rustdoc_test_option ( proc_res) ;
1893+ } else {
1894+ let root = self . find_rust_src_root ( ) . unwrap ( ) ;
18961895 let res = self . cmd2procres ( Command :: new ( & self . config . docck_python )
18971896 . arg ( root. join ( "src/etc/htmldocck.py" ) )
18981897 . arg ( out_dir)
@@ -1903,21 +1902,20 @@ actual:\n\
19031902 }
19041903 }
19051904
1906- fn check_rustdoc_test_option ( & self ) {
1905+ fn check_rustdoc_test_option ( & self , res : ProcRes ) {
19071906 let mut file = fs:: File :: open ( & self . testpaths . file )
19081907 . expect ( "markdown_test_output_check_entry File::open failed" ) ;
19091908 let mut content = String :: new ( ) ;
19101909 file. read_to_string ( & mut content)
19111910 . expect ( "markdown_test_output_check_entry read_to_string failed" ) ;
19121911 let mut ignore = false ;
19131912 let mut v: Vec < usize > =
1914- content. split ( " \n " )
1913+ content. lines ( )
19151914 . enumerate ( )
19161915 . filter_map ( |( line_nb, line) | {
19171916 let sline = line. split ( "///" ) . last ( ) . unwrap_or ( "" ) ;
19181917 let line = sline. trim_left ( ) ;
1919- if line. starts_with ( "```" ) &&
1920- !line. contains ( "ignore" ) {
1918+ if line. starts_with ( "```" ) {
19211919 if ignore {
19221920 ignore = false ;
19231921 None
@@ -1931,37 +1929,30 @@ actual:\n\
19311929 } )
19321930 . collect ( ) ;
19331931
1934- let args = ProcArgs {
1935- prog : self . config . rustdoc_path . to_str ( ) . unwrap ( ) . to_owned ( ) ,
1936- args : vec ! [ "--test" . to_owned( ) , self . testpaths. file. to_str( ) . unwrap( ) . to_owned( ) ] ,
1937- } ;
1938- let env = self . props . exec_env . clone ( ) ;
1939- let res = self . compose_and_run ( args,
1940- env,
1941- self . config . run_lib_path . to_str ( ) . unwrap ( ) ,
1942- None ,
1943- None ) ;
1944-
1945- res. stdout . split ( "\n " )
1946- . filter ( |s| s. starts_with ( "test " ) )
1947- . inspect ( |s| {
1948- let tmp: Vec < & str > = s. split ( " - line " ) . collect ( ) ;
1949- if tmp. len ( ) == 2 {
1950- let line = usize:: from_str_radix ( tmp[ 1 ] . split ( " ..." )
1951- . next ( )
1952- . unwrap_or ( "0" ) , 10 )
1953- . unwrap_or ( 0 ) ;
1954- if let Ok ( pos) = v. binary_search ( & line) {
1955- v. remove ( pos) ;
1956- } else {
1957- self . fatal_proc_rec ( & format ! ( "Not found doc test: \" {}\" in {:?}" ,
1958- s, v) ,
1959- & res) ;
1960- }
1961- }
1962- } )
1963- . all ( |_| true ) ;
1964- if v. len ( ) != 0 {
1932+ let mut tested = 0 ;
1933+ for _ in res. stdout . split ( "\n " )
1934+ . filter ( |s| s. starts_with ( "test " ) )
1935+ . inspect ( |s| {
1936+ let tmp: Vec < & str > = s. split ( " - line " ) . collect ( ) ;
1937+ if tmp. len ( ) == 2 {
1938+ tested += 1 ;
1939+ let line = tmp[ 1 ] . split ( " ..." )
1940+ . next ( )
1941+ . unwrap_or ( "0" )
1942+ . parse ( )
1943+ . unwrap_or ( 0 ) ;
1944+ if let Ok ( pos) = v. binary_search ( & line) {
1945+ v. remove ( pos) ;
1946+ } else {
1947+ self . fatal_proc_rec (
1948+ & format ! ( "Not found doc test: \" {}\" in {:?}" , s, v) ,
1949+ & res) ;
1950+ }
1951+ }
1952+ } ) { }
1953+ if tested == 0 {
1954+ self . fatal_proc_rec ( "No test has been found" , & res) ;
1955+ } else if v. len ( ) != 0 {
19651956 self . fatal_proc_rec ( & format ! ( "Not found test at line{} {:?}" ,
19661957 if v. len( ) > 1 { "s" } else { "" } , v) ,
19671958 & res) ;
0 commit comments