@@ -328,13 +328,13 @@ fn create_local_package_with_custom_build_hook(pkgid: &PkgId,
328328
329329}
330330
331- fn assert_lib_exists ( repo : & Path , short_name : & str , v : Version ) {
332- assert ! ( lib_exists( repo, short_name , v) ) ;
331+ fn assert_lib_exists ( repo : & Path , pkg_path : & Path , v : Version ) {
332+ assert ! ( lib_exists( repo, pkg_path , v) ) ;
333333}
334334
335- fn lib_exists ( repo : & Path , short_name : & str , _v : Version ) -> bool { // ??? version?
336- debug ! ( "assert_lib_exists: repo = %s, short_name = %s" , repo. to_str( ) , short_name ) ;
337- let lib = installed_library_in_workspace ( short_name , repo) ;
335+ fn lib_exists ( repo : & Path , pkg_path : & Path , _v : Version ) -> bool { // ??? version?
336+ debug ! ( "assert_lib_exists: repo = %s, pkg_path = %s" , repo. to_str( ) , pkg_path . to_str ( ) ) ;
337+ let lib = installed_library_in_workspace ( pkg_path , repo) ;
338338 debug ! ( "assert_lib_exists: checking whether %? exists" , lib) ;
339339 lib. is_some ( ) && {
340340 let libname = lib. get_ref ( ) ;
@@ -507,7 +507,7 @@ fn test_install_valid() {
507507 assert ! ( os:: path_exists( & exec) ) ;
508508 assert ! ( is_rwx( & exec) ) ;
509509
510- let lib = installed_library_in_workspace ( temp_pkg_id. short_name , & temp_workspace) ;
510+ let lib = installed_library_in_workspace ( & temp_pkg_id. path , & temp_workspace) ;
511511 debug ! ( "lib = %?" , lib) ;
512512 assert ! ( lib. map_default( false , |l| os:: path_exists( l) ) ) ;
513513 assert ! ( lib. map_default( false , |l| is_rwx( l) ) ) ;
@@ -571,7 +571,7 @@ fn test_install_git() {
571571 let _built_lib =
572572 built_library_in_workspace ( & temp_pkg_id,
573573 & ws) . expect ( "test_install_git: built lib should exist" ) ;
574- assert_lib_exists ( & ws, temp_pkg_id. short_name , temp_pkg_id. version . clone ( ) ) ;
574+ assert_lib_exists ( & ws, & temp_pkg_id. path , temp_pkg_id. version . clone ( ) ) ;
575575 let built_test = built_test_in_workspace ( & temp_pkg_id,
576576 & ws) . expect ( "test_install_git: built test should exist" ) ;
577577 assert ! ( os:: path_exists( & built_test) ) ;
@@ -685,7 +685,7 @@ fn test_package_request_version() {
685685
686686 command_line_test([~" install", fmt!(" %s#0.3 ", local_path)], &repo);
687687
688- assert!(match installed_library_in_workspace(" test_pkg_version", &repo.push(" . rust")) {
688+ assert!(match installed_library_in_workspace(&Path( " test_pkg_version") , &repo.push(" . rust")) {
689689 Some(p) => {
690690 debug!(" installed: %s", p.to_str());
691691 p.to_str().ends_with(fmt!(" 0.3 %s", os::consts::DLL_SUFFIX))
@@ -731,7 +731,7 @@ fn rustpkg_library_target() {
731731
732732 add_git_tag(&package_dir, ~" 1.0 ");
733733 command_line_test([~" install", ~" foo"], &foo_repo);
734- assert_lib_exists(&foo_repo.push(" . rust"), " foo", ExactRevision(~" 1.0 "));
734+ assert_lib_exists(&foo_repo.push(" . rust"), &Path( " foo") , ExactRevision(~" 1.0 "));
735735}
736736
737737#[test]
@@ -754,7 +754,7 @@ fn package_script_with_default_build() {
754754 fail!(" Couldn ' t copy file");
755755 }
756756 command_line_test([~" install", ~" fancy-lib"], &dir);
757- assert_lib_exists(&dir, " fancy-lib", NoVersion);
757+ assert_lib_exists(&dir, &Path( " fancy-lib") , NoVersion);
758758 assert!(os::path_exists(&dir.push(" build").push(" fancy-lib").push(" generated. rs")));
759759}
760760
@@ -783,7 +783,7 @@ fn rustpkg_install_no_arg() {
783783 " fn main( ) { let _x = ( ) ; } ");
784784 debug!(" install_no_arg: dir = %s", package_dir.to_str());
785785 command_line_test([~" install"], &package_dir);
786- assert_lib_exists(&tmp, " foo", NoVersion);
786+ assert_lib_exists(&tmp, &Path( " foo") , NoVersion);
787787}
788788
789789#[test]
@@ -1172,11 +1172,11 @@ fn rust_path_hack_test(hack_flag: bool) {
11721172 dest_workspace. to_str( ) , workspace. push_many( [ "src" , "foo-0.1" ] ) . to_str( ) ) ;
11731173 command_line_test_with_env ( ~[ ~"install"] + if hack_flag { ~[ ~"--rust-path-hack"] } else { ~[ ] } +
11741174 ~[ ~"foo"] , & dest_workspace, rust_path) ;
1175- assert_lib_exists ( & dest_workspace, "foo" , NoVersion ) ;
1175+ assert_lib_exists ( & dest_workspace, & Path ( "foo" ) , NoVersion ) ;
11761176 assert_executable_exists ( & dest_workspace, "foo" ) ;
11771177 assert_built_library_exists ( & dest_workspace, "foo" ) ;
11781178 assert_built_executable_exists ( & dest_workspace, "foo" ) ;
1179- assert ! ( !lib_exists( & workspace, "foo" , NoVersion ) ) ;
1179+ assert ! ( !lib_exists( & workspace, & Path ( "foo" ) , NoVersion ) ) ;
11801180 assert ! ( !executable_exists( & workspace, "foo" ) ) ;
11811181 assert ! ( !built_library_exists( & workspace, "foo" ) ) ;
11821182 assert ! ( !built_executable_exists( & workspace, "foo" ) ) ;
@@ -1212,9 +1212,9 @@ fn rust_path_hack_cwd() {
12121212 debug ! ( "declare -x RUST_PATH=%s" , dest_workspace. to_str( ) ) ;
12131213 command_line_test_with_env ( [ ~"install", ~"--rust-path-hack", ~"foo"] , & cwd, rust_path) ;
12141214 debug ! ( "Checking that foo exists in %s" , dest_workspace. to_str( ) ) ;
1215- assert_lib_exists ( & dest_workspace, "foo" , NoVersion ) ;
1215+ assert_lib_exists ( & dest_workspace, & Path ( "foo" ) , NoVersion ) ;
12161216 assert_built_library_exists ( & dest_workspace, "foo" ) ;
1217- assert ! ( !lib_exists( & cwd, "foo" , NoVersion ) ) ;
1217+ assert ! ( !lib_exists( & cwd, & Path ( "foo" ) , NoVersion ) ) ;
12181218 assert ! ( !built_library_exists( & cwd, "foo" ) ) ;
12191219}
12201220
@@ -1232,9 +1232,9 @@ fn rust_path_hack_multi_path() {
12321232 debug ! ( "declare -x RUST_PATH=%s" , dest_workspace. to_str( ) ) ;
12331233 command_line_test_with_env ( [ ~"install", ~"--rust-path-hack", name. clone ( ) ] , & subdir, rust_path) ;
12341234 debug ! ( "Checking that %s exists in %s" , name, dest_workspace. to_str( ) ) ;
1235- assert_lib_exists ( & dest_workspace, "quux" , NoVersion ) ;
1235+ assert_lib_exists ( & dest_workspace, & Path ( "quux" ) , NoVersion ) ;
12361236 assert_built_library_exists ( & dest_workspace, name) ;
1237- assert ! ( !lib_exists( & subdir, "quux" , NoVersion ) ) ;
1237+ assert ! ( !lib_exists( & subdir, & Path ( "quux" ) , NoVersion ) ) ;
12381238 assert ! ( !built_library_exists( & subdir, name) ) ;
12391239}
12401240
@@ -1251,9 +1251,9 @@ fn rust_path_hack_install_no_arg() {
12511251 debug ! ( "declare -x RUST_PATH=%s" , dest_workspace. to_str( ) ) ;
12521252 command_line_test_with_env ( [ ~"install", ~"--rust-path-hack"] , & source_dir, rust_path) ;
12531253 debug ! ( "Checking that foo exists in %s" , dest_workspace. to_str( ) ) ;
1254- assert_lib_exists ( & dest_workspace, "foo" , NoVersion ) ;
1254+ assert_lib_exists ( & dest_workspace, & Path ( "foo" ) , NoVersion ) ;
12551255 assert_built_library_exists ( & dest_workspace, "foo" ) ;
1256- assert ! ( !lib_exists( & source_dir, "foo" , NoVersion ) ) ;
1256+ assert ! ( !lib_exists( & source_dir, & Path ( "foo" ) , NoVersion ) ) ;
12571257 assert ! ( !built_library_exists( & cwd, "foo" ) ) ;
12581258}
12591259
@@ -1378,7 +1378,7 @@ fn notrans_flag_fail() {
13781378 // we can't tell
13791379 assert ! ( !built_executable_exists( & workspace, "foo" ) ) ;
13801380 assert ! ( !object_file_exists( & workspace, "foo" ) ) ;
1381- assert ! ( !lib_exists( & workspace, "foo" , NoVersion ) ) ;
1381+ assert ! ( !lib_exists( & workspace, & Path ( "foo" ) , NoVersion ) ) ;
13821382 }
13831383}
13841384
@@ -1550,6 +1550,37 @@ fn test_optimized_build() {
15501550 assert!(built_executable_exists(&workspace, " foo"));
15511551}
15521552
1553+ fn pkgid_pointing_to_subdir() {
1554+ // The actual repo is mockgithub.com/mozilla/some_repo
1555+ // rustpkg should recognize that and treat the part after some_repo/ as a subdir
1556+ let workspace = mkdtemp(&os::tmpdir(), " parent_repo").expect(" Couldn ' t create temp dir");
1557+ assert!(os::mkdir_recursive(&workspace.push_many([~" src", ~" mockgithub. com",
1558+ ~" mozilla", ~" some_repo"]), U_RWX));
1559+
1560+ let foo_dir = workspace.push_many([~" src", ~" mockgithub. com", ~" mozilla", ~" some_repo",
1561+ ~" extras", ~" foo"]);
1562+ let bar_dir = workspace.push_many([~" src", ~" mockgithub. com", ~" mozilla", ~" some_repo",
1563+ ~" extras", ~" bar"]);
1564+ assert!(os::mkdir_recursive(&foo_dir, U_RWX));
1565+ assert!(os::mkdir_recursive(&bar_dir, U_RWX));
1566+ writeFile(&foo_dir.push(" lib. rs"), " pub fn f( ) { } ");
1567+ writeFile(&bar_dir.push(" lib. rs"), " pub fn g( ) { } ");
1568+
1569+ debug!(" Creating a file in %s", workspace.to_str());
1570+ let testpkg_dir = workspace.push_many([~" src", ~" testpkg-0.1 "]);
1571+ assert!(os::mkdir_recursive(&testpkg_dir, U_RWX));
1572+
1573+ writeFile(&testpkg_dir.push(" main. rs"),
1574+ " extern mod foo = \"mockgithub. com/mozilla/some_repo/extras/foo\" ; \n
1575+ extern mod bar = \"mockgithub. com/mozilla/some_repo/extras/bar\" ; \n
1576+ use foo:: f; use bar:: g; \n
1577+ fn main( ) { f( ) ; g( ) ; } ");
1578+
1579+ debug!(" RUST_PATH =%s", workspace.to_str());
1580+ command_line_test([~" install", ~" testpkg"], &workspace);
1581+ assert_executable_exists(&workspace, " testpkg") ;
1582+ }
1583+
15531584/// Returns true if p exists and is executable
15541585fn is_executable( p: & Path ) -> bool {
15551586 use std:: libc:: consts:: os:: posix88:: { S_IXUSR } ;
0 commit comments