@@ -328,13 +328,13 @@ fn create_local_package_with_custom_build_hook(pkgid: &PkgId,
328
328
329
329
}
330
330
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) ) ;
333
333
}
334
334
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) ;
338
338
debug ! ( "assert_lib_exists: checking whether %? exists" , lib) ;
339
339
lib. is_some ( ) && {
340
340
let libname = lib. get_ref ( ) ;
@@ -507,7 +507,7 @@ fn test_install_valid() {
507
507
assert ! ( os:: path_exists( & exec) ) ;
508
508
assert ! ( is_rwx( & exec) ) ;
509
509
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) ;
511
511
debug ! ( "lib = %?" , lib) ;
512
512
assert ! ( lib. map_default( false , |l| os:: path_exists( l) ) ) ;
513
513
assert ! ( lib. map_default( false , |l| is_rwx( l) ) ) ;
@@ -571,7 +571,7 @@ fn test_install_git() {
571
571
let _built_lib =
572
572
built_library_in_workspace ( & temp_pkg_id,
573
573
& 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 ( ) ) ;
575
575
let built_test = built_test_in_workspace ( & temp_pkg_id,
576
576
& ws) . expect ( "test_install_git: built test should exist" ) ;
577
577
assert ! ( os:: path_exists( & built_test) ) ;
@@ -685,7 +685,7 @@ fn test_package_request_version() {
685
685
686
686
command_line_test([~" install", fmt!(" %s#0.3 ", local_path)], &repo);
687
687
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")) {
689
689
Some(p) => {
690
690
debug!(" installed: %s", p.to_str());
691
691
p.to_str().ends_with(fmt!(" 0.3 %s", os::consts::DLL_SUFFIX))
@@ -731,7 +731,7 @@ fn rustpkg_library_target() {
731
731
732
732
add_git_tag(&package_dir, ~" 1.0 ");
733
733
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 "));
735
735
}
736
736
737
737
#[test]
@@ -754,7 +754,7 @@ fn package_script_with_default_build() {
754
754
fail!(" Couldn ' t copy file");
755
755
}
756
756
command_line_test([~" install", ~" fancy-lib"], &dir);
757
- assert_lib_exists(&dir, " fancy-lib", NoVersion);
757
+ assert_lib_exists(&dir, &Path( " fancy-lib") , NoVersion);
758
758
assert!(os::path_exists(&dir.push(" build").push(" fancy-lib").push(" generated. rs")));
759
759
}
760
760
@@ -783,7 +783,7 @@ fn rustpkg_install_no_arg() {
783
783
" fn main( ) { let _x = ( ) ; } ");
784
784
debug!(" install_no_arg: dir = %s", package_dir.to_str());
785
785
command_line_test([~" install"], &package_dir);
786
- assert_lib_exists(&tmp, " foo", NoVersion);
786
+ assert_lib_exists(&tmp, &Path( " foo") , NoVersion);
787
787
}
788
788
789
789
#[test]
@@ -1172,11 +1172,11 @@ fn rust_path_hack_test(hack_flag: bool) {
1172
1172
dest_workspace. to_str( ) , workspace. push_many( [ "src" , "foo-0.1" ] ) . to_str( ) ) ;
1173
1173
command_line_test_with_env ( ~[ ~"install"] + if hack_flag { ~[ ~"--rust-path-hack"] } else { ~[ ] } +
1174
1174
~[ ~"foo"] , & dest_workspace, rust_path) ;
1175
- assert_lib_exists ( & dest_workspace, "foo" , NoVersion ) ;
1175
+ assert_lib_exists ( & dest_workspace, & Path ( "foo" ) , NoVersion ) ;
1176
1176
assert_executable_exists ( & dest_workspace, "foo" ) ;
1177
1177
assert_built_library_exists ( & dest_workspace, "foo" ) ;
1178
1178
assert_built_executable_exists ( & dest_workspace, "foo" ) ;
1179
- assert ! ( !lib_exists( & workspace, "foo" , NoVersion ) ) ;
1179
+ assert ! ( !lib_exists( & workspace, & Path ( "foo" ) , NoVersion ) ) ;
1180
1180
assert ! ( !executable_exists( & workspace, "foo" ) ) ;
1181
1181
assert ! ( !built_library_exists( & workspace, "foo" ) ) ;
1182
1182
assert ! ( !built_executable_exists( & workspace, "foo" ) ) ;
@@ -1212,9 +1212,9 @@ fn rust_path_hack_cwd() {
1212
1212
debug ! ( "declare -x RUST_PATH=%s" , dest_workspace. to_str( ) ) ;
1213
1213
command_line_test_with_env ( [ ~"install", ~"--rust-path-hack", ~"foo"] , & cwd, rust_path) ;
1214
1214
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 ) ;
1216
1216
assert_built_library_exists ( & dest_workspace, "foo" ) ;
1217
- assert ! ( !lib_exists( & cwd, "foo" , NoVersion ) ) ;
1217
+ assert ! ( !lib_exists( & cwd, & Path ( "foo" ) , NoVersion ) ) ;
1218
1218
assert ! ( !built_library_exists( & cwd, "foo" ) ) ;
1219
1219
}
1220
1220
@@ -1232,9 +1232,9 @@ fn rust_path_hack_multi_path() {
1232
1232
debug ! ( "declare -x RUST_PATH=%s" , dest_workspace. to_str( ) ) ;
1233
1233
command_line_test_with_env ( [ ~"install", ~"--rust-path-hack", name. clone ( ) ] , & subdir, rust_path) ;
1234
1234
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 ) ;
1236
1236
assert_built_library_exists ( & dest_workspace, name) ;
1237
- assert ! ( !lib_exists( & subdir, "quux" , NoVersion ) ) ;
1237
+ assert ! ( !lib_exists( & subdir, & Path ( "quux" ) , NoVersion ) ) ;
1238
1238
assert ! ( !built_library_exists( & subdir, name) ) ;
1239
1239
}
1240
1240
@@ -1251,9 +1251,9 @@ fn rust_path_hack_install_no_arg() {
1251
1251
debug ! ( "declare -x RUST_PATH=%s" , dest_workspace. to_str( ) ) ;
1252
1252
command_line_test_with_env ( [ ~"install", ~"--rust-path-hack"] , & source_dir, rust_path) ;
1253
1253
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 ) ;
1255
1255
assert_built_library_exists ( & dest_workspace, "foo" ) ;
1256
- assert ! ( !lib_exists( & source_dir, "foo" , NoVersion ) ) ;
1256
+ assert ! ( !lib_exists( & source_dir, & Path ( "foo" ) , NoVersion ) ) ;
1257
1257
assert ! ( !built_library_exists( & cwd, "foo" ) ) ;
1258
1258
}
1259
1259
@@ -1378,7 +1378,7 @@ fn notrans_flag_fail() {
1378
1378
// we can't tell
1379
1379
assert ! ( !built_executable_exists( & workspace, "foo" ) ) ;
1380
1380
assert ! ( !object_file_exists( & workspace, "foo" ) ) ;
1381
- assert ! ( !lib_exists( & workspace, "foo" , NoVersion ) ) ;
1381
+ assert ! ( !lib_exists( & workspace, & Path ( "foo" ) , NoVersion ) ) ;
1382
1382
}
1383
1383
}
1384
1384
@@ -1550,6 +1550,37 @@ fn test_optimized_build() {
1550
1550
assert!(built_executable_exists(&workspace, " foo"));
1551
1551
}
1552
1552
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
+
1553
1584
/// Returns true if p exists and is executable
1554
1585
fn is_executable( p: & Path ) -> bool {
1555
1586
use std:: libc:: consts:: os:: posix88:: { S_IXUSR } ;
0 commit comments