Skip to content

Commit 878c73b

Browse files
committed
---
yaml --- r: 64828 b: refs/heads/snap-stage3 c: 8ae900f h: refs/heads/master v: v3
1 parent f5b20be commit 878c73b

File tree

9 files changed

+83
-145
lines changed

9 files changed

+83
-145
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 2830d7d0135f188260f1762e6a47c347e9a603e2
4+
refs/heads/snap-stage3: 8ae900f51d25512a3d95794b1f961ecc31f134f9
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/rustpkg.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,6 @@ A package ID can also specify a version, like:
7676
`github.com/mozilla/rust#0.3`.
7777
In this case, `rustpkg` will check that the repository `github.com/mozilla/rust` has a tag named `0.3`,
7878
and report an error otherwise.
79-
A package ID can also specify a particular revision of a repository, like:
80-
`github.com/mozilla/rust#release-0.7`.
81-
When the refspec (portion of the package ID after the `#`) can't be parsed as a decimal number,
82-
rustpkg passes the refspec along to the version control system without interpreting it.
83-
rustpkg also interprets any dependencies on such a package ID literally
84-
(as opposed to versions, where a newer version satisfies a dependency on an older version).
85-
Thus, `github.com/mozilla/rust#5c4cd30f80` is also a valid package ID,
86-
since git can deduce that 5c4cd30f80 refers to a revision of the desired repository.
8779

8880
## Source files
8981

branches/snap-stage3/mk/tests.mk

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,28 +312,26 @@ define TEST_RUNNER
312312
# If NO_REBUILD is set then break the dependencies on extra so we can
313313
# test crates without rebuilding std and extra first
314314
ifeq ($(NO_REBUILD),)
315-
STDTESTDEP_$(1)_$(2)_$(3) = $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_EXTRALIB_$(2))
315+
STDTESTDEP_$(1)_$(2)_$(3) = $$(SREQ$(1)_T_$(2)_H_$(3)) \
316+
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_EXTRALIB_$(2))
316317
else
317318
STDTESTDEP_$(1)_$(2)_$(3) =
318319
endif
319320

320321
$(3)/stage$(1)/test/stdtest-$(2)$$(X_$(2)): \
321322
$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
322-
$$(SREQ$(1)_T_$(2)_H_$(3)) \
323323
$$(STDTESTDEP_$(1)_$(2)_$(3))
324324
@$$(call E, compile_and_link: $$@)
325325
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
326326

327327
$(3)/stage$(1)/test/extratest-$(2)$$(X_$(2)): \
328328
$$(EXTRALIB_CRATE) $$(EXTRALIB_INPUTS) \
329-
$$(SREQ$(1)_T_$(2)_H_$(3)) \
330329
$$(STDTESTDEP_$(1)_$(2)_$(3))
331330
@$$(call E, compile_and_link: $$@)
332331
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
333332

334333
$(3)/stage$(1)/test/syntaxtest-$(2)$$(X_$(2)): \
335334
$$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
336-
$$(SREQ$(1)_T_$(2)_H_$(3)) \
337335
$$(STDTESTDEP_$(1)_$(2)_$(3))
338336
@$$(call E, compile_and_link: $$@)
339337
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test

branches/snap-stage3/src/librustpkg/package_source.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
use target::*;
1212
use package_id::PkgId;
1313
use std::path::Path;
14-
use std::{os, str};
14+
use std::{os, run, str};
1515
use context::*;
1616
use crate::Crate;
1717
use messages::*;
18-
use source_control::{git_clone, git_clone_general};
18+
use source_control::git_clone;
1919
use path_util::pkgid_src_in_workspace;
2020
use util::compile_crate;
21+
use version::{ExactRevision, SemanticVersion, NoVersion};
2122

2223
// An enumeration of the unpacked source of a package workspace.
2324
// This contains a list of files found in the source workspace.
@@ -101,13 +102,22 @@ impl PkgSrc {
101102
}
102103

