1- use std:: io:: Read ;
2-
31use camino:: Utf8Path ;
42use semver:: Version ;
53
@@ -10,12 +8,12 @@ use crate::directives::{
108} ;
119use crate :: executor:: { CollectedTestDesc , ShouldPanic } ;
1210
13- fn make_test_description < R : Read > (
11+ fn make_test_description (
1412 config : & Config ,
1513 name : String ,
1614 path : & Utf8Path ,
1715 filterable_path : & Utf8Path ,
18- src : R ,
16+ file_contents : & str ,
1917 revision : Option < & str > ,
2018) -> CollectedTestDesc {
2119 let cache = DirectivesCache :: load ( config) ;
@@ -26,7 +24,7 @@ fn make_test_description<R: Read>(
2624 name,
2725 path,
2826 filterable_path,
29- src ,
27+ file_contents ,
3028 revision,
3129 & mut poisoned,
3230 ) ;
@@ -226,14 +224,13 @@ fn cfg() -> ConfigBuilder {
226224}
227225
228226fn parse_rs ( config : & Config , contents : & str ) -> EarlyProps {
229- let bytes = contents. as_bytes ( ) ;
230- EarlyProps :: from_reader ( config, Utf8Path :: new ( "a.rs" ) , bytes)
227+ EarlyProps :: from_file_contents ( config, Utf8Path :: new ( "a.rs" ) , contents)
231228}
232229
233230fn check_ignore ( config : & Config , contents : & str ) -> bool {
234231 let tn = String :: new ( ) ;
235232 let p = Utf8Path :: new ( "a.rs" ) ;
236- let d = make_test_description ( & config, tn, p, p, std :: io :: Cursor :: new ( contents) , None ) ;
233+ let d = make_test_description ( & config, tn, p, p, contents, None ) ;
237234 d. ignore
238235}
239236
@@ -243,9 +240,9 @@ fn should_fail() {
243240 let tn = String :: new ( ) ;
244241 let p = Utf8Path :: new ( "a.rs" ) ;
245242
246- let d = make_test_description ( & config, tn. clone ( ) , p, p, std :: io :: Cursor :: new ( "" ) , None ) ;
243+ let d = make_test_description ( & config, tn. clone ( ) , p, p, "" , None ) ;
247244 assert_eq ! ( d. should_panic, ShouldPanic :: No ) ;
248- let d = make_test_description ( & config, tn, p, p, std :: io :: Cursor :: new ( "//@ should-fail" ) , None ) ;
245+ let d = make_test_description ( & config, tn, p, p, "//@ should-fail" , None ) ;
249246 assert_eq ! ( d. should_panic, ShouldPanic :: Yes ) ;
250247}
251248
@@ -778,9 +775,8 @@ fn threads_support() {
778775 }
779776}
780777
781- fn run_path ( poisoned : & mut bool , path : & Utf8Path , buf : & [ u8 ] ) {
782- let rdr = std:: io:: Cursor :: new ( & buf) ;
783- iter_directives ( TestMode :: Ui , poisoned, path, rdr, & mut |_| { } ) ;
778+ fn run_path ( poisoned : & mut bool , path : & Utf8Path , file_contents : & str ) {
779+ iter_directives ( TestMode :: Ui , poisoned, path, file_contents, & mut |_| { } ) ;
784780}
785781
786782#[ test]
@@ -789,7 +785,7 @@ fn test_unknown_directive_check() {
789785 run_path (
790786 & mut poisoned,
791787 Utf8Path :: new ( "a.rs" ) ,
792- include_bytes ! ( "./test-auxillary/unknown_directive.rs" ) ,
788+ include_str ! ( "./test-auxillary/unknown_directive.rs" ) ,
793789 ) ;
794790 assert ! ( poisoned) ;
795791}
@@ -800,7 +796,7 @@ fn test_known_directive_check_no_error() {
800796 run_path (
801797 & mut poisoned,
802798 Utf8Path :: new ( "a.rs" ) ,
803- include_bytes ! ( "./test-auxillary/known_directive.rs" ) ,
799+ include_str ! ( "./test-auxillary/known_directive.rs" ) ,
804800 ) ;
805801 assert ! ( !poisoned) ;
806802}
@@ -811,7 +807,7 @@ fn test_error_annotation_no_error() {
811807 run_path (
812808 & mut poisoned,
813809 Utf8Path :: new ( "a.rs" ) ,
814- include_bytes ! ( "./test-auxillary/error_annotation.rs" ) ,
810+ include_str ! ( "./test-auxillary/error_annotation.rs" ) ,
815811 ) ;
816812 assert ! ( !poisoned) ;
817813}
@@ -822,29 +818,29 @@ fn test_non_rs_unknown_directive_not_checked() {
822818 run_path (
823819 & mut poisoned,
824820 Utf8Path :: new ( "a.Makefile" ) ,
825- include_bytes ! ( "./test-auxillary/not_rs.Makefile" ) ,
821+ include_str ! ( "./test-auxillary/not_rs.Makefile" ) ,
826822 ) ;
827823 assert ! ( !poisoned) ;
828824}
829825
830826#[ test]
831827fn test_trailing_directive ( ) {
832828 let mut poisoned = false ;
833- run_path ( & mut poisoned, Utf8Path :: new ( "a.rs" ) , b "//@ only-x86 only-arm") ;
829+ run_path ( & mut poisoned, Utf8Path :: new ( "a.rs" ) , "//@ only-x86 only-arm" ) ;
834830 assert ! ( poisoned) ;
835831}
836832
837833#[ test]
838834fn test_trailing_directive_with_comment ( ) {
839835 let mut poisoned = false ;
840- run_path ( & mut poisoned, Utf8Path :: new ( "a.rs" ) , b "//@ only-x86 only-arm with comment") ;
836+ run_path ( & mut poisoned, Utf8Path :: new ( "a.rs" ) , "//@ only-x86 only-arm with comment" ) ;
841837 assert ! ( poisoned) ;
842838}
843839
844840#[ test]
845841fn test_not_trailing_directive ( ) {
846842 let mut poisoned = false ;
847- run_path ( & mut poisoned, Utf8Path :: new ( "a.rs" ) , b "//@ revisions: incremental") ;
843+ run_path ( & mut poisoned, Utf8Path :: new ( "a.rs" ) , "//@ revisions: incremental" ) ;
848844 assert ! ( !poisoned) ;
849845}
850846
0 commit comments