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