@@ -69,6 +69,7 @@ struct CacheKey {
6969 channel : ReleaseChannel ,
7070 cmd : String ,
7171 args : Vec < String > ,
72+ env : Vec < ( String , String ) > ,
7273 input : String ,
7374}
7475
@@ -84,13 +85,15 @@ impl Cache {
8485 channel : ReleaseChannel ,
8586 cmd : & str ,
8687 args : Vec < String > ,
88+ env : Vec < ( String , String ) > ,
8789 input : String )
8890 -> io:: Result < ( ExitStatus , Vec < u8 > ) > {
8991 // Build key to look up
9092 let key = CacheKey {
9193 channel : channel,
9294 cmd : cmd. to_string ( ) ,
9395 args : args,
96+ env : env,
9497 input : input,
9598 } ;
9699 let mut cache = self . cache . lock ( ) . unwrap ( ) ;
@@ -106,7 +109,7 @@ impl Cache {
106109 } ;
107110 let container = format ! ( "rust-playpen-{}" , chan) ;
108111
109- let container = try!( Container :: new ( cmd, & key. args , & container) ) ;
112+ let container = try!( Container :: new ( cmd, & key. args , & key . env , & container) ) ;
110113
111114 let tuple = try!( container. run ( key. input . as_bytes ( ) , Duration :: new ( 5 , 0 ) ) ) ;
112115 let ( status, mut output, timeout) = tuple;
@@ -145,6 +148,36 @@ impl FromStr for AsmFlavor {
145148 }
146149}
147150
151+ #[ derive( Debug , PartialEq , Eq ) ]
152+ pub enum Backtrace {
153+ Never ,
154+ Always ,
155+ Auto ,
156+ }
157+
158+ impl Backtrace {
159+ pub fn is_requested ( & self , debug : bool ) -> bool {
160+ match * self {
161+ Backtrace :: Never => false ,
162+ Backtrace :: Always => true ,
163+ Backtrace :: Auto => debug,
164+ }
165+ }
166+ }
167+
168+ impl FromStr for Backtrace {
169+ type Err = StringError ;
170+
171+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
172+ match s {
173+ "0" => Ok ( Backtrace :: Never ) ,
174+ "1" => Ok ( Backtrace :: Always ) ,
175+ "2" => Ok ( Backtrace :: Auto ) ,
176+ _ => Err ( StringError ( format ! ( "unknown backtrace setting {}" , s) ) ) ,
177+ }
178+ }
179+ }
180+
148181#[ derive( Debug , PartialEq , Eq ) ]
149182pub enum OptLevel {
150183 O0 ,
@@ -249,6 +282,7 @@ mod tests {
249282 let ( status, out) = cache. exec ( ReleaseChannel :: Stable ,
250283 "/usr/local/bin/evaluate.sh" ,
251284 Vec :: new ( ) ,
285+ Vec :: new ( ) ,
252286 input. to_string ( ) ) . unwrap ( ) ;
253287 assert ! ( status. success( ) ) ;
254288 assert_eq ! ( out, & [ 0xff , b'H' , b'e' , b'l' , b'l' , b'o' , b'\n' ] ) ;
@@ -267,6 +301,7 @@ mod tests {
267301 let ( status, out) = cache. exec ( ReleaseChannel :: Stable ,
268302 "/usr/local/bin/evaluate.sh" ,
269303 Vec :: new ( ) ,
304+ Vec :: new ( ) ,
270305 input. to_string ( ) ) . unwrap ( ) ;
271306 assert ! ( !status. success( ) ) ;
272307 assert ! ( String :: from_utf8_lossy( & out) . contains( "timeout triggered" ) ) ;
@@ -281,6 +316,7 @@ mod tests {
281316 let ( status, out) = cache. exec ( ReleaseChannel :: Stable ,
282317 "/usr/local/bin/compile.sh" ,
283318 vec ! [ String :: from( "--emit=llvm-ir" ) ] ,
319+ vec ! [ ] ,
284320 input. to_string ( ) ) . unwrap ( ) ;
285321
286322 assert ! ( status. success( ) ) ;
@@ -300,6 +336,7 @@ mod tests {
300336 let ( status, out) = cache. exec ( ReleaseChannel :: Stable ,
301337 "rustfmt" ,
302338 Vec :: new ( ) ,
339+ Vec :: new ( ) ,
303340 input. to_string ( ) ) . unwrap ( ) ;
304341 assert ! ( status. success( ) ) ;
305342 assert ! ( String :: from_utf8( out) . unwrap( ) . contains( r#""Hello""# ) )
0 commit comments