1010
1111#[ allow( missing_doc) ] ;
1212
13- use digest:: Digest ;
1413use json;
1514use json:: ToJson ;
16- use sha1:: Sha1 ;
1715use serialize:: { Encoder , Encodable , Decoder , Decodable } ;
1816use arc:: { Arc , RWArc } ;
1917use treemap:: TreeMap ;
@@ -23,7 +21,6 @@ use std::{os, str, task};
2321use std:: rt:: io;
2422use std:: rt:: io:: Writer ;
2523use std:: rt:: io:: Decorator ;
26- use std:: rt:: io:: extensions:: ReaderUtil ;
2724use std:: rt:: io:: mem:: MemWriter ;
2825use std:: rt:: io:: file:: FileInfo ;
2926
@@ -276,19 +273,6 @@ fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
276273 Decodable :: decode ( & mut decoder)
277274}
278275
279- fn digest < T : Encodable < json:: Encoder > > ( t : & T ) -> ~str {
280- let mut sha = ~Sha1 :: new ( ) ;
281- ( * sha) . input_str ( json_encode ( t) ) ;
282- ( * sha) . result_str ( )
283- }
284-
285- fn digest_file ( path : & Path ) -> ~str {
286- let mut sha = ~Sha1 :: new ( ) ;
287- let s = path. open_reader ( io:: Open ) . read_to_end ( ) ;
288- ( * sha) . input ( s) ;
289- ( * sha) . result_str ( )
290- }
291-
292276impl Context {
293277
294278 pub fn new ( db : RWArc < Database > ,
@@ -497,6 +481,8 @@ impl<'self, T:Send +
497481#[ test]
498482fn test ( ) {
499483 use std:: { os, run} ;
484+ use std:: rt:: io:: ReaderUtil ;
485+ use std:: str:: from_utf8_owned;
500486
501487 // Create a path to a new file 'filename' in the directory in which
502488 // this test is running.
@@ -524,8 +510,10 @@ fn test() {
524510 let subcx = cx. clone( ) ;
525511 let pth = pth. clone( ) ;
526512
513+ let file_content = from_utf8_owned( pth. open_reader( io:: Open ) . read_to_end( ) ) ;
514+
527515 // FIXME (#9639): This needs to handle non-utf8 paths
528- prep. declare_input( "file" , pth. as_str( ) . unwrap( ) , digest_file ( & pth ) ) ;
516+ prep. declare_input( "file" , pth. as_str( ) . unwrap( ) , file_content ) ;
529517 do prep. exec |_exe| {
530518 let out = make_path( ~"foo. o") ;
531519 // FIXME (#9639): This needs to handle non-utf8 paths
0 commit comments