@@ -218,7 +218,6 @@ fn command_line_test(args: &[~str], cwd: &Path) -> ProcessOutput {
218
218
fn command_line_test_with_env ( args : & [ ~str ] , cwd : & Path , env : Option < ~[ ( ~str , ~str ) ] > )
219
219
-> ProcessOutput {
220
220
let cmd = test_sysroot ( ) . push ( "bin" ) . push ( "rustpkg" ) . to_str ( ) ;
221
- let cwd = normalize ( RemotePath ( ( * cwd) . clone ( ) ) ) ;
222
221
debug ! ( "About to run command: %? %? in %s" , cmd, args, cwd. to_str( ) ) ;
223
222
assert ! ( os:: path_is_dir( & * cwd) ) ;
224
223
let cwd = ( * cwd) . clone ( ) ;
@@ -322,6 +321,14 @@ fn assert_executable_exists(repo: &Path, short_name: &str) {
322
321
assert ! ( is_rwx( & exec) ) ;
323
322
}
324
323
324
+ fn assert_built_executable_exists ( repo : & Path , short_name : & str ) {
325
+ debug ! ( "assert_built_executable_exists: repo = %s, short_name = %s" , repo. to_str( ) , short_name) ;
326
+ let exec = built_executable_in_workspace ( & PkgId :: new ( short_name, repo) ,
327
+ repo) . expect ( "assert_built_executable_exists failed" ) ;
328
+ assert ! ( os:: path_exists( & exec) ) ;
329
+ assert ! ( is_rwx( & exec) ) ;
330
+ }
331
+
325
332
fn command_line_test_output ( args : & [ ~str ] ) -> ~[ ~str ] {
326
333
let mut result = ~[ ] ;
327
334
let p_output = command_line_test ( args, & os:: getcwd ( ) ) ;
@@ -490,30 +497,29 @@ fn test_install_git() {
490
497
// should have test, bench, lib, and main
491
498
command_line_test ( [ ~"install", temp_pkg_id. local_path . to_str ( ) ] , & repo) ;
492
499
// Check that all files exist
493
- let ws = repo. push ( ".rust" ) ;
494
- debug ! ( "Checking for files in %s" , ws. to_str( ) ) ;
495
- let exec = target_executable_in_workspace ( & temp_pkg_id, & ws) ;
500
+ debug ! ( "Checking for files in %s" , repo. to_str( ) ) ;
501
+ let exec = target_executable_in_workspace ( & temp_pkg_id, & repo) ;
496
502
debug ! ( "exec = %s" , exec. to_str( ) ) ;
497
503
assert ! ( os:: path_exists( & exec) ) ;
498
504
assert ! ( is_rwx( & exec) ) ;
499
505
let _built_lib =
500
506
built_library_in_workspace ( & temp_pkg_id,
501
- & ws ) . expect ( "test_install_git: built lib should exist" ) ;
502
- let lib = target_library_in_workspace ( & temp_pkg_id, & ws ) ;
507
+ & repo ) . expect ( "test_install_git: built lib should exist" ) ;
508
+ let lib = target_library_in_workspace ( & temp_pkg_id, & repo ) ;
503
509
debug ! ( "lib = %s" , lib. to_str( ) ) ;
504
510
assert ! ( os:: path_exists( & lib) ) ;
505
511
assert ! ( is_rwx( & lib) ) ;
506
512
let built_test = built_test_in_workspace ( & temp_pkg_id,
507
- & ws ) . expect ( "test_install_git: built test should exist" ) ;
513
+ & repo ) . expect ( "test_install_git: built test should exist" ) ;
508
514
assert ! ( os:: path_exists( & built_test) ) ;
509
515
let built_bench = built_bench_in_workspace ( & temp_pkg_id,
510
- & ws ) . expect ( "test_install_git: built bench should exist" ) ;
516
+ & repo ) . expect ( "test_install_git: built bench should exist" ) ;
511
517
assert ! ( os:: path_exists( & built_bench) ) ;
512
518
// And that the test and bench executables aren't installed
513
- let test = target_test_in_workspace ( & temp_pkg_id, & ws ) ;
519
+ let test = target_test_in_workspace ( & temp_pkg_id, & repo ) ;
514
520
assert ! ( !os:: path_exists( & test) ) ;
515
521
debug ! ( "test = %s" , test. to_str( ) ) ;
516
- let bench = target_bench_in_workspace ( & temp_pkg_id, & ws ) ;
522
+ let bench = target_bench_in_workspace ( & temp_pkg_id, & repo ) ;
517
523
debug ! ( "bench = %s" , bench. to_str( ) ) ;
518
524
assert ! ( !os:: path_exists( & bench) ) ;
519
525
}
@@ -586,12 +592,12 @@ fn test_package_version() {
586
592
command_line_test([~" install", ~" mockgithub. com/catamorphism/test_pkg_version"],
587
593
&repo);
588
594
assert!(match built_library_in_workspace(&temp_pkg_id,
589
- &repo.push(" . rust ") ) {
595
+ &repo) {
590
596
Some(p) => p.to_str().ends_with(fmt!(" 0.4 %s", os::consts::DLL_SUFFIX)),
591
597
None => false
592
598
});
593
- assert!(built_executable_in_workspace(&temp_pkg_id, &repo.push(" . rust ") )
594
- == Some(repo.push(" . rust ").push(" build").
599
+ assert!(built_executable_in_workspace(&temp_pkg_id, &repo)
600
+ == Some(repo.push(" build").
595
601
push(" mockgithub. com").
596
602
push(" catamorphism").
597
603
push(" test_pkg_version").
@@ -689,7 +695,7 @@ fn rustpkg_library_target() {
689
695
690
696
add_git_tag(&package_dir, ~" 1.0 ");
691
697
command_line_test([~" install", ~" foo"], &foo_repo);
692
- assert_lib_exists(&foo_repo.push(" . rust ") , " foo", ExactRevision(~" 1.0 "));
698
+ assert_lib_exists(&foo_repo, " foo", ExactRevision(~" 1.0 "));
693
699
}
694
700
695
701
#[test]
@@ -716,14 +722,55 @@ fn package_script_with_default_build() {
716
722
assert!(os::path_exists(&dir.push(" build").push(" fancy_lib").push(" generated. rs")));
717
723
}
718
724
725
+ #[test]
726
+ fn rustpkg_build_no_arg() {
727
+ let tmp = mkdtemp(&os::tmpdir(), " rustpkg_build_no_arg").expect(" rustpkg_build_no_arg failed");
728
+ let package_dir = tmp.push(" src").push(" foo");
729
+ assert!(os::mkdir_recursive(&package_dir, U_RWX));
730
+
731
+ writeFile(&package_dir.push(" main. rs"),
732
+ " fn main( ) { let _x = ( ) ; } ");
733
+ debug!(" build_no_arg: dir = %s", package_dir.to_str());
734
+ command_line_test([~" build"], &package_dir);
735
+ assert_built_executable_exists(&tmp, " foo");
736
+ }
737
+
738
+ #[test]
739
+ fn rustpkg_install_no_arg() {
740
+ let tmp = mkdtemp(&os::tmpdir(),
741
+ " rustpkg_install_no_arg").expect(" rustpkg_build_no_arg failed");
742
+ let package_dir = tmp.push(" src").push(" foo");
743
+ assert!(os::mkdir_recursive(&package_dir, U_RWX));
744
+ writeFile(&package_dir.push(" lib. rs"),
745
+ " fn main( ) { let _x = ( ) ; } ");
746
+ debug!(" install_no_arg: dir = %s", package_dir.to_str());
747
+ command_line_test([~" install"], &package_dir);
748
+ assert_lib_exists(&tmp, " foo", NoVersion);
749
+ }
750
+
751
+ #[test]
752
+ fn rustpkg_clean_no_arg() {
753
+ let tmp = mkdtemp(&os::tmpdir(), " rustpkg_clean_no_arg").expect(" rustpkg_clean_no_arg failed");
754
+ let package_dir = tmp.push(" src").push(" foo");
755
+ assert!(os::mkdir_recursive(&package_dir, U_RWX));
756
+
757
+ writeFile(&package_dir.push(" main. rs"),
758
+ " fn main( ) { let _x = ( ) ; } ");
759
+ debug!(" clean_no_arg: dir = %s", package_dir.to_str());
760
+ command_line_test([~" build"], &package_dir);
761
+ assert_built_executable_exists(&tmp, " foo");
762
+ command_line_test([~" clean"], &package_dir);
763
+ assert!(!built_executable_in_workspace(&PkgId::new(" foo", &package_dir),
764
+ &tmp).map_default(false, |m| { os::path_exists(m) }));
765
+ }
766
+
719
767
#[test]
720
768
#[ignore (reason = " Un -ignore when #7071 is fixed")]
721
769
fn rust_path_test() {
722
770
let dir_for_path = mkdtemp(&os::tmpdir(), " more_rust").expect(" rust_path_test failed");
723
771
let dir = mk_workspace(&dir_for_path, &normalize(RemotePath(Path(" foo"))), &NoVersion);
724
772
debug!(" dir = %s", dir.to_str());
725
- writeFile(&Path(" /Users /tjc/more_rust/src/foo-0.1 /main. rs"),
726
- " fn main( ) { let _x = ( ) ; } ");
773
+ writeFile(&dir.push(" main. rs"), " fn main( ) { let _x = ( ) ; } ");
727
774
728
775
let cwd = os::getcwd();
729
776
debug!(" cwd = %s", cwd.to_str());
@@ -781,21 +828,24 @@ fn test_list() {
781
828
let quux = PkgId::new(" quux", &dir);
782
829
create_local_package_in(&quux, &dir);
783
830
831
+ // NOTE Not really great output, though...
832
+ // NOTE do any tests need to be unignored?
784
833
command_line_test([~" install", ~" foo"], &dir);
785
834
let env_arg = ~[(~" RUST_PATH ", dir.to_str())];
835
+ debug!(" RUST_PATH = %s", dir.to_str());
786
836
let list_output = command_line_test_output_with_env([~" list"], env_arg.clone());
787
- assert!(list_output.iter().any(|x| x.starts_with(" foo- ")));
837
+ assert!(list_output.iter().any(|x| x.starts_with(" libfoo_ ")));
788
838
789
839
command_line_test([~" install", ~" bar"], &dir);
790
840
let list_output = command_line_test_output_with_env([~" list"], env_arg.clone());
791
- assert!(list_output.iter().any(|x| x.starts_with(" foo- ")));
792
- assert!(list_output.iter().any(|x| x.starts_with(" bar- ")));
841
+ assert!(list_output.iter().any(|x| x.starts_with(" libfoo_ ")));
842
+ assert!(list_output.iter().any(|x| x.starts_with(" libbar_ ")));
793
843
794
844
command_line_test([~" install", ~" quux"], &dir);
795
845
let list_output = command_line_test_output_with_env([~" list"], env_arg);
796
- assert!(list_output.iter().any(|x| x.starts_with(" foo- ")));
797
- assert!(list_output.iter().any(|x| x.starts_with(" bar- ")));
798
- assert!(list_output.iter().any(|x| x.starts_with(" quux- ")));
846
+ assert!(list_output.iter().any(|x| x.starts_with(" libfoo_ ")));
847
+ assert!(list_output.iter().any(|x| x.starts_with(" libbar_ ")));
848
+ assert!(list_output.iter().any(|x| x.starts_with(" libquux_ ")));
799
849
}
800
850
801
851
#[test]
@@ -836,7 +886,7 @@ fn install_check_duplicates() {
836
886
let mut contents = ~[];
837
887
let check_dups = |p: &PkgId| {
838
888
if contents.contains(p) {
839
- fail!(" package database contains duplicate ID " );
889
+ fail!(" package %s appears in `list` output more than once ", p.local_path.to_str() );
840
890
}
841
891
else {
842
892
contents.push((*p).clone());
0 commit comments