1
- use std:: io:: Read ;
2
-
3
1
use camino:: Utf8Path ;
4
2
use semver:: Version ;
5
3
@@ -10,12 +8,12 @@ use crate::directives::{
10
8
} ;
11
9
use crate :: executor:: { CollectedTestDesc , ShouldPanic } ;
12
10
13
- fn make_test_description < R : Read > (
11
+ fn make_test_description (
14
12
config : & Config ,
15
13
name : String ,
16
14
path : & Utf8Path ,
17
15
filterable_path : & Utf8Path ,
18
- src : R ,
16
+ file_contents : & str ,
19
17
revision : Option < & str > ,
20
18
) -> CollectedTestDesc {
21
19
let cache = DirectivesCache :: load ( config) ;
@@ -26,7 +24,7 @@ fn make_test_description<R: Read>(
26
24
name,
27
25
path,
28
26
filterable_path,
29
- src ,
27
+ file_contents ,
30
28
revision,
31
29
& mut poisoned,
32
30
) ;
@@ -226,14 +224,13 @@ fn cfg() -> ConfigBuilder {
226
224
}
227
225
228
226
fn 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)
231
228
}
232
229
233
230
fn check_ignore ( config : & Config , contents : & str ) -> bool {
234
231
let tn = String :: new ( ) ;
235
232
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 ) ;
237
234
d. ignore
238
235
}
239
236
@@ -243,9 +240,9 @@ fn should_fail() {
243
240
let tn = String :: new ( ) ;
244
241
let p = Utf8Path :: new ( "a.rs" ) ;
245
242
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 ) ;
247
244
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 ) ;
249
246
assert_eq ! ( d. should_panic, ShouldPanic :: Yes ) ;
250
247
}
251
248
@@ -778,9 +775,8 @@ fn threads_support() {
778
775
}
779
776
}
780
777
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 |_| { } ) ;
784
780
}
785
781
786
782
#[ test]
@@ -789,7 +785,7 @@ fn test_unknown_directive_check() {
789
785
run_path (
790
786
& mut poisoned,
791
787
Utf8Path :: new ( "a.rs" ) ,
792
- include_bytes ! ( "./test-auxillary/unknown_directive.rs" ) ,
788
+ include_str ! ( "./test-auxillary/unknown_directive.rs" ) ,
793
789
) ;
794
790
assert ! ( poisoned) ;
795
791
}
@@ -800,7 +796,7 @@ fn test_known_directive_check_no_error() {
800
796
run_path (
801
797
& mut poisoned,
802
798
Utf8Path :: new ( "a.rs" ) ,
803
- include_bytes ! ( "./test-auxillary/known_directive.rs" ) ,
799
+ include_str ! ( "./test-auxillary/known_directive.rs" ) ,
804
800
) ;
805
801
assert ! ( !poisoned) ;
806
802
}
@@ -811,7 +807,7 @@ fn test_error_annotation_no_error() {
811
807
run_path (
812
808
& mut poisoned,
813
809
Utf8Path :: new ( "a.rs" ) ,
814
- include_bytes ! ( "./test-auxillary/error_annotation.rs" ) ,
810
+ include_str ! ( "./test-auxillary/error_annotation.rs" ) ,
815
811
) ;
816
812
assert ! ( !poisoned) ;
817
813
}
@@ -822,29 +818,29 @@ fn test_non_rs_unknown_directive_not_checked() {
822
818
run_path (
823
819
& mut poisoned,
824
820
Utf8Path :: new ( "a.Makefile" ) ,
825
- include_bytes ! ( "./test-auxillary/not_rs.Makefile" ) ,
821
+ include_str ! ( "./test-auxillary/not_rs.Makefile" ) ,
826
822
) ;
827
823
assert ! ( !poisoned) ;
828
824
}
829
825
830
826
#[ test]
831
827
fn test_trailing_directive ( ) {
832
828
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" ) ;
834
830
assert ! ( poisoned) ;
835
831
}
836
832
837
833
#[ test]
838
834
fn test_trailing_directive_with_comment ( ) {
839
835
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" ) ;
841
837
assert ! ( poisoned) ;
842
838
}
843
839
844
840
#[ test]
845
841
fn test_not_trailing_directive ( ) {
846
842
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" ) ;
848
844
assert ! ( !poisoned) ;
849
845
}
850
846
0 commit comments