@@ -95,17 +95,17 @@ fn mk_empty_workspace(short_name: &Path, version: &Version, tag: &str) -> Path {
9595
9696fn mk_workspace ( workspace : & Path , short_name : & Path , version : & Version ) -> Path {
9797 // include version number in directory name
98- let package_dir = workspace. push ( "src" ) . push ( fmt ! ( "%s-%s" ,
99- short_name. to_str( ) , version. to_str( ) ) ) ;
98+ let package_dir = workspace. push_many ( [ ~ "src", fmt ! ( "%s-%s" ,
99+ short_name. to_str( ) , version. to_str( ) ) ] ) ;
100100 assert ! ( os:: mkdir_recursive( & package_dir, U_RWX ) ) ;
101101 package_dir
102102}
103103
104104fn mk_temp_workspace ( short_name : & Path , version : & Version ) -> Path {
105105 let package_dir = mk_empty_workspace ( short_name,
106- version, "temp_workspace" ) . push ( "src" ) . push ( fmt ! ( "%s-%s" ,
106+ version, "temp_workspace" ) . push_many ( [ ~ "src", fmt ! ( "%s-%s" ,
107107 short_name. to_str( ) ,
108- version. to_str( ) ) ) ;
108+ version. to_str( ) ) ] ) ;
109109
110110 debug ! ( "Created %s and does it exist? %?" , package_dir. to_str( ) ,
111111 os:: path_is_dir( & package_dir) ) ;
@@ -207,13 +207,13 @@ fn test_sysroot() -> Path {
207207// Returns the path to rustpkg
208208fn rustpkg_exec ( ) -> Path {
209209 // Ugh
210- let first_try = test_sysroot ( ) . push ( "lib" ) . push ( "rustc" )
211- . push ( host_triple ( ) ) . push ( "bin" ) . push ( "rustpkg" ) ;
210+ let first_try = test_sysroot ( ) . push_many (
211+ [ ~"lib" , ~"rustc" , host_triple ( ) , ~ "bin", ~ "rustpkg"] ) ;
212212 if is_executable ( & first_try) {
213213 first_try
214214 }
215215 else {
216- let second_try = test_sysroot ( ) . push ( "bin" ) . push ( "rustpkg" ) ;
216+ let second_try = test_sysroot ( ) . push_many ( [ ~ "bin", ~ "rustpkg"] ) ;
217217 if is_executable ( & second_try) {
218218 second_try
219219 }
@@ -237,8 +237,11 @@ fn command_line_test_partial(args: &[~str], cwd: &Path) -> Option<ProcessOutput>
237237fn command_line_test_with_env ( args : & [ ~str ] , cwd : & Path , env : Option < ~[ ( ~str , ~str ) ] > )
238238 -> Option < ProcessOutput > {
239239 let cmd = rustpkg_exec ( ) . to_str ( ) ;
240- debug ! ( "cd %s; %s %s" ,
241- cwd. to_str( ) , cmd, args. connect( " " ) ) ;
240+ let env_str = match env {
241+ Some ( ref pairs) => pairs. map ( |& ( ref k, ref v) | { fmt ! ( "%s=%s" , * k, * v) } ) . connect ( "," ) ,
242+ None => ~""
243+ } ;
244+ debug ! ( "%s cd %s; %s %s" , env_str, cwd. to_str( ) , cmd, args. connect( " " ) ) ;
242245 assert ! ( os:: path_is_dir( & * cwd) ) ;
243246 let cwd = ( * cwd) . clone ( ) ;
244247 let mut prog = run:: Process :: new ( cmd, args, run:: ProcessOptions {
@@ -278,7 +281,7 @@ fn create_local_package(pkgid: &PkgId) -> Path {
278281
279282fn create_local_package_in ( pkgid : & PkgId , pkgdir : & Path ) -> Path {
280283
281- let package_dir = pkgdir. push ( "src" ) . push ( pkgid. to_str ( ) ) ;
284+ let package_dir = pkgdir. push_many ( [ ~ "src", pkgid. to_str ( ) ] ) ;
282285
283286 // Create main, lib, test, and bench files
284287 assert ! ( os:: mkdir_recursive( & package_dir, U_RWX ) ) ;
@@ -306,16 +309,12 @@ fn create_local_package_with_dep(pkgid: &PkgId, subord_pkgid: &PkgId) -> Path {
306309 let package_dir = create_local_package ( pkgid) ;
307310 create_local_package_in ( subord_pkgid, & package_dir) ;
308311 // Write a main.rs file into pkgid that references subord_pkgid
309- writeFile ( & package_dir. push ( "src" ) . push ( pkgid. to_str ( ) ) . push ( "main.rs" ) ,
312+ writeFile ( & package_dir. push_many ( [ ~ "src", pkgid. to_str ( ) , ~ "main. rs "] ) ,
310313 fmt ! ( "extern mod %s;\n fn main() {}" ,
311314 subord_pkgid. short_name) ) ;
312315 // Write a lib.rs file into subord_pkgid that has something in it
313- writeFile ( & package_dir. push ( "src" ) . push ( subord_pkgid. to_str ( ) ) . push ( "lib.rs" ) ,
316+ writeFile ( & package_dir. push_many ( [ ~ "src", subord_pkgid. to_str ( ) , ~ "lib. rs "] ) ,
314317 "pub fn f() {}" ) ;
315- debug ! ( "Dry run -- would create packages %s and %s in %s" ,
316- pkgid. to_str( ) ,
317- subord_pkgid. to_str( ) ,
318- package_dir. to_str( ) ) ;
319318 package_dir
320319}
321320
@@ -432,13 +431,13 @@ fn lib_output_file_name(workspace: &Path, parent: &str, short_name: &str) -> Pat
432431 & NoVersion ) . expect ( "lib_output_file_name" )
433432}
434433
435- fn output_file_name ( workspace : & Path , short_name : & str ) -> Path {
434+ fn output_file_name ( workspace : & Path , short_name : ~ str ) -> Path {
436435 target_build_dir ( workspace) . push ( short_name) . push ( fmt ! ( "%s%s" , short_name, os:: EXE_SUFFIX ) )
437436}
438437
439438fn touch_source_file ( workspace : & Path , pkgid : & PkgId ) {
440439 use conditions:: bad_path:: cond;
441- let pkg_src_dir = workspace. push ( "src" ) . push ( pkgid. to_str ( ) ) ;
440+ let pkg_src_dir = workspace. push_many ( [ ~ "src", pkgid. to_str ( ) ] ) ;
442441 let contents = os:: list_dir_path ( & pkg_src_dir) ;
443442 for p in contents. iter ( ) {
444443 if p. filetype ( ) == Some ( ".rs" ) {
@@ -453,7 +452,7 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
453452/// Add a comment at the end
454453fn frob_source_file ( workspace : & Path , pkgid : & PkgId ) {
455454 use conditions:: bad_path:: cond;
456- let pkg_src_dir = workspace. push ( "src" ) . push ( pkgid. to_str ( ) ) ;
455+ let pkg_src_dir = workspace. push_many ( [ ~ "src", pkgid. to_str ( ) ] ) ;
457456 let contents = os:: list_dir_path ( & pkg_src_dir) ;
458457 let mut maybe_p = None ;
459458 for p in contents. iter ( ) {
@@ -544,7 +543,7 @@ fn test_install_git() {
544543 let temp_pkg_id = git_repo_pkg ( ) ;
545544 let repo = init_git_repo ( & temp_pkg_id. path ) ;
546545 debug ! ( "repo = %s" , repo. to_str( ) ) ;
547- let repo_subdir = repo. push ( "mockgithub.com" ) . push ( "catamorphism" ) . push ( "test-pkg" ) ;
546+ let repo_subdir = repo. push_many ( [ ~ "mockgithub. com ", ~ "catamorphism", ~ "test-pkg"] ) ;
548547 debug ! ( "repo_subdir = %s" , repo_subdir. to_str( ) ) ;
549548
550549 writeFile ( & repo_subdir. push ( "main.rs" ) ,
@@ -632,7 +631,7 @@ fn test_package_ids_must_be_relative_path_like() {
632631fn test_package_version() {
633632 let local_path = " mockgithub. com/catamorphism/test_pkg_version";
634633 let repo = init_git_repo(&Path(local_path));
635- let repo_subdir = repo.push( " mockgithub. com").push( " catamorphism").push( " test_pkg_version");
634+ let repo_subdir = repo.push_many([~ " mockgithub. com", ~ " catamorphism", ~ " test_pkg_version"] );
636635 debug!(" Writing files in: %s", repo_subdir.to_str());
637636 writeFile(&repo_subdir.push(" main. rs"),
638637 " fn main( ) { let _x = ( ) ; } ");
@@ -667,7 +666,7 @@ fn test_package_version() {
667666fn test_package_request_version() {
668667 let local_path = " mockgithub. com/catamorphism/test_pkg_version";
669668 let repo = init_git_repo(&Path(local_path));
670- let repo_subdir = repo.push( " mockgithub. com").push( " catamorphism").push( " test_pkg_version");
669+ let repo_subdir = repo.push_many([~ " mockgithub. com", ~ " catamorphism", ~ " test_pkg_version"] );
671670 debug!(" Writing files in: %s", repo_subdir.to_str());
672671 writeFile(&repo_subdir.push(" main. rs"),
673672 " fn main( ) { let _x = ( ) ; } ");
@@ -693,16 +692,16 @@ fn test_package_request_version() {
693692 });
694693 let temp_pkg_id = PkgId::new(" mockgithub. com/catamorphism/test_pkg_version#0.3 ");
695694 assert!(target_executable_in_workspace(&temp_pkg_id, &repo.push(" . rust"))
696- == repo.push(" . rust").push(" bin").push(" test_pkg_version"));
695+ == repo.push_many([~" . rust", ~" bin", ~" test_pkg_version"]));
696+
697+ let dir = &repo.push_many([~" . rust",
698+ ~" src",
699+ ~" mockgithub. com",
700+ ~" catamorphism",
701+ ~" test_pkg_version-0.3 "]);
697702
698- assert!(os::path_exists(&repo.push(" . rust").push(" src")
699- .push(" mockgithub. com").push(" catamorphism")
700- .push(" test_pkg_version-0.3 ")
701- .push(" version-0.3 -file. txt")));
702- assert!(!os::path_exists(&repo.push(" . rust").push(" src")
703- .push(" mockgithub. com").push(" catamorphism")
704- .push(" test_pkg_version-0.3 ")
705- .push(" version-0.4 -file. txt")));
703+ assert!(os::path_exists(&dir.push(" version-0.3 -file. txt")));
704+ assert!(!os::path_exists(&dir.push(" version-0.4 -file. txt")));
706705}
707706
708707#[test]
@@ -745,11 +744,11 @@ fn rustpkg_local_pkg() {
745744fn package_script_with_default_build() {
746745 let dir = create_local_package(&PkgId::new(" fancy-lib"));
747746 debug!(" dir = %s", dir.to_str());
748- let source = test_sysroot().pop().pop().pop().push(" src ").push(" librustpkg ").
749- push(" testsuite").push( " pass").push( " src").push( " fancy-lib").push( " pkg. rs");
747+ let source = test_sysroot().pop().pop().pop().push_many(
748+ [~" src ", ~" librustpkg ", ~" testsuite", ~ " pass", ~ " src", ~ " fancy-lib", ~ " pkg. rs"] );
750749 debug!(" package_script_with_default_build: %s", source.to_str());
751750 if !os::copy_file(&source,
752- &dir.push( " src").push( " fancy-lib-0.1 ").push( " pkg. rs")) {
751+ &dir.push_many([~ " src", ~ " fancy-lib-0.1 ", ~ " pkg. rs"] )) {
753752 fail!(" Couldn ' t copy file");
754753 }
755754 command_line_test([~" install", ~" fancy-lib"], &dir);
@@ -761,7 +760,7 @@ fn package_script_with_default_build() {
761760fn rustpkg_build_no_arg() {
762761 let tmp = mkdtemp(&os::tmpdir(), " rustpkg_build_no_arg").expect(" rustpkg_build_no_arg failed")
763762 .push(" . rust");
764- let package_dir = tmp.push( " src").push( " foo");
763+ let package_dir = tmp.push_many([~ " src", ~ " foo"] );
765764 assert!(os::mkdir_recursive(&package_dir, U_RWX));
766765
767766 writeFile(&package_dir.push(" main. rs"),
@@ -776,7 +775,7 @@ fn rustpkg_install_no_arg() {
776775 let tmp = mkdtemp(&os::tmpdir(),
777776 " rustpkg_install_no_arg").expect(" rustpkg_install_no_arg failed")
778777 .push(" . rust");
779- let package_dir = tmp.push( " src").push( " foo");
778+ let package_dir = tmp.push_many([~ " src", ~ " foo"] );
780779 assert!(os::mkdir_recursive(&package_dir, U_RWX));
781780 writeFile(&package_dir.push(" lib. rs"),
782781 " fn main( ) { let _x = ( ) ; } ");
@@ -789,7 +788,7 @@ fn rustpkg_install_no_arg() {
789788fn rustpkg_clean_no_arg() {
790789 let tmp = mkdtemp(&os::tmpdir(), " rustpkg_clean_no_arg").expect(" rustpkg_clean_no_arg failed")
791790 .push(" . rust");
792- let package_dir = tmp.push( " src").push( " foo");
791+ let package_dir = tmp.push_many([~ " src", ~ " foo"] );
793792 assert!(os::mkdir_recursive(&package_dir, U_RWX));
794793
795794 writeFile(&package_dir.push(" main. rs"),
@@ -822,7 +821,7 @@ fn rust_path_test() {
822821#[ignore] // FIXME(#9184) tests can't change the cwd (other tests are sad then)
823822fn rust_path_contents() {
824823 let dir = mkdtemp(&os::tmpdir(), " rust_path").expect(" rust_path_contents failed");
825- let abc = &dir.push( " A ").push( " B ").push( " C ");
824+ let abc = &dir.push_many([~ " A ", ~ " B ", ~ " C "] );
826825 assert!(os::mkdir_recursive(&abc.push(" . rust"), U_RWX));
827826 assert!(os::mkdir_recursive(&abc.pop().push(" . rust"), U_RWX));
828827 assert!(os::mkdir_recursive(&abc.pop().pop().push(" . rust"), U_RWX));
@@ -863,7 +862,6 @@ fn test_list() {
863862// list doesn't output very much right now...
864863 command_line_test([~" install", ~" foo"], &dir);
865864 let env_arg = ~[(~" RUST_PATH ", dir.to_str())];
866- debug!(" RUST_PATH = %s", dir.to_str());
867865 let list_output = command_line_test_output_with_env([~" list"], env_arg.clone());
868866 assert!(list_output.iter().any(|x| x.starts_with(" foo")));
869867
@@ -949,14 +947,14 @@ fn no_rebuilding_dep() {
949947 let bar_date_1 = datestamp(&lib_output_file_name(&workspace,
950948 " . rust",
951949 " bar"));
952- let foo_date_1 = datestamp(&output_file_name(&workspace, " foo"));
950+ let foo_date_1 = datestamp(&output_file_name(&workspace, ~ " foo"));
953951
954952 frob_source_file(&workspace, &p_id);
955953 command_line_test([~" build", ~" foo"], &workspace);
956954 let bar_date_2 = datestamp(&lib_output_file_name(&workspace,
957955 " . rust",
958956 " bar"));
959- let foo_date_2 = datestamp(&output_file_name(&workspace, " foo"));
957+ let foo_date_2 = datestamp(&output_file_name(&workspace, ~ " foo"));
960958 assert_eq!(bar_date_1, bar_date_2);
961959 assert!(foo_date_1 < foo_date_2);
962960 assert!(foo_date_1 > bar_date_1);
@@ -1043,7 +1041,7 @@ fn test_uninstall() {
10431041fn test_non_numeric_tag() {
10441042 let temp_pkg_id = git_repo_pkg();
10451043 let repo = init_git_repo(&temp_pkg_id.path);
1046- let repo_subdir = repo.push( " mockgithub. com").push( " catamorphism").push( " test-pkg");
1044+ let repo_subdir = repo.push_many([~ " mockgithub. com", ~ " catamorphism", ~ " test-pkg"] );
10471045 writeFile(&repo_subdir.push(" foo"), " foo");
10481046 writeFile(&repo_subdir.push(" lib. rs"),
10491047 " pub fn f( ) { let _x = ( ) ; } ");
@@ -1085,12 +1083,6 @@ fn test_extern_mod() {
10851083 let env = Some ( [ ( ~"RUST_PATH ", lib_depend_dir. to_str ( ) ) ] + os:: env ( ) ) ;
10861084 let rustpkg_exec = rustpkg_exec ( ) ;
10871085 let rustc = rustpkg_exec. with_filename ( "rustc" ) ;
1088- debug ! ( "RUST_PATH=%s %s %s \n --sysroot %s -o %s" ,
1089- lib_depend_dir. to_str( ) ,
1090- rustc. to_str( ) ,
1091- main_file. to_str( ) ,
1092- test_sysroot( ) . to_str( ) ,
1093- exec_file. to_str( ) ) ;
10941086
10951087 let mut prog = run:: Process :: new ( rustc. to_str ( ) , [ main_file. to_str ( ) ,
10961088 ~"--sysroot", test_sysroot ( ) . to_str ( ) ,
@@ -1164,7 +1156,7 @@ fn test_extern_mod_simpler() {
11641156fn test_import_rustpkg ( ) {
11651157 let p_id = PkgId :: new ( "foo" ) ;
11661158 let workspace = create_local_package ( & p_id) ;
1167- writeFile ( & workspace. push ( "src" ) . push ( "foo-0.1" ) . push ( "pkg.rs" ) ,
1159+ writeFile ( & workspace. push_many ( [ ~ "src", ~ "foo-0.1 ", ~ "pkg. rs "] ) ,
11681160 "extern mod rustpkg; fn main() {}" ) ;
11691161 command_line_test ( [ ~"build", ~"foo"] , & workspace) ;
11701162 debug ! ( "workspace = %s" , workspace. to_str( ) ) ;
@@ -1176,7 +1168,7 @@ fn test_import_rustpkg() {
11761168fn test_macro_pkg_script ( ) {
11771169 let p_id = PkgId :: new ( "foo" ) ;
11781170 let workspace = create_local_package ( & p_id) ;
1179- writeFile ( & workspace. push ( "src" ) . push ( "foo-0.1" ) . push ( "pkg.rs" ) ,
1171+ writeFile ( & workspace. push_many ( [ ~ "src", ~ "foo-0.1 ", ~ "pkg. rs "] ) ,
11801172 "extern mod rustpkg; fn main() { debug!(\" Hi\" ); }" ) ;
11811173 command_line_test ( [ ~"build", ~"foo"] , & workspace) ;
11821174 debug ! ( "workspace = %s" , workspace. to_str( ) ) ;
@@ -1215,8 +1207,6 @@ fn rust_path_hack_test(hack_flag: bool) {
12151207 let dest_workspace = mk_empty_workspace ( & Path ( "bar" ) , & NoVersion , "dest_workspace" ) ;
12161208 let rust_path = Some ( ~[ ( ~"RUST_PATH ",
12171209 fmt ! ( "%s:%s" , dest_workspace. to_str( ) , workspace. push_many( [ "src" , "foo-0.1" ] ) . to_str( ) ) ) ] ) ;
1218- debug ! ( "declare -x RUST_PATH=%s:%s" ,
1219- dest_workspace. to_str( ) , workspace. push_many( [ "src" , "foo-0.1" ] ) . to_str( ) ) ;
12201210 command_line_test_with_env ( ~[ ~"install"] + if hack_flag { ~[ ~"--rust-path-hack"] } else { ~[ ] } +
12211211 ~[ ~"foo"] , & dest_workspace, rust_path) ;
12221212 assert_lib_exists ( & dest_workspace, & Path ( "foo" ) , NoVersion ) ;
@@ -1256,7 +1246,6 @@ fn rust_path_hack_cwd() {
12561246
12571247 let dest_workspace = mk_empty_workspace ( & Path ( "bar" ) , & NoVersion , "dest_workspace" ) ;
12581248 let rust_path = Some ( ~[ ( ~"RUST_PATH ", dest_workspace. to_str ( ) ) ] ) ;
1259- debug ! ( "declare -x RUST_PATH=%s" , dest_workspace. to_str( ) ) ;
12601249 command_line_test_with_env ( [ ~"install", ~"--rust-path-hack", ~"foo"] , & cwd, rust_path) ;
12611250 debug ! ( "Checking that foo exists in %s" , dest_workspace. to_str( ) ) ;
12621251 assert_lib_exists ( & dest_workspace, & Path ( "foo" ) , NoVersion ) ;
@@ -1276,7 +1265,6 @@ fn rust_path_hack_multi_path() {
12761265
12771266 let dest_workspace = mk_empty_workspace ( & Path ( "bar" ) , & NoVersion , "dest_workspace" ) ;
12781267 let rust_path = Some ( ~[ ( ~"RUST_PATH ", dest_workspace. to_str ( ) ) ] ) ;
1279- debug ! ( "declare -x RUST_PATH=%s" , dest_workspace. to_str( ) ) ;
12801268 command_line_test_with_env ( [ ~"install", ~"--rust-path-hack", name. clone ( ) ] , & subdir, rust_path) ;
12811269 debug ! ( "Checking that %s exists in %s" , name, dest_workspace. to_str( ) ) ;
12821270 assert_lib_exists ( & dest_workspace, & Path ( "quux" ) , NoVersion ) ;
@@ -1295,7 +1283,6 @@ fn rust_path_hack_install_no_arg() {
12951283
12961284 let dest_workspace = mk_empty_workspace ( & Path ( "bar" ) , & NoVersion , "dest_workspace" ) ;
12971285 let rust_path = Some ( ~[ ( ~"RUST_PATH ", dest_workspace. to_str ( ) ) ] ) ;
1298- debug ! ( "declare -x RUST_PATH=%s" , dest_workspace. to_str( ) ) ;
12991286 command_line_test_with_env ( [ ~"install", ~"--rust-path-hack"] , & source_dir, rust_path) ;
13001287 debug ! ( "Checking that foo exists in %s" , dest_workspace. to_str( ) ) ;
13011288 assert_lib_exists ( & dest_workspace, & Path ( "foo" ) , NoVersion ) ;
@@ -1314,7 +1301,6 @@ fn rust_path_hack_build_no_arg() {
13141301
13151302 let dest_workspace = mk_empty_workspace ( & Path ( "bar" ) , & NoVersion , "dest_workspace" ) ;
13161303 let rust_path = Some ( ~[ ( ~"RUST_PATH ", dest_workspace. to_str ( ) ) ] ) ;
1317- debug ! ( "declare -x RUST_PATH=%s" , dest_workspace. to_str( ) ) ;
13181304 command_line_test_with_env ( [ ~"build", ~"--rust-path-hack"] , & source_dir, rust_path) ;
13191305 debug ! ( "Checking that foo exists in %s" , dest_workspace. to_str( ) ) ;
13201306 assert_built_library_exists ( & dest_workspace, "foo" ) ;
@@ -1336,8 +1322,6 @@ fn rust_path_install_target() {
13361322 let rust_path = Some ( ~[ ( ~"RUST_PATH ", fmt ! ( "%s:%s" , dir_to_install_to. to_str( ) ,
13371323 dir. to_str( ) ) ) ] ) ;
13381324 let cwd = os:: getcwd ( ) ;
1339-
1340- debug ! ( "RUST_PATH=%s:%s" , dir_to_install_to. to_str( ) , dir. to_str( ) ) ;
13411325 command_line_test_with_env ( [ ~"install", ~"foo"] ,
13421326 & cwd,
13431327 rust_path) ;
@@ -1623,7 +1607,6 @@ fn pkgid_pointing_to_subdir() {
16231607 use foo:: f; use bar:: g; \n
16241608 fn main( ) { f( ) ; g( ) ; } ");
16251609
1626- debug!(" RUST_PATH =%s", workspace.to_str());
16271610 command_line_test([~" install", ~" testpkg"], &workspace);
16281611 assert_executable_exists(&workspace, " testpkg");
16291612}
0 commit comments