@@ -496,16 +496,23 @@ fn test() {
496
496
use std:: io:: WriterUtil ;
497
497
use std :: { os, run} ;
498
498
499
- let pth = Path ( "foo.c" ) ;
499
+ // Create a path to a new file 'filename' in the directory in which
500
+ // this test is running.
501
+ fn make_path( filename: ~str ) -> Path {
502
+ let pth = os: : self_exe_path( ) . expect( "workcache::test failed" ) . pop( ) . push( filename) ;
503
+ if os:: path_exists( & pth) {
504
+ os:: remove_file( & pth) ;
505
+ }
506
+ return pth;
507
+ }
508
+
509
+ let pth = make_path( ~"foo. c");
500
510
{
501
511
let r = io::file_writer(&pth, [io::Create]);
502
512
r.unwrap().write_str(" int main ( ) { return 0 ; } ") ;
503
513
}
504
514
505
- let db_path = os:: self_exe_path( ) . expect( "workcache::test failed" ) . pop( ) . push( "db.json" ) ;
506
- if os:: path_exists( & db_path) {
507
- os:: remove_file( & db_path) ;
508
- }
515
+ let db_path = make_path( ~"db. json") ;
509
516
510
517
let cx = Context :: new( RWArc :: new( Database :: new( db_path) ) ,
511
518
RWArc :: new( Logger :: new( ) ) ,
@@ -514,17 +521,19 @@ fn test() {
514
521
let s = do cx. with_prep( "test1" ) |prep| {
515
522
516
523
let subcx = cx. clone( ) ;
524
+ let pth = pth. clone( ) ;
517
525
518
526
prep. declare_input( "file" , pth. to_str( ) , digest_file( & pth) ) ;
519
527
do prep. exec |_exe| {
520
- let out = Path ( "foo.o" ) ;
521
- run:: process_status( "gcc" , [ ~"foo . c" , ~" -o", out. to_str( ) ] ) ;
528
+ let out = make_path ( ~ "foo. o") ;
529
+ run:: process_status( "gcc" , [ pth . to_str ( ) , ~"-o", out. to_str( ) ] ) ;
522
530
523
531
let _proof_of_concept = subcx. prep( "subfn" ) ;
524
532
// Could run sub-rules inside here.
525
533
526
534
out. to_str( )
527
535
}
528
536
} ;
537
+
529
538
io:: println( s) ;
530
539
}
0 commit comments