Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make crates-io registry URL optional in config; ignore all changes to source.crates-io #3089

Merged
merged 1 commit into from
Sep 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/cargo/sources/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ a lock file compatible with `{orig}` cannot be generated in this situation
path.push(s);
srcs.push(try!(SourceId::for_directory(&path)));
}
if name == "crates-io" && srcs.is_empty() {
srcs.push(try!(SourceId::crates_io(self.config)));
}

let mut srcs = srcs.into_iter();
let src = try!(srcs.next().chain_error(|| {
Expand Down
48 changes: 48 additions & 0 deletions tests/local-registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,51 @@ unable to verify that `foo v0.0.1` is the same as when the lockfile was generate

"));
}

#[test]
fn crates_io_registry_url_is_optional() {
let root = paths::root();
t!(fs::create_dir(&root.join(".cargo")));
t!(t!(File::create(root.join(".cargo/config"))).write_all(br#"
[source.crates-io]
replace-with = 'my-awesome-local-registry'

[source.my-awesome-local-registry]
local-registry = 'registry'
"#));

Package::new("foo", "0.0.1")
.local(true)
.file("src/lib.rs", "pub fn foo() {}")
.publish();

let p = project("bar")
.file("Cargo.toml", r#"
[project]
name = "bar"
version = "0.0.1"
authors = []

[dependencies]
foo = "0.0.1"
"#)
.file("src/lib.rs", r#"
extern crate foo;
pub fn bar() {
foo::foo();
}
"#);

assert_that(p.cargo_process("build"),
execs().with_status(0).with_stderr(&format!("\
[UNPACKING] foo v0.0.1 ([..])
[COMPILING] foo v0.0.1
[COMPILING] bar v0.0.1 ({dir})
[FINISHED] [..]
",
dir = p.url())));
assert_that(p.cargo("build"), execs().with_status(0).with_stderr("\
[FINISHED] [..]
"));
assert_that(p.cargo("test"), execs().with_status(0));
}