@@ -18,7 +18,7 @@ use std::run::ProcessOutput;
18
18
use installed_packages:: list_installed_packages;
19
19
use package_path:: * ;
20
20
use package_id:: { PkgId } ;
21
- use version:: { ExactRevision , NoVersion , Version } ;
21
+ use version:: { ExactRevision , NoVersion , Version , Tagged } ;
22
22
use path_util:: { target_executable_in_workspace, target_library_in_workspace,
23
23
target_test_in_workspace, target_bench_in_workspace,
24
24
make_dir_rwx, U_RWX , library_in_workspace,
@@ -61,6 +61,16 @@ fn git_repo_pkg() -> PkgId {
61
61
}
62
62
}
63
63
64
+ fn git_repo_pkg_with_tag ( a_tag : ~str ) -> PkgId {
65
+ let remote = RemotePath ( Path ( "mockgithub.com/catamorphism/test-pkg" ) ) ;
66
+ PkgId {
67
+ local_path : normalize ( remote. clone ( ) ) ,
68
+ remote_path : remote,
69
+ short_name : ~"test_pkg",
70
+ version : Tagged ( a_tag)
71
+ }
72
+ }
73
+
64
74
fn writeFile ( file_path : & Path , contents : & str ) {
65
75
let out = io:: file_writer ( file_path, [ io:: Create , io:: Truncate ] ) . unwrap ( ) ;
66
76
out. write_line ( contents) ;
@@ -148,9 +158,13 @@ fn init_git_repo(p: &Path) -> Path {
148
158
}
149
159
}
150
160
151
- fn add_git_tag ( repo : & Path , tag : ~str ) {
152
- assert ! ( repo. is_absolute( ) ) ;
153
- let mut prog = run:: Process :: new ( "git" , [ ~"add", ~"-A "] ,
161
+ fn add_all_and_commit ( repo : & Path ) {
162
+ git_add_all ( repo) ;
163
+ git_commit ( repo, ~"floop") ;
164
+ }
165
+
166
+ fn git_commit ( repo : & Path , msg : ~str ) {
167
+ let mut prog = run:: Process :: new ( "git" , [ ~"commit", ~"-m", msg] ,
154
168
run:: ProcessOptions { env : None ,
155
169
dir : Some ( repo) ,
156
170
in_fd : None ,
@@ -159,9 +173,14 @@ fn add_git_tag(repo: &Path, tag: ~str) {
159
173
} ) ;
160
174
let output = prog. finish_with_output ( ) ;
161
175
if output. status != 0 {
162
- fail ! ( "Couldn't add all files in %s" , repo. to_str( ) )
176
+ fail ! ( "Couldn't commit in %s: output was %s" , repo. to_str( ) ,
177
+ str :: from_bytes( output. output + output. error) )
163
178
}
164
- prog = run:: Process :: new ( "git" , [ ~"commit", ~"-m", ~"whatever"] ,
179
+
180
+ }
181
+
182
+ fn git_add_all ( repo : & Path ) {
183
+ let mut prog = run:: Process :: new ( "git" , [ ~"add", ~"-A "] ,
165
184
run:: ProcessOptions { env : None ,
166
185
dir : Some ( repo) ,
167
186
in_fd : None ,
@@ -170,10 +189,16 @@ fn add_git_tag(repo: &Path, tag: ~str) {
170
189
} ) ;
171
190
let output = prog. finish_with_output ( ) ;
172
191
if output. status != 0 {
173
- fail ! ( "Couldn't commit in %s" , repo. to_str( ) )
192
+ fail ! ( "Couldn't add all files in %s: output was %s" ,
193
+ repo. to_str( ) , str :: from_bytes( output. output + output. error) )
174
194
}
195
+ }
175
196
176
- prog = run:: Process :: new ( "git" , [ ~"tag", tag. clone ( ) ] ,
197
+ fn add_git_tag ( repo : & Path , tag : ~str ) {
198
+ assert ! ( repo. is_absolute( ) ) ;
199
+ git_add_all ( repo) ;
200
+ git_commit ( repo, ~"whatever") ;
201
+ let mut prog = run:: Process :: new ( "git" , [ ~"tag", tag. clone ( ) ] ,
177
202
run:: ProcessOptions { env : None ,
178
203
dir : Some ( repo) ,
179
204
in_fd : None ,
@@ -622,31 +647,6 @@ fn test_package_request_version() {
622
647
writeFile(&repo_subdir.push(" version-0.4 -file. txt"), " hello");
623
648
add_git_tag(&repo_subdir, ~" 0.4 ");
624
649
625
- /*
626
-
627
- let pkg_src = PkgSrc::new(&repo, &repo, &temp_pkg_id);
628
- match temp_pkg_id.version {
629
- ExactRevision(~" 0.3 ") => {
630
- debug!(" Version matches, calling fetch_git");
631
- match pkg_src.fetch_git() {
632
- Some(p) => {
633
- debug!(" does version-0.3 -file exist?");
634
- assert!(os::path_exists(&p.push(" version-0.3 -file. txt")));
635
- debug!(" does version-0.4 -file exist?");
636
- assert!(!os::path_exists(&p.push(" version-0.4 -file. txt")));
637
-
638
- }
639
- None => fail!(" test_package_request_version: fetch_git failed")
640
- }
641
- }
642
- ExactRevision(n) => {
643
- fail!(" n is %? and %? %s %?", n, n, if n == ~" 0.3 " { " ==" } else { " !=" }, " 0.3 ");
644
- }
645
- _ => fail!(fmt!(" test_package_version: package version was %?, expected ExactRevision ( 0.3 ) ",
646
- temp_pkg_id.version))
647
- }
648
- */
649
-
650
650
command_line_test([~" install", fmt!(" %s#0.3 ", local_path)], &repo);
651
651
652
652
assert!(match installed_library_in_workspace(" test_pkg_version", &repo.push(" . rust")) {
@@ -679,6 +679,7 @@ fn rustpkg_install_url_2() {
679
679
}
680
680
681
681
// FIXME: #7956: temporarily disabled
682
+ #[test]
682
683
fn rustpkg_library_target() {
683
684
let foo_repo = init_git_repo(&Path(" foo"));
684
685
let package_dir = foo_repo.push(" foo");
@@ -705,8 +706,10 @@ fn rustpkg_local_pkg() {
705
706
assert_executable_exists(&dir, " foo");
706
707
}
707
708
709
+ // FIXME: #7956: temporarily disabled
710
+ // Failing on dist-linux bot
708
711
#[test]
709
- #[ignore] // XXX Failing on dist-linux bot
712
+ #[ignore]
710
713
fn package_script_with_default_build() {
711
714
let dir = create_local_package(&PkgId::new(" fancy-lib", &os::getcwd()));
712
715
debug!(" dir = %s", dir.to_str());
@@ -765,7 +768,7 @@ fn rustpkg_clean_no_arg() {
765
768
}
766
769
767
770
#[test]
768
- #[ignore (reason = " Un -ignore when # 7071 is fixed ")]
771
+ #[ignore (reason = " Specifying env doesn ' t work -- see # 8028 ")]
769
772
fn rust_path_test() {
770
773
let dir_for_path = mkdtemp(&os::tmpdir(), " more_rust").expect(" rust_path_test failed");
771
774
let dir = mk_workspace(&dir_for_path, &normalize(RemotePath(Path(" foo"))), &NoVersion);
@@ -774,9 +777,13 @@ fn rust_path_test() {
774
777
775
778
let cwd = os::getcwd();
776
779
debug!(" cwd = %s", cwd.to_str());
780
+ debug!(" Running command: cd %s; RUST_LOG =rustpkg RUST_PATH =%s rustpkg install foo",
781
+ cwd.to_str(), dir_for_path.to_str());
777
782
let mut prog = run::Process::new(" rustpkg",
778
783
[~" install", ~" foo"],
779
- run::ProcessOptions { env: Some(&[(~" RUST_PATH ",
784
+ run::ProcessOptions { env: Some(&[(~" RUST_LOG ",
785
+ ~" rustpkg"),
786
+ (~" RUST_PATH ",
780
787
dir_for_path.to_str())]),
781
788
dir: Some(&cwd),
782
789
in_fd: None,
@@ -954,7 +961,6 @@ fn do_rebuild_dep_only_contents_change() {
954
961
}
955
962
956
963
#[test]
957
- #[ignore(reason = " list not yet implemented")]
958
964
fn test_versions() {
959
965
let workspace = create_local_package(&PkgId::new(" foo#0.1 ", &os::getcwd()));
960
966
create_local_package(&PkgId::new(" foo#0.2 ", &os::getcwd()));
@@ -992,11 +998,35 @@ fn test_rustpkg_test() {
992
998
}
993
999
994
1000
#[test]
995
- #[ignore(reason = " uninstall not yet implemented")]
996
1001
fn test_uninstall() {
997
1002
let workspace = create_local_package(&PkgId::new(" foo", &os::getcwd()));
998
1003
let _output = command_line_test([~" info", ~" foo"], &workspace);
999
1004
command_line_test([~" uninstall", ~" foo"], &workspace);
1000
1005
let output = command_line_test([~" list"], &workspace);
1001
1006
assert!(!str::from_bytes(output.output).contains(" foo"));
1002
1007
}
1008
+
1009
+ #[test]
1010
+ fn test_non_numeric_tag() {
1011
+ let temp_pkg_id = git_repo_pkg();
1012
+ let repo = init_git_repo(&Path(temp_pkg_id.local_path.to_str()));
1013
+ let repo_subdir = repo.push(" mockgithub. com").push(" catamorphism").push(" test_pkg");
1014
+ writeFile(&repo_subdir.push(" foo"), " foo");
1015
+ writeFile(&repo_subdir.push(" lib. rs"),
1016
+ " pub fn f( ) { let _x = ( ) ; } ");
1017
+ add_git_tag(&repo_subdir, ~" testbranch");
1018
+ writeFile(&repo_subdir.push(" testbranch_only"), " hello");
1019
+ add_git_tag(&repo_subdir, ~" another_tag");
1020
+ writeFile(&repo_subdir.push(" not_on_testbranch_only"), " bye bye");
1021
+ add_all_and_commit(&repo_subdir);
1022
+
1023
+
1024
+ command_line_test([~" install", fmt!(" %s#testbranch", temp_pkg_id.remote_path.to_str())],
1025
+ &repo);
1026
+ let file1 = repo.push_many([" mockgithub. com", " catamorphism",
1027
+ " test_pkg", " testbranch_only"]);
1028
+ let file2 = repo.push_many([" mockgithub. com", " catamorphism", " test_pkg",
1029
+ " master_only"] ) ;
1030
+ assert ! ( os:: path_exists( & file1) ) ;
1031
+ assert ! ( !os:: path_exists( & file2) ) ;
1032
+ }
0 commit comments