@@ -34,6 +34,11 @@ pub struct EarlyProps {
34
34
35
35
impl EarlyProps {
36
36
pub fn from_file ( config : & Config , testfile : & Path ) -> Self {
37
+ let file = File :: open ( testfile) . unwrap ( ) ;
38
+ Self :: from_reader ( config, testfile, file)
39
+ }
40
+
41
+ pub fn from_reader < R : Read > ( config : & Config , testfile : & Path , rdr : R ) -> Self {
37
42
let mut props = EarlyProps {
38
43
ignore : false ,
39
44
should_fail : false ,
@@ -45,7 +50,7 @@ impl EarlyProps {
45
50
let rustc_has_profiler_support = env:: var_os ( "RUSTC_PROFILER_SUPPORT" ) . is_some ( ) ;
46
51
let rustc_has_sanitizer_support = env:: var_os ( "RUSTC_SANITIZER_SUPPORT" ) . is_some ( ) ;
47
52
48
- iter_header ( testfile, None , & mut |ln| {
53
+ iter_header ( testfile, None , rdr , & mut |ln| {
49
54
// we should check if any only-<platform> exists and if it exists
50
55
// and does not matches the current platform, skip the test
51
56
if !props. ignore {
@@ -392,7 +397,8 @@ impl TestProps {
392
397
/// `//[foo]`), then the property is ignored unless `cfg` is
393
398
/// `Some("foo")`.
394
399
fn load_from ( & mut self , testfile : & Path , cfg : Option < & str > , config : & Config ) {
395
- iter_header ( testfile, cfg, & mut |ln| {
400
+ let file = File :: open ( testfile) . unwrap ( ) ;
401
+ iter_header ( testfile, cfg, file, & mut |ln| {
396
402
if let Some ( ep) = config. parse_error_pattern ( ln) {
397
403
self . error_patterns . push ( ep) ;
398
404
}
@@ -617,7 +623,7 @@ impl TestProps {
617
623
}
618
624
}
619
625
620
- fn iter_header ( testfile : & Path , cfg : Option < & str > , it : & mut dyn FnMut ( & str ) ) {
626
+ fn iter_header < R : Read > ( testfile : & Path , cfg : Option < & str > , rdr : R , it : & mut dyn FnMut ( & str ) ) {
621
627
if testfile. is_dir ( ) {
622
628
return ;
623
629
}
@@ -628,7 +634,7 @@ fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) {
628
634
// It took me like 2 days to debug why compile-flags weren’t taken into account for my test :)
629
635
let comment_with_brace = comment. to_string ( ) + "[" ;
630
636
631
- let mut rdr = BufReader :: new ( File :: open ( testfile ) . unwrap ( ) ) ;
637
+ let mut rdr = BufReader :: new ( rdr ) ;
632
638
let mut ln = String :: new ( ) ;
633
639
634
640
loop {
0 commit comments