Skip to content

Commit

Permalink
Should not have to specify crates-io registry URL to replace-with
Browse files Browse the repository at this point in the history
Since cargo knows crates-io's registry URL and, anyway, you're trying to
say that you don't want to use crates-io.
  • Loading branch information
carols10cents committed Sep 26, 2016
1 parent 9399229 commit 2490f3f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
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));
}

0 comments on commit 2490f3f

Please sign in to comment.