12
12
13
13
use context:: Ctx ;
14
14
use std:: hashmap:: HashMap ;
15
- use std:: { io, libc, os, result, run, str} ;
15
+ use std:: { io, libc, os, result, run, str, vec } ;
16
16
use extra:: tempfile:: mkdtemp;
17
17
use std:: run:: ProcessOutput ;
18
- use installed_packages:: list_installed_packages;
19
18
use package_path:: * ;
20
19
use package_id:: { PkgId } ;
21
20
use package_source:: * ;
@@ -129,27 +128,20 @@ fn test_sysroot() -> Path {
129
128
self_path. pop ( )
130
129
}
131
130
132
- fn command_line_test ( args : & [ ~str ] , cwd : & Path ) -> ProcessOutput {
133
- command_line_test_with_env ( args, cwd, None )
134
- }
135
-
136
131
/// Runs `rustpkg` (based on the directory that this executable was
137
132
/// invoked from) with the given arguments, in the given working directory.
138
133
/// Returns the process's output.
139
- fn command_line_test_with_env ( args : & [ ~str ] , cwd : & Path , env : Option < ~[ ( ~str , ~str ) ] > )
140
- -> ProcessOutput {
134
+ fn command_line_test ( args : & [ ~str ] , cwd : & Path ) -> ProcessOutput {
141
135
let cmd = test_sysroot ( ) . push ( "bin" ) . push ( "rustpkg" ) . to_str ( ) ;
142
136
let cwd = normalize ( RemotePath ( copy * cwd) ) ;
143
137
debug ! ( "About to run command: %? %? in %s" , cmd, args, cwd. to_str( ) ) ;
144
138
assert ! ( os:: path_is_dir( & * cwd) ) ;
145
- let cwd = cwd. clone ( ) ;
146
- let mut prog = run:: Process :: new ( cmd, args, run:: ProcessOptions {
147
- env : env. map ( |v| v. slice ( 0 , v. len ( ) ) ) ,
148
- dir : Some ( & cwd) ,
149
- in_fd : None ,
150
- out_fd : None ,
151
- err_fd : None
152
- } ) ;
139
+ let mut prog = run:: Process :: new ( cmd, args, run:: ProcessOptions { env : None ,
140
+ dir : Some ( & * cwd) ,
141
+ in_fd : None ,
142
+ out_fd : None ,
143
+ err_fd : None
144
+ } ) ;
153
145
let output = prog. finish_with_output ( ) ;
154
146
debug ! ( "Output from command %s with args %? was %s {%s}[%?]" ,
155
147
cmd, args, str :: from_bytes( output. output) ,
@@ -260,16 +252,6 @@ fn command_line_test_output(args: &[~str]) -> ~[~str] {
260
252
result
261
253
}
262
254
263
- fn command_line_test_output_with_env ( args : & [ ~str ] , env : ~[ ( ~str , ~str ) ] ) -> ~[ ~str ] {
264
- let mut result = ~[ ] ;
265
- let p_output = command_line_test_with_env ( args, & os:: getcwd ( ) , Some ( env) ) ;
266
- let test_output = str:: from_bytes ( p_output. output ) ;
267
- for test_output. split_iter( '\n' ) . advance |s| {
268
- result. push ( s. to_owned ( ) ) ;
269
- }
270
- result
271
- }
272
-
273
255
// assumes short_name and local_path are one and the same -- I should fix
274
256
fn lib_output_file_name ( workspace : & Path , parent : & str , short_name : & str ) -> Path {
275
257
debug ! ( "lib_output_file_name: given %s and parent %s and short name %s" ,
@@ -494,9 +476,8 @@ fn test_package_version() {
494
476
push(" test_pkg_version")));
495
477
}
496
478
497
- // FIXME #7006: Fails on linux for some reason
498
- #[test]
499
- #[ignore]
479
+ // FIXME #7006: Fails on linux/mac for some reason
480
+ #[test] #[ignore]
500
481
fn test_package_request_version() {
501
482
let temp_pkg_id = PkgId::new(" github. com/catamorphism/test_pkg_version#0.3 ");
502
483
let temp = mk_empty_workspace(&LocalPath(Path(" test_pkg_version")), &ExactRevision(~" 0.3 "));
@@ -632,33 +613,7 @@ fn rust_path_parse() {
632
613
}
633
614
634
615
#[test]
635
- fn test_list() {
636
- let foo = PkgId::new(" foo");
637
- let dir = mkdtemp(&os::tmpdir(), " test_list").expect(" test_list failed");
638
- create_local_package_in(&foo, &dir);
639
- let bar = PkgId::new(" bar");
640
- create_local_package_in(&bar, &dir);
641
- let quux = PkgId::new(" quux");
642
- create_local_package_in(&quux, &dir);
643
-
644
- command_line_test([~" install", ~" foo"], &dir);
645
- let env_arg = ~[(~" RUST_PATH ", dir.to_str())];
646
- let list_output = command_line_test_output_with_env([~" list"], env_arg.clone());
647
- assert!(list_output.iter().any(|x| x.starts_with(" foo-")));
648
-
649
- command_line_test([~" install", ~" bar"], &dir);
650
- let list_output = command_line_test_output_with_env([~" list"], env_arg.clone());
651
- assert!(list_output.iter().any(|x| x.starts_with(" foo-")));
652
- assert!(list_output.iter().any(|x| x.starts_with(" bar-")));
653
-
654
- command_line_test([~" install", ~" quux"], &dir);
655
- let list_output = command_line_test_output_with_env([~" list"], env_arg);
656
- assert!(list_output.iter().any(|x| x.starts_with(" foo-")));
657
- assert!(list_output.iter().any(|x| x.starts_with(" bar-")));
658
- assert!(list_output.iter().any(|x| x.starts_with(" quux-")));
659
- }
660
-
661
- #[test]
616
+ #[ignore(reason = " Package database not yet implemented")]
662
617
fn install_remove() {
663
618
let foo = PkgId::new(" foo");
664
619
let bar = PkgId::new(" bar");
@@ -667,43 +622,18 @@ fn install_remove() {
667
622
create_local_package_in(&foo, &dir);
668
623
create_local_package_in(&bar, &dir);
669
624
create_local_package_in(&quux, &dir);
670
- let rust_path_to_use = ~[(~" RUST_PATH ", dir.to_str())];
671
625
command_line_test([~" install", ~" foo"], &dir);
672
626
command_line_test([~" install", ~" bar"], &dir);
673
627
command_line_test([~" install", ~" quux"], &dir);
674
- let list_output = command_line_test_output_with_env([~" list"], rust_path_to_use.clone());
675
- assert!(list_output.iter().any(|x| x.starts_with(" foo")));
676
- assert!(list_output.iter().any(|x| x.starts_with(" bar")));
677
- assert!(list_output.iter().any(|x| x.starts_with(" quux")));
678
- command_line_test([~" uninstall", ~" foo"], &dir);
679
- let list_output = command_line_test_output_with_env([~" list"], rust_path_to_use.clone());
680
- assert!(!list_output.iter().any(|x| x.starts_with(" foo")));
681
- assert!(list_output.iter().any(|x| x.starts_with(" bar")));
682
- assert!(list_output.iter().any(|x| x.starts_with(" quux")));
683
- }
684
-
685
- #[test]
686
- fn install_check_duplicates() {
687
- // should check that we don't install two packages with the same full name *and* version
688
- // (" Is already installed -- doing nothing")
689
- // check invariant that there are no dups in the pkg database
690
- let dir = mkdtemp(&os::tmpdir(), " install_remove").expect(" install_remove");
691
- let foo = PkgId::new(" foo");
692
- create_local_package_in(&foo, &dir);
693
-
694
- command_line_test([~" install", ~" foo"], &dir);
695
- command_line_test([~" install", ~" foo"], &dir);
696
- let mut contents = ~[];
697
- let check_dups = |p: &PkgId| {
698
- if contents.contains(p) {
699
- fail!(" package database contains duplicate ID ");
700
- }
701
- else {
702
- contents.push(copy *p);
703
- }
704
- false
705
- };
706
- list_installed_packages(check_dups);
628
+ let list_output = command_line_test_output([~" list"]);
629
+ assert!(list_output.iter().any(|x| x == &~" foo"));
630
+ assert!(list_output.iter().any(|x| x == &~" bar"));
631
+ assert!(list_output.iter().any(|x| x == &~" quux"));
632
+ command_line_test([~" remove", ~" foo"], &dir);
633
+ let list_output = command_line_test_output([~" list"]);
634
+ assert!(!list_output.iter().any(|x| x == &~" foo"));
635
+ assert!(list_output.iter().any(|x| x == &~" bar"));
636
+ assert!(list_output.iter().any(|x| x == &~" quux"));
707
637
}
708
638
709
639
#[test]
0 commit comments