@@ -357,23 +357,37 @@ fn for_each_package(c: cargo, b: block(source, package)) {
357
357
358
358
// FIXME: deduplicate code with install_one_crate
359
359
fn test_one_crate ( c : cargo , _path : str , cf : str , _p : pkg ) {
360
- let name = fs:: basename ( cf) ;
361
- let ri = str:: index ( name, '.' as u8 ) ;
362
- if ri != -1 {
363
- name = str:: slice ( name, 0 u, ri as uint ) ;
364
- }
365
- #debug ( "Installing: %s" , name) ;
366
- let old = fs:: list_dir ( "." ) ;
367
- let p = run:: program_output ( "rustc" , [ "--test" , name + ".rc" ] ) ;
360
+ let buildpath = fs:: connect ( _path, "/test" ) ;
361
+ need_dir ( buildpath) ;
362
+ #debug ( "Testing: %s -> %s" , cf, buildpath) ;
363
+ let p = run:: program_output ( "rustc" , [ "--out-dir" , buildpath, "--test" ,
364
+ cf] ) ;
365
+ if p. status != 0 {
366
+ error ( #fmt[ "rustc failed: %d\n %s\n %s" , p. status , p. err , p. out ] ) ;
367
+ ret;
368
+ }
369
+ let new = fs:: list_dir ( buildpath) ;
370
+ let exec_suffix = os:: exec_suffix ( ) ;
371
+ for ct: str in new {
372
+ if ( exec_suffix != "" && str:: ends_with ( ct, exec_suffix) ) ||
373
+ ( exec_suffix == "" && !str:: starts_with ( ct, "./lib" ) ) {
374
+ run:: run_program ( ct, [ ] ) ;
375
+ }
376
+ }
377
+ }
378
+
379
+ fn install_one_crate ( c : cargo , _path : str , cf : str , _p : pkg ) {
380
+ let buildpath = fs:: connect ( _path, "/build" ) ;
381
+ need_dir ( buildpath) ;
382
+ #debug ( "Installing: %s -> %s" , cf, buildpath) ;
383
+ let p = run:: program_output ( "rustc" , [ "--out-dir" , buildpath, cf] ) ;
368
384
if p. status != 0 {
369
385
error ( #fmt[ "rustc failed: %d\n %s\n %s" , p. status , p. err , p. out ] ) ;
370
386
ret;
371
387
}
372
- let new = fs:: list_dir ( "." ) ;
373
- let created =
374
- vec:: filter :: < str > ( new, { |n| !vec:: member :: < str > ( n, old) } ) ;
388
+ let new = fs:: list_dir ( buildpath) ;
375
389
let exec_suffix = os:: exec_suffix ( ) ;
376
- for ct: str in created {
390
+ for ct: str in new {
377
391
if ( exec_suffix != "" && str:: ends_with ( ct, exec_suffix) ) ||
378
392
( exec_suffix == "" && !str:: starts_with ( ct, "./lib" ) ) {
379
393
// FIXME: need libstd fs::copy or something
0 commit comments