103104
let url = fmt!("https://%s", self.id.remote_path.to_str());
104-
note(fmt!("Fetching package: git clone %s %s [version=%s]",
105-
url, local.to_str(), self.id.version.to_str()));
106-
if git_clone_general(url, &local, &self.id.version) {
107-
Some(local)
105+
let branch_args = match self.id.version {
106+
NoVersion => ~[],
107+
ExactRevision(ref s) => ~[~"--branch", (*s).clone()],
108+
SemanticVersion(ref s) => ~[~"--branch", s.to_str()]
109+
};
110+
111+
112+
note(fmt!("Fetching package: git clone %s %s %?", url, local.to_str(), branch_args));
113+
114+
if run::process_output("git",
115+
~[~"clone", url.clone(), local.to_str()] + branch_args).status != 0 {
116+
note(fmt!("fetching %s failed: can't clone repository", url));
117+
None
108118
}
109119
else {
110-
None
120+
Some(local)
111121
}
112122
}
113123

branches/snap-stage3/src/librustpkg/path_util.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ pub fn rust_path() -> ~[Path] {
5252
}
5353
None => ~[]
5454
};
55-
debug!("RUST_PATH entries from environment: %?", env_rust_path);
5655
let cwd = os::getcwd();
5756
// now add in default entries
5857
env_rust_path.push(cwd.clone());
@@ -346,12 +345,7 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
346345
let subdir = match what {
347346
Lib => "lib", Main | Test | Bench => "bin"
348347
};
349-
// Artifacts in the build directory live in a package-ID-specific subdirectory,
350-
// but installed ones don't.
351-
let result = match where {
352-
Build => workspace.push(subdir).push_rel(&*pkgid.local_path),
353-
_ => workspace.push(subdir)
354-
};
348+
let result = workspace.push(subdir);
355349
if !os::path_exists(&result) && !mkdir_recursive(&result, U_RWX) {
356350
cond.raise((result.clone(), fmt!("target_file_in_workspace couldn't \
357351
create the %s dir (pkgid=%s, workspace=%s, what=%?, where=%?",

branches/snap-stage3/src/librustpkg/source_control.rs

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,30 @@
1010

1111
// Utils for working with version control repositories. Just git right now.
1212

13-
use std::{os, run, str};
14-
use std::run::{ProcessOutput, ProcessOptions, Process};
13+
use std::{io, os, run, str};
1514
use version::*;
1615

1716
/// For a local git repo
1817
pub fn git_clone(source: &Path, target: &Path, v: &Version) {
1918
assert!(os::path_is_dir(source));
2019
assert!(is_git_dir(source));
2120
if !os::path_exists(target) {
22-
debug!("Running: git clone %s %s", source.to_str(),
21+
let version_args = match v {
22+
&ExactRevision(ref s) => ~[~"--branch", s.to_owned()],
23+
_ => ~[]
24+
};
25+
debug!("Running: git clone %s %s %s", version_args.to_str(), source.to_str(),
2326
target.to_str());
24-
assert!(git_clone_general(source.to_str(), target, v));
27+
let outp = run::process_output("git", ~[~"clone"] + version_args +
28+
~[source.to_str(), target.to_str()]);
29+
if outp.status != 0 {
30+
io::println(str::from_bytes_owned(outp.output.clone()));
31+
io::println(str::from_bytes_owned(outp.error));
32+
fail!("Couldn't `git clone` %s", source.to_str());
33+
}
2534
}
2635
else {
2736
// Pull changes
28-
// Note that this ignores tags, which is probably wrong. There are no tests for
29-
// it, though.
3037
debug!("Running: git --work-tree=%s --git-dir=%s pull --no-edit %s",
3138
target.to_str(), target.push(".git").to_str(), source.to_str());
3239
let outp = run::process_output("git", [fmt!("--work-tree=%s", target.to_str()),
@@ -36,40 +43,6 @@ pub fn git_clone(source: &Path, target: &Path, v: &Version) {
3643
}
3744
}
3845

39-
/// Source can be either a URL or a local file path.
40-
/// true if successful
41-
pub fn git_clone_general(source: &str, target: &Path, v: &Version) -> bool {
42-
let outp = run::process_output("git", [~"clone", source.to_str(), target.to_str()]);
43-
if outp.status != 0 {
44-
debug!(str::from_bytes_owned(outp.output.clone()));
45-
debug!(str::from_bytes_owned(outp.error));
46-
false
47-
}
48-
else {
49-
match v {
50-
&ExactRevision(ref s) | &Tagged(ref s) => {
51-
let outp = process_output_in_cwd("git", [~"checkout", fmt!("%s", *s)],
52-
target);
53-
if outp.status != 0 {
54-
debug!(str::from_bytes_owned(outp.output.clone()));
55-
debug!(str::from_bytes_owned(outp.error));
56-
false
57-
}
58-
else {
59-
true
60-
}
61-
}
62-
_ => true
63-
}
64-
}
65-
}
66-
67-
fn process_output_in_cwd(prog: &str, args: &[~str], cwd: &Path) -> ProcessOutput {
68-
let mut prog = Process::new(prog, args, ProcessOptions{ dir: Some(cwd)
69-
,..ProcessOptions::new()});
70-
prog.finish_with_output()
71-
}
72-
7346
pub fn is_git_dir(p: &Path) -> bool {
7447
os::path_is_dir(&p.push(".git"))
7548
}

branches/snap-stage3/src/librustpkg/tests.rs

Lines changed: 38 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::run::ProcessOutput;
1818
use installed_packages::list_installed_packages;
1919
use package_path::*;
2020
use package_id::{PkgId};
21-
use version::{ExactRevision, NoVersion, Version, Tagged};
21+
use version::{ExactRevision, NoVersion, Version};
2222
use path_util::{target_executable_in_workspace, target_library_in_workspace,
2323
target_test_in_workspace, target_bench_in_workspace,
2424
make_dir_rwx, U_RWX, library_in_workspace,
@@ -61,16 +61,6 @@ fn git_repo_pkg() -> PkgId {
6161
}
6262
}
6363

64-
fn git_repo_pkg_with_tag(a_tag: ~str) -> PkgId {
65-
let remote = RemotePath(Path("mocki.8713187.xyz/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-
7464
fn writeFile(file_path: &Path, contents: &str) {
7565
let out = io::file_writer(file_path, [io::Create, io::Truncate]).unwrap();
7666
out.write_line(contents);
@@ -158,13 +148,9 @@ fn init_git_repo(p: &Path) -> Path {
158148
}
159149
}
160150

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],
151+
fn add_git_tag(repo: &Path, tag: ~str) {
152+
assert!(repo.is_absolute());
153+
let mut prog = run::Process::new("git", [~"add", ~"-A"],
168154
run::ProcessOptions { env: None,
169155
dir: Some(repo),
170156
in_fd: None,
@@ -173,14 +159,9 @@ fn git_commit(repo: &Path, msg: ~str) {
173159
});
174160
let output = prog.finish_with_output();
175161
if output.status != 0 {
176-
fail!("Couldn't commit in %s: output was %s", repo.to_str(),
177-
str::from_bytes(output.output + output.error))
162+
fail!("Couldn't add all files in %s", repo.to_str())
178163
}
179-
180-
}
181-
182-
fn git_add_all(repo: &Path) {
183-
let mut prog = run::Process::new("git", [~"add", ~"-A"],
164+
prog = run::Process::new("git", [~"commit", ~"-m", ~"whatever"],
184165
run::ProcessOptions { env: None,
185166
dir: Some(repo),
186167
in_fd: None,
@@ -189,16 +170,10 @@ fn git_add_all(repo: &Path) {
189170
});
190171
let output = prog.finish_with_output();
191172
if output.status != 0 {
192-
fail!("Couldn't add all files in %s: output was %s",
193-
repo.to_str(), str::from_bytes(output.output + output.error))
173+
fail!("Couldn't commit in %s", repo.to_str())
194174
}
195-
}
196175

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()],
176+
prog = run::Process::new("git", [~"tag", tag.clone()],
202177
run::ProcessOptions { env: None,
203178
dir: Some(repo),
204179
in_fd: None,
@@ -647,6 +622,31 @@ fn test_package_request_version() {
647622
writeFile(&repo_subdir.push("version-0.4-file.txt"), "hello");
648623
add_git_tag(&repo_subdir, ~"0.4");
649624
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+
650650
command_line_test([~"install", fmt!("%s#0.3", local_path)], &repo);
651651
652652
assert!(match installed_library_in_workspace("test_pkg_version", &repo.push(".rust")) {
@@ -679,7 +679,6 @@ fn rustpkg_install_url_2() {
679679
}
680680
681681
// FIXME: #7956: temporarily disabled
682-
#[test]
683682
fn rustpkg_library_target() {
684683
let foo_repo = init_git_repo(&Path("foo"));
685684
let package_dir = foo_repo.push("foo");
@@ -706,10 +705,8 @@ fn rustpkg_local_pkg() {
706705
assert_executable_exists(&dir, "foo");
707706
}
708707
709-
// FIXME: #7956: temporarily disabled
710-
// Failing on dist-linux bot
711708
#[test]
712-
#[ignore]
709+
#[ignore] // XXX Failing on dist-linux bot
713710
fn package_script_with_default_build() {
714711
let dir = create_local_package(&PkgId::new("fancy-lib", &os::getcwd()));
715712
debug!("dir = %s", dir.to_str());
@@ -768,7 +765,7 @@ fn rustpkg_clean_no_arg() {
768765
}
769766
770767
#[test]
771-
#[ignore (reason = "Specifying env doesn't work -- see #8028")]
768+
#[ignore (reason = "Un-ignore when #7071 is fixed")]
772769
fn rust_path_test() {
773770
let dir_for_path = mkdtemp(&os::tmpdir(), "more_rust").expect("rust_path_test failed");
774771
let dir = mk_workspace(&dir_for_path, &normalize(RemotePath(Path("foo"))), &NoVersion);
@@ -777,13 +774,9 @@ fn rust_path_test() {
777774
778775
let cwd = os::getcwd();
779776
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());
782777
let mut prog = run::Process::new("rustpkg",
783778
[~"install", ~"foo"],
784-
run::ProcessOptions { env: Some(&[(~"RUST_LOG",
785-
~"rustpkg"),
786-
(~"RUST_PATH",
779+
run::ProcessOptions { env: Some(&[(~"RUST_PATH",
787780
dir_for_path.to_str())]),
788781
dir: Some(&cwd),
789782
in_fd: None,
@@ -961,6 +954,7 @@ fn do_rebuild_dep_only_contents_change() {
961954
}
962955
963956
#[test]
957+
#[ignore(reason = "list not yet implemented")]
964958
fn test_versions() {
965959
let workspace = create_local_package(&PkgId::new("foo#0.1", &os::getcwd()));
966960
create_local_package(&PkgId::new("foo#0.2", &os::getcwd()));
@@ -998,35 +992,11 @@ fn test_rustpkg_test() {
998992
}
999993
1000994
#[test]
995+
#[ignore(reason = "uninstall not yet implemented")]
1001996
fn test_uninstall() {
1002997
let workspace = create_local_package(&PkgId::new("foo", &os::getcwd()));
1003998
let _output = command_line_test([~"info", ~"foo"], &workspace);
1004999
command_line_test([~"uninstall", ~"foo"], &workspace);
10051000
let output = command_line_test([~"list"], &workspace);
10061001
assert!(!str::from_bytes(output.output).contains("foo"));
10071002
}
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

Comments
 (0)